aboutsummaryrefslogtreecommitdiff
path: root/path.c
diff options
context:
space:
mode:
authorJiang Xin <worldhello.net@gmail.com>2012-02-28 12:23:26 +0800
committerJiang Xin <worldhello.net@gmail.com>2012-02-28 12:23:26 +0800
commit508d1244dc8d38188c70e98207efa8a97d16b47c (patch)
treefc8688b80be453755f8135df11bf1db2d247725a /path.c
parent0ad9e96d2e2f42f4d2ce7cd612bf741913242bc0 (diff)
parent25a7850a106ed0f27b88b8ce0b89fd326120dff4 (diff)
downloadgit-508d1244dc8d38188c70e98207efa8a97d16b47c.tar.gz
git-508d1244dc8d38188c70e98207efa8a97d16b47c.tar.xz
Merge branch 'master' into git-po
Diffstat (limited to 'path.c')
-rw-r--r--path.c7
1 files changed, 5 insertions, 2 deletions
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;
}