summaryrefslogtreecommitdiff
path: root/refs.c
diff options
context:
space:
mode:
authorLars Hjemli <hjemli@gmail.com>2008-02-20 23:13:14 +0100
committerJunio C Hamano <gitster@pobox.com>2008-04-09 01:22:50 -0700
commit842abf06f36b5b31050db6406265972e3e1cc189 (patch)
tree06d8b89bf2cd6ca8f4878fffe9392673eaac5c38 /refs.c
parentb44ebb19e3234c5dffe9869ceac5408bb44c2e20 (diff)
downloadgit-842abf06f36b5b31050db6406265972e3e1cc189.tar.gz
Teach resolve_gitlink_ref() about the .git file
When .git in a submodule is a file, resolve_gitlink_ref() needs to pick up the real GIT_DIR of the submodule from that file. Signed-off-by: Lars Hjemli <hjemli@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'refs.c')
-rw-r--r--refs.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/refs.c b/refs.c
index 1b0050eee4..a81fb291f8 100644
--- a/refs.c
+++ b/refs.c
@@ -352,6 +352,7 @@ int resolve_gitlink_ref(const char *path, const char *refname, unsigned char *re
{
int len = strlen(path), retval;
char *gitdir;
+ const char *tmp;
while (len && path[len-1] == '/')
len--;
@@ -359,9 +360,19 @@ int resolve_gitlink_ref(const char *path, const char *refname, unsigned char *re
return -1;
gitdir = xmalloc(len + MAXREFLEN + 8);
memcpy(gitdir, path, len);
- memcpy(gitdir + len, "/.git/", 7);
-
- retval = resolve_gitlink_ref_recursive(gitdir, len+6, refname, result, 0);
+ memcpy(gitdir + len, "/.git", 6);
+ len += 5;
+
+ tmp = read_gitfile_gently(gitdir);
+ if (tmp) {
+ free(gitdir);
+ len = strlen(tmp);
+ gitdir = xmalloc(len + MAXREFLEN + 3);
+ memcpy(gitdir, tmp, len);
+ }
+ gitdir[len] = '/';
+ gitdir[++len] = '\0';
+ retval = resolve_gitlink_ref_recursive(gitdir, len, refname, result, 0);
free(gitdir);
return retval;
}