Re: [PATCH v2 7/8] for-each-ref: add ahead-behind format atom
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Mar 10, 2023, 19:09 UTC
- Message-ID
- <xmqqlek45sqb.fsf@gitster.g>
- In-Reply-To
- <82dd6f44a33279551bb638357df4bc82253283e5.1678468864.git.gitgitgadget@gmail.com>
"Derrick Stolee via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 10 quoted lines
> Test this tree > --------------------------------------------------------------- > 1500.2: ahead-behind counts: git for-each-ref 0.27(0.24+0.02) > 1500.3: ahead-behind counts: git branch 0.27(0.24+0.03) > 1500.4: ahead-behind counts: git tag 0.28(0.27+0.01) > 1500.5: ahead-behind counts: git rev-list 4.57(4.03+0.54) > > The 'git rev-list' test exists in this change as a demonstration, but it > will be removed in the next change to avoid wasting time on this > comparison.
Nice.
> +ahead-behind:<ref>:: > + Two integers, separated by a space, demonstrating the number of > + commits ahead and behind, respectively, when comparing the output > + ref to the `<ref>` specified in the format.
Don't we take any commit-ish, not necessarily a ref? In the context of for-each-ref documentation, I am afraid that the readers assume that the word refers to a ref and %(ahead-behind:ea6e93913b) and the like are forbidden, which is not what you wanted when you used lookup_commit_reference_by_name() in the implementation.
> + # Use " !" at the end to demonstrate whitepsace
psace.
> + # around empty ahead-behind token for tag-blob.
;-)
Show 19 quoted lines
> + cat >expect <<-EOF && > + refs/tags/tag-blob ! > + refs/tags/tag-left 1 1 ! > + refs/tags/tag-lines 0 1 ! > + refs/tags/tag-one-line 0 1 ! > + refs/tags/tag-right 0 0 ! > + refs/tags/tag-zero-lines 0 1 ! > + EOF > + git tag -l --format="%(refname) %(ahead-behind:HEAD) !" >actual 2>err && > + grep "refs/tags/tag" actual >actual.focus && > + test_cmp expect actual.focus && > + > + # Error reported for tags that point to non-commits. > + grep "error: object [0-9a-f]* is a blob, not a commit" err > +' > + > # trying to verify annotated non-signed tags: > > test_expect_success GPG \