Skip to content

Commit 0310676

Browse files
phordgitster
authored andcommitted
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>
1 parent 1c64b48 commit 0310676

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

path.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@ const char *enter_repo(const char *path, int strict)
295295
static const char *suffix[] = {
296296
".git/.git", "/.git", ".git", "", NULL,
297297
};
298+
const char *gitfile;
298299
int len = strlen(path);
299300
int i;
300301
while ((1 < len) && (path[len-1] == '/'))
@@ -329,7 +330,12 @@ const char *enter_repo(const char *path, int strict)
329330
break;
330331
}
331332
}
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))
333339
return NULL;
334340
path = validated_path;
335341
}

0 commit comments

Comments
 (0)