summaryrefslogtreecommitdiff
path: root/refs.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2008-05-05 19:16:16 -0700
committerJunio C Hamano <gitster@pobox.com>2008-05-05 19:16:16 -0700
commite2e2defc14a79ea5b4aaae23e33072f29c5965eb (patch)
tree6a86523e0105c66bef7e7ee8610773d185b7cad3 /refs.c
parent9c36e1700f99811ea9190279ea197424dcbb0303 (diff)
parentc48799e560c826905e87c8a8a71effeb0ca5e897 (diff)
downloadgit-e2e2defc14a79ea5b4aaae23e33072f29c5965eb.tar.gz
Merge branch 'lh/git-file'
* lh/git-file: Teach GIT-VERSION-GEN about the .git file Teach git-submodule.sh about the .git file Teach resolve_gitlink_ref() about the .git file Add platform-independent .git "symlink"
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 4db73ed8f0..9b495eb16e 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;
}