Skip to content

Commit

Permalink
show-branch --current: do not barf on detached HEAD
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Junio C Hamano committed May 26, 2008
1 parent a2f5be5 commit f8fcb57
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions builtin-show-branch.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down

0 comments on commit f8fcb57

Please sign in to comment.