git/list[1] front-page[2] threads[3] people[4] search[5] about
 

git describe is not returning the expected tag

From
FPFlorian Pfaff <florian.pfaff@hitachivantara.com>
Date
Jul 7, 2022, 05:59 UTC
Message-ID
<PH0PR08MB773203CE3206B8DEFB172B2F94839@PH0PR08MB7732.namprd08.prod.outlook.com>
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???????

Actual result =============

What I am getting instead is  v2.0.0-13-g9a45651

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
        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

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
Next: Elijah Newren
Message 1 of 2 in “git describe is not returning the expected tag”
  1. Florian PfaffJul 7, 2022
  2. Elijah NewrenJul 8, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.