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

52
XD.c
View file

@ -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");