Skip to content

Commit a5b3663

Browse files
peffgitster
authored andcommitted
branch: only perform HEAD check for local branches
When assembling the ref-filter format to show "git branch" output, we put the "%(if)%(HEAD)" conditional at the start of the overall format. But there's no point in checking whether a remote branch matches HEAD, as it never will. The check should go inside the local conditional; we assemble that format inside the "local" strbuf. By itself, this is just a minor optimization. But in a future patch, we'll need this refactoring to fix local-branch coloring. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 613a0e5 commit a5b3663

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

builtin/branch.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -331,8 +331,9 @@ static char *build_format(struct ref_filter *filter, int maxwidth, const char *r
331331
struct strbuf local = STRBUF_INIT;
332332
struct strbuf remote = STRBUF_INIT;
333333

334-
strbuf_addf(&fmt, "%%(if)%%(HEAD)%%(then)* %s%%(else) %%(end)",
334+
strbuf_addf(&local, "%%(if)%%(HEAD)%%(then)* %s%%(else) %%(end)",
335335
branch_get_color(BRANCH_COLOR_CURRENT));
336+
strbuf_addf(&remote, " ");
336337

337338
if (filter->verbose) {
338339
struct strbuf obname = STRBUF_INIT;

0 commit comments

Comments
 (0)