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

[PATCH 3/3] branch: set remote color in ref-filter branch immediately

From
Jeff King <peff@peff.net>
Date
Jul 9, 2017, 10:00 UTC
Message-ID
<20170709100045.neb5ovc776wnfphs@sigill.intra.peff.net>
In-Reply-To
<20170709095708.moymrozmqdv2oixx@sigill.intra.peff.net>

We set the current and local branch colors at the top of the build_format() function. Let's do the same for the remote color. This saves a little bit of repetition, but more importantly it puts all of the color-setting in the same place. That makes it easier to see that we are coloring all possibilities.

Signed-off-by: Jeff King <peff@peff.net>
---
 builtin/branch.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/builtin/branch.c b/builtin/branch.c
index ee4e93c3a..8a0595e11 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -338,7 +338,8 @@ static char *build_format(struct ref_filter *filter, int maxwidth, const char *r
 	strbuf_addf(&local, "%%(if)%%(HEAD)%%(then)* %s%%(else)  %s%%(end)",
 		    branch_get_color(BRANCH_COLOR_CURRENT),
 		    branch_get_color(BRANCH_COLOR_LOCAL));
-	strbuf_addf(&remote, "  ");
+	strbuf_addf(&remote, "  %s",
+		    branch_get_color(BRANCH_COLOR_REMOTE));
 
 	if (filter->verbose) {
 		struct strbuf obname = STRBUF_INIT;
@@ -361,17 +362,17 @@ static char *build_format(struct ref_filter *filter, int maxwidth, const char *r
 		else
 			strbuf_addf(&local, "%%(if)%%(upstream:track)%%(then)%%(upstream:track) %%(end)%%(contents:subject)");
 
-		strbuf_addf(&remote, "%s%%(align:%d,left)%s%%(refname:lstrip=2)%%(end)%s"
+		strbuf_addf(&remote, "%%(align:%d,left)%s%%(refname:lstrip=2)%%(end)%s"
 			    "%%(if)%%(symref)%%(then) -> %%(symref:short)"
 			    "%%(else) %s %%(contents:subject)%%(end)",
-			    branch_get_color(BRANCH_COLOR_REMOTE), maxwidth, quote_literal_for_format(remote_prefix),
+			    maxwidth, quote_literal_for_format(remote_prefix),
 			    branch_get_color(BRANCH_COLOR_RESET), obname.buf);
 		strbuf_release(&obname);
 	} else {
 		strbuf_addf(&local, "%%(refname:lstrip=2)%s%%(if)%%(symref)%%(then) -> %%(symref:short)%%(end)",
 			    branch_get_color(BRANCH_COLOR_RESET));
-		strbuf_addf(&remote, "%s%s%%(refname:lstrip=2)%s%%(if)%%(symref)%%(then) -> %%(symref:short)%%(end)",
-			    branch_get_color(BRANCH_COLOR_REMOTE), quote_literal_for_format(remote_prefix),
+		strbuf_addf(&remote, "%s%%(refname:lstrip=2)%s%%(if)%%(symref)%%(then) -> %%(symref:short)%%(end)",
+			    quote_literal_for_format(remote_prefix),
 			    branch_get_color(BRANCH_COLOR_RESET));
 	}
 
-- 
2.13.2.1066.gabaed60bd
Previous: Jeff King
Message 6 of 6 in “git-2.13.2: color.branch.local problem”
  1. Leo RazoumovJul 8, 2017
  2. Jeff KingJul 9, 2017
  3. Jeff KingJul 9, 2017
  4. 1/3 branch: only perform HEAD check for local branchesJeff King, Jul 9, 2017
  5. 2/3 branch: use BRANCH_COLOR_LOCAL in ref-filter formatJeff King, Jul 9, 2017
  6. 3/3 branch: set remote color in ref-filter branch immediatelyJeff King, Jul 9, 2017

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.