提交 f8fcb57b 编写于 作者: J Junio C Hamano

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: NJunio C Hamano <gitster@pobox.com>
上级 a2f5be50
......@@ -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);
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册