summaryrefslogtreecommitdiff
path: root/show-branch.c
diff options
context:
space:
mode:
authorJunio C Hamano <junio@twinsun.com>2005-09-30 14:26:57 -0700
committerJunio C Hamano <junkio@cox.net>2005-10-01 23:19:33 -0700
commit8098a178b26dc7a158d129a092a5b78da6d12b72 (patch)
treea91aec067dd33319e2f33de565c42ef43b449b56 /show-branch.c
parenta876ed83be5467d6075da8a16306724cb1babc2a (diff)
downloadgit-8098a178b26dc7a158d129a092a5b78da6d12b72.tar.gz
Add git-symbolic-ref
This adds the counterpart of git-update-ref that lets you read and create "symbolic refs". By default it uses a symbolic link to represent ".git/HEAD -> refs/heads/master", but it can be compiled to use the textfile symbolic ref. The places that did 'readlink .git/HEAD' and 'ln -s refs/heads/blah .git/HEAD' have been converted to use new git-symbolic-ref command, so that they can deal with either implementation. Signed-off-by: Junio C Hamano <junio@twinsun.com>
Diffstat (limited to 'show-branch.c')
-rw-r--r--show-branch.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/show-branch.c b/show-branch.c
index 5778a594f4..8429c171cf 100644
--- a/show-branch.c
+++ b/show-branch.c
@@ -349,6 +349,7 @@ int main(int ac, char **av)
int all_heads = 0, all_tags = 0;
int all_mask, all_revs, shown_merge_point;
char head_path[128];
+ const char *head_path_p;
int head_path_len;
unsigned char head_sha1[20];
int merge_base = 0;
@@ -430,11 +431,15 @@ int main(int ac, char **av)
if (0 <= extra)
join_revs(&list, &seen, num_rev, extra);
- head_path_len = readlink(".git/HEAD", head_path, sizeof(head_path)-1);
- if ((head_path_len < 0) || get_sha1("HEAD", head_sha1))
+ head_path_p = resolve_ref(git_path("HEAD"), head_sha1, 1);
+ if (head_path_p) {
+ head_path_len = strlen(head_path_p);
+ memcpy(head_path, head_path_p, head_path_len + 1);
+ }
+ else {
+ head_path_len = 0;
head_path[0] = 0;
- else
- head_path[head_path_len] = 0;
+ }
if (merge_base)
return show_merge_base(seen, num_rev);