formatting

This commit is contained in:
Squibid 2025-11-10 19:08:44 -05:00
parent 203d7fee48
commit 4e3d6f9b4a
Signed by: squibid
GPG key ID: BECE5684D3C4005D
3 changed files with 27 additions and 26 deletions

Binary file not shown.

1
.gitignore vendored
View file

@ -1,3 +1,4 @@
*.o *.o
XD XD
compile_commands.json compile_commands.json
.cache

52
XD.c
View file

@ -59,11 +59,11 @@ static int explain = 0;
* @return absolute path to git repo * @return absolute path to git repo
*/ */
char char
*find_git_repo() *find_git_repo(void)
{ {
char path[PATH_MAX] = ".", fstr[PATH_MAX], *rpath, *res; char path[PATH_MAX] = ".", fstr[PATH_MAX], *rpath, *res;
struct stat s; struct stat s;
FILE *f; FILE *f;
int i, c; int i, c;
/* find the number of jumps to the root of the fs */ /* find the number of jumps to the root of the fs */
@ -84,28 +84,28 @@ char
strcat(path, "/.git"); strcat(path, "/.git");
/* if there seems to be a git directory return the directory it was found in */ /* if there seems to be a git directory return the directory it was found in */
if (stat(path, &s) == 0) { if (stat(path, &s) == 0) {
if (S_ISDIR(s.st_mode)) { if (S_ISDIR(s.st_mode)) {
return realpath(path, NULL); return realpath(path, NULL);
} else if (S_ISREG(s.st_mode)) { } else if (S_ISREG(s.st_mode)) {
/* we do some special magic here to check if we're in a submodule */ /* we do some special magic here to check if we're in a submodule */
f = fopen(path, "r"); f = fopen(path, "r");
if (!f) { if (!f) {
L("fopen: %s", strerror(errno)); L("fopen: %s", strerror(errno));
return NULL; return NULL;
} }
res = fgets(fstr, PATH_MAX, f); res = fgets(fstr, PATH_MAX, f);
fclose(f); fclose(f);
if (!res) { if (!res) {
L("fgets: %s", strerror(errno)); L("fgets: %s", strerror(errno));
return NULL; return NULL;
} }
if (strncmp(fstr, "gitdir: ", strlen("gitdir: ")) == 0) { if (strncmp(fstr, "gitdir: ", strlen("gitdir: ")) == 0) {
fstr[strlen(fstr) - 1] = '\0'; fstr[strlen(fstr) - 1] = '\0';
return realpath(fstr + strlen("gitdir: "), NULL); return realpath(fstr + strlen("gitdir: "), NULL);
} }
} }
} }
/* reset contents of gpath, and go up a directory */ /* reset contents of gpath, and go up a directory */
memset(&path[strlen(path) - 4], '.', 2); memset(&path[strlen(path) - 4], '.', 2);
@ -121,7 +121,7 @@ char
* @return a pointer to the git repo object * @return a pointer to the git repo object
*/ */
git_repository git_repository
*init_git() *init_git(void)
{ {
char *buf; char *buf;
git_repository *repo; git_repository *repo;
@ -166,7 +166,7 @@ git_repository
int int
has_stashes(git_repository *repo) has_stashes(git_repository *repo)
{ {
git_reference *stash = NULL; git_reference *stash = NULL;
int e; int e;
e = git_reference_lookup(&stash, repo, "refs/stash"); e = git_reference_lookup(&stash, repo, "refs/stash");