Skip to content

Commit 7ca260a

Browse files
peffgitster
authored andcommitted
branch: set remote color in ref-filter branch immediately
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 34d820e commit 7ca260a

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

builtin/branch.c

+6-5
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,8 @@ static char *build_format(struct ref_filter *filter, int maxwidth, const char *r
334334
strbuf_addf(&local, "%%(if)%%(HEAD)%%(then)* %s%%(else) %s%%(end)",
335335
branch_get_color(BRANCH_COLOR_CURRENT),
336336
branch_get_color(BRANCH_COLOR_LOCAL));
337-
strbuf_addf(&remote, " ");
337+
strbuf_addf(&remote, " %s",
338+
branch_get_color(BRANCH_COLOR_REMOTE));
338339

339340
if (filter->verbose) {
340341
struct strbuf obname = STRBUF_INIT;
@@ -357,17 +358,17 @@ static char *build_format(struct ref_filter *filter, int maxwidth, const char *r
357358
else
358359
strbuf_addf(&local, "%%(if)%%(upstream:track)%%(then)%%(upstream:track) %%(end)%%(contents:subject)");
359360

360-
strbuf_addf(&remote, "%s%%(align:%d,left)%s%%(refname:lstrip=2)%%(end)%s"
361+
strbuf_addf(&remote, "%%(align:%d,left)%s%%(refname:lstrip=2)%%(end)%s"
361362
"%%(if)%%(symref)%%(then) -> %%(symref:short)"
362363
"%%(else) %s %%(contents:subject)%%(end)",
363-
branch_get_color(BRANCH_COLOR_REMOTE), maxwidth, quote_literal_for_format(remote_prefix),
364+
maxwidth, quote_literal_for_format(remote_prefix),
364365
branch_get_color(BRANCH_COLOR_RESET), obname.buf);
365366
strbuf_release(&obname);
366367
} else {
367368
strbuf_addf(&local, "%%(refname:lstrip=2)%s%%(if)%%(symref)%%(then) -> %%(symref:short)%%(end)",
368369
branch_get_color(BRANCH_COLOR_RESET));
369-
strbuf_addf(&remote, "%s%s%%(refname:lstrip=2)%s%%(if)%%(symref)%%(then) -> %%(symref:short)%%(end)",
370-
branch_get_color(BRANCH_COLOR_REMOTE), quote_literal_for_format(remote_prefix),
370+
strbuf_addf(&remote, "%s%%(refname:lstrip=2)%s%%(if)%%(symref)%%(then) -> %%(symref:short)%%(end)",
371+
quote_literal_for_format(remote_prefix),
371372
branch_get_color(BRANCH_COLOR_RESET));
372373
}
373374

0 commit comments

Comments
 (0)