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

[PATCH 2/3] git-show-branch: sha1 based branch head determination

From
DWDirk Wallenstein <halsmit@t-online.de>
Date
Feb 25, 2009, 10:17 UTC
Message-ID
<14706b525c71ab0628e54f7bd24b3303bf422698.1235499771.git.halsmit@t-online.de>
In-Reply-To
<cover.1235499771.git.halsmit@t-online.de>
Any ref that points to the same object as the one that is
currently pointed at by HEAD, is recognized as head, which is
then marked with a '*' in the corresponding column.
---
 builtin-show-branch.c |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/builtin-show-branch.c b/builtin-show-branch.c
index df83491..96ae3cb 100644
--- a/builtin-show-branch.c
+++ b/builtin-show-branch.c
@@ -460,9 +460,16 @@ static void snarf_refs(int head, int remotes)
 static int rev_is_head(char *head, int headlen, char *name,
 		       unsigned char *head_sha1, unsigned char *sha1)
 {
-	if ((!head[0]) ||
-	    (head_sha1 && sha1 && hashcmp(head_sha1, sha1)))
+	if (!head[0])
 		return 0;
+	if (head_sha1 && sha1) {
+		if (hashcmp(head_sha1, sha1)) {
+			return 0;
+		} else {
+			return 1;
+		}
+	}
+
 	if (!prefixcmp(head, "refs/heads/"))
 		head += 11;
 	if (!prefixcmp(name, "refs/heads/"))
-- 
1.6.1
Previous: Dirk WallensteinNext: Dirk Wallenstein
Message 3 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.