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

[PATCH 3/4] Default to displaying /all/ non-tag refs, not just locals

From
APAndy Parkins <andyparkins@gmail.com>
Date
Nov 2, 2006, 11:11 UTC
Message-ID
<200611021111.22604.andyparkins@gmail.com>
In-Reply-To
<bec6ab7849e3fcacac23cca44a0ba93282af5fca.1162465753.git.andyparkins@gmail.com>

Adds support for display_mode == 2; which shows all non-tag refs. I've set display_mode = 2 by default so it's easily reverted if needed - or if a switch for the old mode is wanted it can be easily added

Signed-off-by: Andy Parkins <andyparkins@gmail.com>
---
 builtin-branch.c |   32 +++++++++++++++++++++++++-------
 1 files changed, 25 insertions(+), 7 deletions(-)
diff --git a/builtin-branch.c b/builtin-branch.c
index 85b7007..b88413a 100644
--- a/builtin-branch.c
+++ b/builtin-branch.c
@@ -104,20 +104,38 @@ static void print_ref_list(int display_m
 {
 	int i;
 	char c;
+	char *p;
 
-	if (display_mode)
-		for_each_remote_ref(append_ref, NULL);
-	else
-		for_each_branch_ref(append_ref, NULL);
+	switch (display_mode) {
+		case 0:
+			for_each_branch_ref(append_ref, NULL);
+			break;
+		case 1:
+			for_each_remote_ref(append_ref, NULL);
+			break;
+		case 2:
+			for_each_ref(append_ref, NULL);
+			break;
+	}
 
 	qsort(ref_list, ref_index, sizeof(char *), ref_cmp);
 
 	for (i = 0; i < ref_index; i++) {
+		p = ref_list[i];
+		if (display_mode == 2) {
+			if (!strncmp( p, "refs/", 5 ))
+				p += 5;
+			if (!strncmp( p, "tags/", 5 ))
+				continue;
+			if (!strncmp( p, "heads/", 6 ))
+				p += 6;
+		}
+
 		c = ' ';
-		if (!strcmp(ref_list[i], head))
+		if (!strcmp(p, head))
 			c = '*';
 
-		printf("%c %s\n", c, ref_list[i]);
+		printf("%c %s\n", c, p);
 	}
 }
 
@@ -160,7 +178,7 @@ static void create_branch(const char *na
 
 int cmd_branch(int argc, const char **argv, const char *prefix)
 {
-	int delete = 0, force_delete = 0, force_create = 0, display_mode = 0;
+	int delete = 0, force_delete = 0, force_create = 0, display_mode = 2;
 	int reflog = 0;
 	int i;
 
-- 
1.4.3.2
Previous: Junio C HamanoNext: Junio C Hamano
Message 16 of 23 in “Rename remote_only to display_mode”
  1. 2/4 Rename remote_only to display_modeAndy Parkins, Nov 2, 2006
  2. Junio C HamanoNov 3, 2006
  3. Andy ParkinsNov 3, 2006
  4. Andreas EricssonNov 3, 2006
  5. Junio C HamanoNov 3, 2006
  6. Andy ParkinsNov 3, 2006
  7. Andy ParkinsNov 3, 2006
  8. Andreas EricssonNov 3, 2006
  9. Add support to git-branch to show local and remote branchesAndy Parkins, Nov 3, 2006
  10. Colourise git-branch outputAndy Parkins, Nov 3, 2006
  11. Junio C HamanoNov 3, 2006
  12. Alex RiesenNov 3, 2006
  13. Junio C HamanoNov 3, 2006
  14. Andy ParkinsNov 3, 2006
  15. Junio C HamanoNov 3, 2006
  16. 3/4 Default to displaying /all/ non-tag refs, not just localsAndy Parkins, Nov 2, 2006
  17. Junio C HamanoNov 3, 2006
  18. Andy ParkinsNov 3, 2006
  19. Andreas EricssonNov 3, 2006
  20. 4/4 Show the branch type after the branch name for remotesAndy Parkins, Nov 2, 2006
  21. Junio C HamanoNov 3, 2006
  22. Andy ParkinsNov 3, 2006
  23. Junio C HamanoNov 3, 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.