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

[PATCH] show-branch: mark active branch with a '*' again

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Sep 21, 2006, 22:07 UTC
Message-ID
<Pine.LNX.4.63.0609220006010.19042@wbgn013.biozentrum.uni-wuerzburg.de>

This was lost in the packed-ref updates. The original test was a bit dubious, so I cleaned that up, too. It fixes the case when the current HEAD is refs/heads/bla/master: the original test was true for both bla/master _and_ master.

However, it shares a hard-to-fix bug with the original test: if the current HEAD is refs/heads/master, and there is a branch refs/heads/heads/master, then both are marked active.

Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
---
	... and since nobody uses headlen, there is no need to fix that up.
 builtin-show-branch.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/builtin-show-branch.c b/builtin-show-branch.c
index 5d6ce56..fb1a400 100644
--- a/builtin-show-branch.c
+++ b/builtin-show-branch.c
@@ -443,6 +443,12 @@ static int rev_is_head(char *head, int h
 	if ((!head[0]) ||
 	    (head_sha1 && sha1 && hashcmp(head_sha1, sha1)))
 		return 0;
+	if (!strncmp(head, "refs/heads/", 11))
+		head += 11;
+	if (!strncmp(name, "refs/heads/", 11))
+		name += 11;
+	else if (!strncmp(name, "heads/", 6))
+		name += 6;
 	return !strcmp(head, name);
 }
 
-- 
1.4.2.1.g9797-dirty
Message 1 of 1 in “show-branch: mark active branch with a '*' again”
  1. show-branch: mark active branch with a '*' againJohannes Schindelin, Sep 21, 2006

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.