* BUG Report: git branch ignore --no-abbrev flag @ 2017-03-08 18:14 Guillaume Wenzek 2017-03-08 18:33 ` Junio C Hamano 0 siblings, 1 reply; 8+ messages in thread From: Guillaume Wenzek @ 2017-03-08 18:14 UTC (permalink / raw) To: git Hi, After updating to git 2.12.0 on Monday I noticed that the "git branch" wasn't behaving as usual. As of today `git branch -vv --no-abbrev` outputs short hashes instead of long one (as requested by --no-abbrev)[1] git branch -vv --no-abbrev * (HEAD detached at 2.12.1) 1c69bf2 Add recap-release since previous release messages didn't go out. master eb70249 [origin/master] Fix: support parsing "git://" remote URI to Github URL Expected output: git branch --vv --no-abbrev * (HEAD detached at 2.12.1) 1c69bf24be6de096d801435378be85a936ab0f29 Add recap-release since previous release messages didn't go out. master eb70249e724f933255b4d8c7096092f2764942b4 [origin/master] Fix: support parsing "git://" remote URI to Github URL [1] https://git-scm.com/docs/git-branch#git-branch---no-abbrev I don't have any relevant configuration set. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: BUG Report: git branch ignore --no-abbrev flag 2017-03-08 18:14 BUG Report: git branch ignore --no-abbrev flag Guillaume Wenzek @ 2017-03-08 18:33 ` Junio C Hamano 2017-03-08 21:59 ` Junio C Hamano 0 siblings, 1 reply; 8+ messages in thread From: Junio C Hamano @ 2017-03-08 18:33 UTC (permalink / raw) To: Guillaume Wenzek; +Cc: git, Karthik Nayak Guillaume Wenzek <guillaume.wenzek@gmail.com> writes: > After updating to git 2.12.0 on Monday I noticed that the "git branch" > wasn't behaving as usual. Are you sure you are trying 2.12? v2.12.0 and before should behave the same way and honor --no-abbrev as far as I know. On the other hand, 'master' has 93e8cd8b ("Merge branch 'kn/ref-filter-branch-list'", 2017-02-27), which seems to introduce the regression. Karthik? ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: BUG Report: git branch ignore --no-abbrev flag 2017-03-08 18:33 ` Junio C Hamano @ 2017-03-08 21:59 ` Junio C Hamano 2017-03-08 22:16 ` [PATCH] branch: honor --abbrev/--no-abbrev in --list mode Junio C Hamano 2017-03-09 9:44 ` BUG Report: git branch ignore --no-abbrev flag Guillaume Wenzek 0 siblings, 2 replies; 8+ messages in thread From: Junio C Hamano @ 2017-03-08 21:59 UTC (permalink / raw) To: Karthik Nayak; +Cc: git, Guillaume Wenzek Junio C Hamano <gitster@pobox.com> writes: > Guillaume Wenzek <guillaume.wenzek@gmail.com> writes: > >> After updating to git 2.12.0 on Monday I noticed that the "git branch" >> wasn't behaving as usual. > > Are you sure you are trying 2.12? v2.12.0 and before should behave > the same way and honor --no-abbrev as far as I know. > > On the other hand, 'master' has 93e8cd8b ("Merge branch > 'kn/ref-filter-branch-list'", 2017-02-27), which seems to introduce > the regression. > > Karthik? I haven't fully checked if filter.abbrev is set correctly, but I noticed the output format is formulated without taking the value of filter.abbrev into account at all, so this is an attempt to fix that omission. I also notice that filter.abbrev is _ONLY_ used by builtin/branch.c and the actual ref-filter code does not have to know anything about it. We probably should eliminate filter.abbrev field from the structure and use a regular variable in builtin/branch.c and use it to pass the result of command line parsing from cmd_branch() down to build_format() as an argument. But that is outside the scope of regression fix. builtin/branch.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/builtin/branch.c b/builtin/branch.c index cbaa6d03c0..537c47811a 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)); ^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH] branch: honor --abbrev/--no-abbrev in --list mode 2017-03-08 21:59 ` Junio C Hamano @ 2017-03-08 22:16 ` Junio C Hamano 2017-03-09 13:25 ` Jakub Narębski 2017-03-09 9:44 ` BUG Report: git branch ignore --no-abbrev flag Guillaume Wenzek 1 sibling, 1 reply; 8+ messages in thread From: Junio C Hamano @ 2017-03-08 22:16 UTC (permalink / raw) To: git; +Cc: Karthik Nayak, Guillaume Wenzek 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> --- * This time with test. I am building directly this fix on top of the kn/ref-filter-branch-test topic that was merged to 'master' after 2.12, and haven't checked if there will be conflicts with other topics in-flight (I am expecting none, but I do not know until I start today's integration cycle). builtin/branch.c | 19 +++++++++++++++---- t/t3200-branch.sh | 25 +++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/builtin/branch.c b/builtin/branch.c index cbaa6d03c0..537c47811a 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)); diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh index 8a833f354e..39bd5ac8fa 100755 --- a/t/t3200-branch.sh +++ b/t/t3200-branch.sh @@ -207,6 +207,31 @@ test_expect_success 'git branch --list -d t should fail' ' test_path_is_missing .git/refs/heads/t ' +test_expect_success 'git branch --list -v with --abbrev' ' + test_when_finished "git branch -D t" && + git branch t && + git branch -v --list t >actual.default && + git branch -v --list --abbrev t >actual.abbrev && + test_cmp actual.default actual.abbrev && + + git branch -v --list --no-abbrev t >actual.noabbrev && + git branch -v --list --abbrev=0 t >actual.0abbrev && + test_cmp actual.noabbrev actual.0abbrev && + + git branch -v --list --abbrev=36 t >actual.36abbrev && + # how many hexdigits are used? + read name objdefault rest <actual.abbrev && + read name obj36 rest <actual.36abbrev && + objfull=$(git rev-parse --verify t) && + + # are we really getting abbreviations? + test "$obj36" != "$objdefault" && + expr "$obj36" : "$objdefault" >/dev/null && + test "$objfull" != "$obj36" && + expr "$objfull" : "$obj36" >/dev/null + +' + test_expect_success 'git branch --column' ' COLUMNS=81 git branch --column=column >actual && cat >expected <<\EOF && -- 2.12.0.246.ga2ecc84866-goog ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] branch: honor --abbrev/--no-abbrev in --list mode 2017-03-08 22:16 ` [PATCH] branch: honor --abbrev/--no-abbrev in --list mode Junio C Hamano @ 2017-03-09 13:25 ` Jakub Narębski 2017-03-10 16:45 ` Junio C Hamano 0 siblings, 1 reply; 8+ messages in thread From: Jakub Narębski @ 2017-03-09 13:25 UTC (permalink / raw) To: Junio C Hamano, git; +Cc: Karthik Nayak, Guillaume Wenzek W dniu 08.03.2017 o 23:16, Junio C Hamano pisze: > diff --git a/builtin/branch.c b/builtin/branch.c > index cbaa6d03c0..537c47811a 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); ^ ^ I wonder why the last one has leading space --/ and trailing one -----/ The rest (for default abbrev and for no abbrev do not). -- Jakub Narębski ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] branch: honor --abbrev/--no-abbrev in --list mode 2017-03-09 13:25 ` Jakub Narębski @ 2017-03-10 16:45 ` Junio C Hamano 0 siblings, 0 replies; 8+ messages in thread From: Junio C Hamano @ 2017-03-10 16:45 UTC (permalink / raw) To: Jakub Narębski; +Cc: git, Karthik Nayak, Guillaume Wenzek Jakub Narębski <jnareb@gmail.com> writes: > W dniu 08.03.2017 o 23:16, Junio C Hamano pisze: > >> diff --git a/builtin/branch.c b/builtin/branch.c >> index cbaa6d03c0..537c47811a 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); > ^ ^ > I wonder why the last one has leading space --/ and trailing one -----/ > The rest (for default abbrev and for no abbrev do not). Thanks for spotting; that's just an editor cruft that shouldn't have been there. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: BUG Report: git branch ignore --no-abbrev flag 2017-03-08 21:59 ` Junio C Hamano 2017-03-08 22:16 ` [PATCH] branch: honor --abbrev/--no-abbrev in --list mode Junio C Hamano @ 2017-03-09 9:44 ` Guillaume Wenzek 2017-03-09 10:38 ` Jeff King 1 sibling, 1 reply; 8+ messages in thread From: Guillaume Wenzek @ 2017-03-09 9:44 UTC (permalink / raw) To: Junio C Hamano; +Cc: Karthik Nayak, git Thanks for looking into it, The full version number is "2.12.0.246.ga2ecc84866" but I don't think that's an official number, I'm using my company (Google) apt repository. The git package date is 2017/03/03 while previous version was from 2017/02/16, the commit you identified is actually between the two, so that may be it. On 8 March 2017 at 22:59, Junio C Hamano <gitster@pobox.com> wrote: > Junio C Hamano <gitster@pobox.com> writes: > >> Guillaume Wenzek <guillaume.wenzek@gmail.com> writes: >> >>> After updating to git 2.12.0 on Monday I noticed that the "git branch" >>> wasn't behaving as usual. >> >> Are you sure you are trying 2.12? v2.12.0 and before should behave >> the same way and honor --no-abbrev as far as I know. >> >> On the other hand, 'master' has 93e8cd8b ("Merge branch >> 'kn/ref-filter-branch-list'", 2017-02-27), which seems to introduce >> the regression. >> >> Karthik? > > I haven't fully checked if filter.abbrev is set correctly, but I > noticed the output format is formulated without taking the value of > filter.abbrev into account at all, so this is an attempt to fix > that omission. > > I also notice that filter.abbrev is _ONLY_ used by builtin/branch.c and > the actual ref-filter code does not have to know anything about it. > > We probably should eliminate filter.abbrev field from the structure > and use a regular variable in builtin/branch.c and use it to pass > the result of command line parsing from cmd_branch() down to > build_format() as an argument. > > But that is outside the scope of regression fix. > > > builtin/branch.c | 19 +++++++++++++++---- > 1 file changed, 15 insertions(+), 4 deletions(-) > > diff --git a/builtin/branch.c b/builtin/branch.c > index cbaa6d03c0..537c47811a 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)); ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: BUG Report: git branch ignore --no-abbrev flag 2017-03-09 9:44 ` BUG Report: git branch ignore --no-abbrev flag Guillaume Wenzek @ 2017-03-09 10:38 ` Jeff King 0 siblings, 0 replies; 8+ messages in thread From: Jeff King @ 2017-03-09 10:38 UTC (permalink / raw) To: Guillaume Wenzek; +Cc: Junio C Hamano, Karthik Nayak, git On Thu, Mar 09, 2017 at 10:44:42AM +0100, Guillaume Wenzek wrote: > The full version number is "2.12.0.246.ga2ecc84866" but I don't think > that's an official number, I'm using my company (Google) apt > repository. That's built from the commit at a2ecc84866, which is in the "next" branch (and is 246 commits ahead of v2.12.0). So that explains why you are seeing the behavior. The code _isn't_ in v2.12.0, but you're running a much more recent version. -Peff ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2017-03-10 16:45 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2017-03-08 18:14 BUG Report: git branch ignore --no-abbrev flag Guillaume Wenzek 2017-03-08 18:33 ` Junio C Hamano 2017-03-08 21:59 ` Junio C Hamano 2017-03-08 22:16 ` [PATCH] branch: honor --abbrev/--no-abbrev in --list mode Junio C Hamano 2017-03-09 13:25 ` Jakub Narębski 2017-03-10 16:45 ` Junio C Hamano 2017-03-09 9:44 ` BUG Report: git branch ignore --no-abbrev flag Guillaume Wenzek 2017-03-09 10:38 ` Jeff King
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).