diff options
author | Jeff King <peff@peff.net> | 2017-07-09 12:58:10 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-07-09 19:24:42 +0300 |
commit | a5b3663898d6e45a5d109ce89c516adc2fd4ded2 (patch) | |
tree | 52a3a3dfcce6f9d07afc4a92544f5fb6f65cd287 | |
parent | 613a0e52ea11c4496e3e154de192486a18eac2e4 (diff) |
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 <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r-- | builtin/branch.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/builtin/branch.c b/builtin/branch.c index 64d3e7d7c9..5f8b5ada8e 100644 --- a/builtin/branch.c +++ b/builtin/branch.c @@ -331,8 +331,9 @@ static char *build_format(struct ref_filter *filter, int maxwidth, const char *r struct strbuf local = STRBUF_INIT; struct strbuf remote = STRBUF_INIT; - strbuf_addf(&fmt, "%%(if)%%(HEAD)%%(then)* %s%%(else) %%(end)", + strbuf_addf(&local, "%%(if)%%(HEAD)%%(then)* %s%%(else) %%(end)", branch_get_color(BRANCH_COLOR_CURRENT)); + strbuf_addf(&remote, " "); if (filter->verbose) { struct strbuf obname = STRBUF_INIT; |