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