threads / discuss / 56680

git log with %(describe) placeholder does not find most recent tag

Subject: git log with %(describe) placeholder does not find most recent tag

## tl;dr

5 messages between Oct 11, 2021 and Oct 11, 2021.

replies: 4people: 4as markdown or json

Benjamin Kircher· Oct 11, 2021, 08:08 UTC · lore
Hello there,

What did you do before the bug happened? (Steps to reproduce your issue)

    git log --format='%(describe)' -n1
produces a different result than
    git describe --tags
What did you expect to happen? (Expected behavior)

I expected both to produce (roughly) the same result. At least, reference the same tag.

What happened instead? (Actual behavior)
    git log --format='%(describe)' -n1
    v0.11.0
and
    git log --format='%(describe)' -n1
    v0.3.0-beta-253-g4ccd023
What's different between what you expected and what actually happened?

git log with %(describe) placeholder does not seem to find the most recent tag as git-describe would do. Is this intended?

[System Info] git version: git version 2.33.0 cpu: x86_64 no commit associated with this build sizeof-long: 8 sizeof-size_t: 8 shell-path: /bin/sh uname: Linux 5.14.10-200.fc34.x86_64 #1 SMP Thu Oct 7 20:49:53 UTC 2021 x86_64 compiler info: gnuc: 11.2 libc info: glibc: 2.33 $SHELL (typically, interactive shell): /bin/zsh

[Enabled Hooks]
Bagas Sanjaya· Oct 11, 2021, 08:23 UTC · re: Benjamin Kircher · lore

Re: git log with %(describe) placeholder does not find most recent tag

On 11/10/21 15.08, Benjamin Kircher wrote:
Show 28 quoted lines
> What did you do before the bug happened? (Steps to reproduce your
> issue)
> 
>      git log --format='%(describe)' -n1
> 
> produces a different result than
> 
>      git describe --tags
> 
> What did you expect to happen? (Expected behavior)
> 
> I expected both to produce (roughly) the same result. At least,
> reference the same tag.
> 
> What happened instead? (Actual behavior)
> 
>      git log --format='%(describe)' -n1
>      v0.11.0
> 
> and
> 
>      git log --format='%(describe)' -n1
>      v0.3.0-beta-253-g4ccd023
> 
> What's different between what you expected and what actually happened?
> 
> git log with %(describe) placeholder does not seem to find the most
> recent tag as git-describe would do. Is this intended?

I tried to reproduce your issue. I have linux.git shallow repo (master branch pulls from torvalds' mainline tree and stable branches pull from stable tree). HEAD currently points to v5.15-rc5 tag.

The result (note that I use custom-compiled Git):

``` $ /opt/git/bin/git version git version 2.33.0

$ /opt/git/bin/git log -n 1 --format='%(describe)' v5.15-rc5

$ /opt/git/bin/git describe --tags v5.15-rc5 ```

Both results (git log and git describe) are same.
-- 
An old man doll... just what I always wanted! - Clara
Benjamin Kircher· Oct 11, 2021, 08:29 UTC · re: Bagas Sanjaya · lore

Re: git log with %(describe) placeholder does not find most recent tag

On Mon, 2021-10-11 at 15:23 +0700, Bagas Sanjaya wrote:
> Both results (git log and git describe) are same.

Yes. Good one. Absolutely correct. I wasn't able to reproduce that with Linux repository, too.

Problem is observed only in some repositories while others seem fine.
I was able to reproduce it with a freshly cloned version of:
  https://github.com/gridscale/gscloud.git
BK
Carlo Arenas· Oct 11, 2021, 12:27 UTC · re: Benjamin Kircher · lore

Re: git log with %(describe) placeholder does not find most recent tag

On Mon, Oct 11, 2021 at 1:10 AM Benjamin Kircher <bkircher@0xadd.de> wrote:
> produces a different result than
>
>     git describe --tags

if the repository you are looking at has non annotated tags (the ones that have no signature or message and that are created by default with `git tag`), then that is expected and explained in the documentation for the '--tags' option you are using.

Carlo
Jeff King· Oct 11, 2021, 16:23 UTC · re: Carlo Arenas · lore

Re: git log with %(describe) placeholder does not find most recent tag

On Mon, Oct 11, 2021 at 05:27:39AM -0700, Carlo Arenas wrote:
Show 9 quoted lines
> On Mon, Oct 11, 2021 at 1:10 AM Benjamin Kircher <bkircher@0xadd.de> wrote:
> > produces a different result than
> >
> >     git describe --tags
> 
> if the repository you are looking at has non annotated tags (the ones
> that have no signature or message and that are created by default with
> `git tag`), then that is expected and explained in the documentation
> for the '--tags' option you are using.

Yes, that's the case in the example repo he showed. I don't think there is currently a way to convince %(describe) to use "--tags" in the underlying describe command, but it seems like a reasonable extension if somebody is interested in writing it. We already take some options to %(describe), so the syntax is prepared to add more.

-Peff

← back to recent threads