Compare commits
3 Commits
d834bac2f4
...
v4.1
Author | SHA1 | Date | |
---|---|---|---|
203d7fee48
|
|||
530f5a54c8
|
|||
01567bb069
|
2
XD.1
2
XD.1
@@ -85,6 +85,6 @@ $ \fBXD -e $?\fR
|
||||
.br
|
||||
In a git repository.
|
||||
.br
|
||||
The're staged changes.
|
||||
There staged changes.
|
||||
.br
|
||||
Return code of 130, ctrl-c was pressed, or SIGTERM sent.
|
||||
|
30
XD.c
30
XD.c
@@ -61,8 +61,9 @@ static int explain = 0;
|
||||
char
|
||||
*find_git_repo()
|
||||
{
|
||||
char path[PATH_MAX] = ".", *rpath;
|
||||
char path[PATH_MAX] = ".", fstr[PATH_MAX], *rpath, *res;
|
||||
struct stat s;
|
||||
FILE *f;
|
||||
int i, c;
|
||||
|
||||
/* find the number of jumps to the root of the fs */
|
||||
@@ -83,9 +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 && S_ISDIR(s.st_mode)) {
|
||||
return realpath(path, 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);
|
||||
@@ -301,7 +321,7 @@ main(int argc, char *argv[])
|
||||
|
||||
/* change the nose depending on the current git repo's status */
|
||||
if (has_staged(repo)) {
|
||||
E("They're staged changes.")
|
||||
E("There staged changes.")
|
||||
P("*"); /* change to broken nose for staged changes */
|
||||
} else if (has_untracked(repo)) {
|
||||
E("There are untracked changes in the repository.")
|
||||
|
Reference in New Issue
Block a user