[PATCH 3/3] git-show-branch: avoid any column to be flagged as branch head if head is detached
For a detached head, resolve_ref() returns the argument "HEAD"
unmodified. That case is checked for and pretended to be NULL,
which consequently avoids any column to be flagged as branch head.
---
builtin-show-branch.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/builtin-show-branch.c b/builtin-show-branch.c
index 96ae3cb..b073a31 100644
--- a/builtin-show-branch.c
+++ b/builtin-show-branch.c
@@ -766,6 +766,9 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
}
head_p = resolve_ref("HEAD", head_sha1, 1, NULL);
+ if (head_p && !strcmp(head_p, "HEAD")) {
+ head_p = NULL;
+ }
if (head_p) {
head_len = strlen(head_p);
memcpy(head, head_p, head_len + 1);
--
1.6.1