X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=path.c;h=6f2aa699ad63c2f7c65632761efbaebb7f461868;hb=09b90fb3c065ac5ac2ad051596b036131ecedbd5;hp=b6f71d1086981dc41bdbbc8954eccd9e9b719f98;hpb=b95ffc143fee155e9ef7ef5e4def38c58febf2ee;p=git.git diff --git a/path.c b/path.c index b6f71d108..6f2aa699a 100644 --- a/path.c +++ b/path.c @@ -293,7 +293,7 @@ const char *enter_repo(const char *path, int strict) if (!strict) { static const char *suffix[] = { - ".git/.git", "/.git", ".git", "", NULL, + "/.git", "", ".git/.git", ".git", NULL, }; const char *gitfile; int len = strlen(path); @@ -324,8 +324,11 @@ const char *enter_repo(const char *path, int strict) return NULL; len = strlen(used_path); for (i = 0; suffix[i]; i++) { + struct stat st; strcpy(used_path + len, suffix[i]); - if (!access(used_path, F_OK)) { + if (!stat(used_path, &st) && + (S_ISREG(st.st_mode) || + (S_ISDIR(st.st_mode) && is_git_directory(used_path)))) { strcat(validated_path, suffix[i]); break; }