Re: git describe is not returning the expected tag

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

Thanks for the detailed report and simple reproduction steps.  Very cool.

On Wed, Jul 6, 2022 at 11:43 PM Florian Pfaff
<florian.pfaff@xxxxxxxxxxxxxxxxxx> wrote:
>
> I am experimenting with git describe as we want to use this in our CI system. However, I am not getting the expected results and neither the git describe documentation nor googling nor stackoverflow have helped me understand why.
>
> The repository
> ==============
>
> git log --oneline --graph
>
> * 9a45651 (HEAD -> main) m c7
> *   b7982a9 merged r3
> |\
> | * 8c2adbe (tag: v3.0.0) r3 c1
> |/
> * 273a50e m c6
> *   6014487 merged r2
> |\
> | * aa906b8 (tag: v2.0.0) r2 c2
> | * 716c189 r2 c1
> |/
> * f0e2c71 m c5
> * d42bc37 m c4
> *   9060516 merged r1
> |\
> | * 619d331 (tag: v1.0.0) r1 c2
> | * 75f90de r1 c1
> * | 372f1fe m c3
> |/
> * a27d5e4 m c2
> * a66cb53 m c1
>
>
> Expected result
> ===============
>
> When running git describe on main I'd expect   v3.0.0-x-d???????

In particular, according to the documentation, this should be named
v3.0.0-2-g9a45651

> Actual result
> =============
>
> What I am getting instead is  v2.0.0-13-g9a45651

Even if you were to delete the v3.0.0 tag, this wouldn't be the
correct answer.  The expected result in that case would be
v2.0.0-5-g9a45651.  So, it finds the wrong tag AND gets the count
wrong.

> More information
> ================
>
> git describe --debug
> ---------------------
>
>         # git describe --debug
>         describe HEAD
>         No exact match on refs or tags, searching to describe
>          annotated         13 v2.0.0
>          annotated         13 v1.0.0
>          annotated         14 v3.0.0

and indeed, here we see that the counts are off for all the tags.  Way
off, even in this simple repository.  The counts should be 5, 11, and
2 rather than 13, 13, and 14.

>         traversed 15 commits
>         v2.0.0-13-g9a45651
>
>
> amount of commits between tag and HEAD
> --------------------------------------
>
>     $ git log --oneline v2.0.0..HEAD | wc -l
>     5
>
>     $ git log --oneline v3.0.0..HEAD | wc -l
>     2

Here you show what the counts should be.

> git version
> -----------
>
>     I have tested 2.36.1 and 2.37.0 both on Ubuntu 20.04.4 LTS both installed from # deb-src http://ppa.launchpad.net/git-core/ppa/ubuntu focal main
>
>
> Script to recreate the repository
> ---------------------------------
>
>     https://gist.github.com/twigs/bb0cbe29af55b8141c19d25de47e0eed

Thanks for the script.  If you add a "sleep 1" after every commit or
merge command, `git describe` happens to return the right output.
Basically, `git describe` is broken.  This appears to have been
discussed previously, see here:
https://lore.kernel.org/git/20191008123156.GG11529@xxxxxxxxxx/, but
looks like there was never quite as simple of a testcase as this one.

If anyone's reading this and wants to dig in, and try to fix, feel
free.  I don't have time to dig further.



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux