summaryrefslogtreecommitdiff
path: root/path.c
diff options
context:
space:
mode:
authorPhil Hord <phil.hord@gmail.com>2011-10-04 20:05:17 (GMT)
committerJunio C Hamano <gitster@pobox.com>2011-10-04 20:30:38 (GMT)
commit03106768afa0be60346bb335f9fd11063622c91d (patch)
tree4814b73c349de3699d796eafced24a6ff68ae573 /path.c
parent1c64b48e67c2c83508c45817002468a9a633c991 (diff)
downloadgit-03106768afa0be60346bb335f9fd11063622c91d.zip
git-03106768afa0be60346bb335f9fd11063622c91d.tar.gz
git-03106768afa0be60346bb335f9fd11063622c91d.tar.bz2
Learn to handle gitfiles in enter_repo
The enter_repo() function is used to navigate into a .git directory. It knows how to find standard alternatives (DWIM) but it doesn't handle gitfiles created by git init --separate-git-dir. This means that git-fetch and others do not work with repositories using the separate-git-dir mechanism. Teach enter_repo() to deal with the gitfile mechanism by resolving the path to the redirected path and continuing tests on that path instead of the found file. Signed-off-by: Phil Hord <hordp@cisco.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'path.c')
-rw-r--r--path.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/path.c b/path.c
index 01028f2..b6f71d1 100644
--- a/path.c
+++ b/path.c
@@ -295,6 +295,7 @@ const char *enter_repo(const char *path, int strict)
static const char *suffix[] = {
".git/.git", "/.git", ".git", "", NULL,
};
+ const char *gitfile;
int len = strlen(path);
int i;
while ((1 < len) && (path[len-1] == '/'))
@@ -329,7 +330,12 @@ const char *enter_repo(const char *path, int strict)
break;
}
}
- if (!suffix[i] || chdir(used_path))
+ if (!suffix[i])
+ return NULL;
+ gitfile = read_gitfile(used_path) ;
+ if (gitfile)
+ strcpy(used_path, gitfile);
+ if (chdir(used_path))
return NULL;
path = validated_path;
}