summaryrefslogtreecommitdiff
path: root/builtin-show-branch.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2008-05-26 22:09:51 (GMT)
committerJunio C Hamano <gitster@pobox.com>2008-05-26 22:09:56 (GMT)
commitf8fcb57bb45e8d3d8f7921377d6c2503590efc3c (patch)
tree507b5e2cd7d171006447032f031e2157e451c140 /builtin-show-branch.c
parenta2f5be500839bdf75e4721cc68642b821128b7b9 (diff)
downloadgit-f8fcb57bb45e8d3d8f7921377d6c2503590efc3c.zip
git-f8fcb57bb45e8d3d8f7921377d6c2503590efc3c.tar.gz
git-f8fcb57bb45e8d3d8f7921377d6c2503590efc3c.tar.bz2
show-branch --current: do not barf on detached HEAD
The code assumed that there always is the current branch, but the result from resolve_ref() on detached HEAD does not even start with "refs/heads/". Originally noticed and fixed by Stephan Beyer. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin-show-branch.c')
-rw-r--r--builtin-show-branch.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/builtin-show-branch.c b/builtin-show-branch.c
index 019abd3..a383323 100644
--- a/builtin-show-branch.c
+++ b/builtin-show-branch.c
@@ -782,8 +782,8 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
has_head++;
}
if (!has_head) {
- int pfxlen = strlen("refs/heads/");
- append_one_rev(head + pfxlen);
+ int offset = !prefixcmp(head, "refs/heads/") ? 11 : 0;
+ append_one_rev(head + offset);
}
}