git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 3/3] git-show-branch: avoid any column to be flagged as branch head if head is detached

From
DWDirk Wallenstein <halsmit@t-online.de>
Date
Feb 25, 2009, 10:17 UTC
Message-ID
<8e3c6fcd00a6a809bf1cca383a09c8d077c945d6.1235499771.git.halsmit@t-online.de>
In-Reply-To
<cover.1235499771.git.halsmit@t-online.de>
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
Previous: Dirk WallensteinNext: Halsmit
Message 4 of 5 in “git-branch-head: recognize all refs pointing to the current branch head as such”
  1. 0/3 git-branch-head: recognize all refs pointing to the current branch head as suchDirk Wallenstein, Feb 25, 2009
  2. 1/3 git-show-branch: allow for multiple branch head columnsDirk Wallenstein, Feb 25, 2009
  3. 2/3 git-show-branch: sha1 based branch head determinationDirk Wallenstein, Feb 25, 2009
  4. 3/3 git-show-branch: avoid any column to be flagged as branch head if head is detachedDirk Wallenstein, Feb 25, 2009
  5. HalsmitFeb 25, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.