Skip to content

Commit

Permalink
Learn to handle gitfiles in enter_repo
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Phil Hord authored and Junio C Hamano committed Oct 4, 2011
1 parent 1c64b48 commit 0310676
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion path.c
Original file line number Diff line number Diff line change
Expand Up @@ -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] == '/'))
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 0310676

Please sign in to comment.