summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2017-03-08 22:13:09 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-03-10 19:47:38 (GMT)
commitac5bbc02b8c3781d517f1414655270b3fa38b028 (patch)
tree0a1ebf08649475f15e15b8c107d0a5daaa2ee321 /builtin
parent44a6b6ce1777f587c318008fe59b901a296f5326 (diff)
downloadgit-ac5bbc02b8c3781d517f1414655270b3fa38b028.zip
git-ac5bbc02b8c3781d517f1414655270b3fa38b028.tar.gz
git-ac5bbc02b8c3781d517f1414655270b3fa38b028.tar.bz2
branch: honor --abbrev/--no-abbrev in --list mode
When the "branch --list" command was converted to use the --format facility from the ref-filter API, we forgot to honor the --abbrev setting in the default output format and instead used a hardcoded "7". Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r--builtin/branch.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/builtin/branch.c b/builtin/branch.c
index cbaa6d0..64d3e7d 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -335,9 +335,18 @@ static char *build_format(struct ref_filter *filter, int maxwidth, const char *r
branch_get_color(BRANCH_COLOR_CURRENT));
if (filter->verbose) {
+ struct strbuf obname = STRBUF_INIT;
+
+ if (filter->abbrev < 0)
+ strbuf_addf(&obname, "%%(objectname:short)");
+ else if (!filter->abbrev)
+ strbuf_addf(&obname, "%%(objectname)");
+ else
+ strbuf_addf(&obname, "%%(objectname:short=%d)", filter->abbrev);
+
strbuf_addf(&local, "%%(align:%d,left)%%(refname:lstrip=2)%%(end)", maxwidth);
strbuf_addf(&local, "%s", branch_get_color(BRANCH_COLOR_RESET));
- strbuf_addf(&local, " %%(objectname:short=7) ");
+ strbuf_addf(&local, " %s ", obname.buf);
if (filter->verbose > 1)
strbuf_addf(&local, "%%(if)%%(upstream)%%(then)[%s%%(upstream:short)%s%%(if)%%(upstream:track)"
@@ -346,10 +355,12 @@ 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%%(if)%%(symref)%%(then) -> %%(symref:short)"
- "%%(else) %%(objectname:short=7) %%(contents:subject)%%(end)",
+ strbuf_addf(&remote, "%s%%(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),
- branch_get_color(BRANCH_COLOR_RESET));
+ 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));