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

[PATCH 1/3] git-show-branch: allow for multiple branch head columns

From
DWDirk Wallenstein <halsmit@t-online.de>
Date
Feb 25, 2009, 10:17 UTC
Message-ID
<fa82452302afa700e7cbbacbf2d58a8c188a0c62.1235499771.git.halsmit@t-online.de>
In-Reply-To
<cover.1235499771.git.halsmit@t-online.de>
If multiple refs point to the current branch head, each of them
should show a '*' in the corresponding column. This commit changes
this information about columns from an absolute index to a bitmask.
---
 builtin-show-branch.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/builtin-show-branch.c b/builtin-show-branch.c
index 306b850..df83491 100644
--- a/builtin-show-branch.c
+++ b/builtin-show-branch.c
@@ -604,7 +604,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
 	int sha1_name = 0;
 	int shown_merge_point = 0;
 	int with_current_branch = 0;
-	int head_at = -1;
+	unsigned int head_at = 0;
 	int topics = 0;
 	int dense = 1;
 	int reflog = 0;
@@ -855,8 +855,10 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
 			else
 				puts(reflog_msg[i]);
 
-			if (is_head)
-				head_at = i;
+			if (is_head) {
+				assert(MAX_REVS <= (sizeof(head_at) * 8));
+				head_at |= (1UL << i);
+			}
 		}
 		if (0 <= extra) {
 			for (i = 0; i < num_rev; i++)
@@ -900,7 +902,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
 					mark = ' ';
 				else if (is_merge)
 					mark = '-';
-				else if (i == head_at)
+				else if (head_at & (1UL << i))
 					mark = '*';
 				else
 					mark = '+';
-- 
1.6.1
Previous: Dirk WallensteinNext: Dirk Wallenstein
Message 2 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.