diff options
author | Junio C Hamano <gitster@pobox.com> | 2012-02-14 12:57:18 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2012-02-14 12:57:18 -0800 |
commit | 0364bb135e285d4118b69979ade3078fab50e08a (patch) | |
tree | 25b765f0b43fd761ba42815a4eae9df3f4bd5545 /path.c | |
parent | 10439fc0effb194e1ce2cd4db8fbd69cfaf23656 (diff) | |
parent | b3256eb8b35937192e85725d0c2bcb422295790c (diff) | |
download | git-0364bb135e285d4118b69979ade3078fab50e08a.tar.gz git-0364bb135e285d4118b69979ade3078fab50e08a.tar.xz |
Merge branch 'jk/git-dir-lookup'
* jk/git-dir-lookup:
standardize and improve lookup rules for external local repos
Diffstat (limited to 'path.c')
-rw-r--r-- | path.c | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -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; } |