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>
This commit is contained in:
Junio C Hamano
2005-09-30 14:26:57 -07:00
committed by Junio C Hamano
parent a876ed83be
commit 8098a178b2
16 changed files with 175 additions and 56 deletions

View File

@ -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);