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>
Phil Hord committed
Oct 4, 2011 at 16:05 UTC
03106768afa0be60346bb335f9fd11063622c91d
1 file changed
+7
-1
path.c
+7
-1
@@ -295,6 +295,7 @@ const char *enter_repo(const char *path, int strict)
295
static const char *suffix[] = {
296
".git/.git", "/.git", ".git", "", NULL,
297
};
298
+ const char *gitfile;
299
int len = strlen(path);
300
int i;
301
while ((1 < len) && (path[len-1] == '/'))
@@ -329,7 +330,12 @@ const char *enter_repo(const char *path, int strict)
330
break;
331
}
332
}
332
- if (!suffix[i] || chdir(used_path))
333
+ if (!suffix[i])
334
+ return NULL;
335
+ gitfile = read_gitfile(used_path) ;
336
+ if (gitfile)
337
+ strcpy(used_path, gitfile);
338
+ if (chdir(used_path))
339
return NULL;
340
path = validated_path;
341
}