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

Getting first tag per branch for a commit

From
Orgad Shaneh <orgads@gmail.com>
Date
Jun 25, 2017, 14:06 UTC
Message-ID
<CAGHpTBLP9MiYr2ZoUOaGjGMC+aO_EKYO6SwNLfAu6QFSRnPatQ@mail.gmail.com>
Hi,
git describe --tags <commit> gives me the first tag that includes this commit.
git tag --contains <commit> shows all the tags that contain the commit.
git branch -a --contains <commit> shows the branches that include this commit.

What I'd like to have is a way to tell the first tag per branch (or per merge) that the commit appeared on.

I'll use an example from the Git repository. Let's pick commit 32b8c581ec which was first introduced in v2.9.3.

git describe --tags will only show v2.9.3

git tag --contains shows the following list: v2.10.0 v2.10.0-rc0 v2.10.0-rc1 v2.10.0-rc2 v2.10.1 v2.10.2 v2.10.3 v2.11.0 v2.11.0-rc0 v2.11.0-rc1 v2.11.0-rc2 v2.11.0-rc3 v2.11.1 v2.11.2 v2.12.0 v2.12.0-rc0 v2.12.0-rc1 v2.12.0-rc2 v2.12.1 v2.12.2 v2.12.3 v2.13.0 v2.13.0-rc0 v2.13.0-rc1 v2.13.0-rc2 v2.13.1 v2.13.2 v2.9.3 v2.9.4

What really interests me as a user is the "first in the series" tag for each version. What I'd expect is: v2.10.0-rc0 v2.9.3

and I can conclude that if it appeared in 2.9.3 then 2.9.4 also has it, and if it's in 2.10.0-rc0 then all the following versions (2.10.x and up) include it.

I think that this can be done by filtering out tags that are connected to already listed tags by first-parent link.

Is there a way to achieve this kind of "simplified contained in" list?
Related: https://bugs.chromium.org/p/gerrit/issues/detail?id=4331
- Orgad
Next: Junio C Hamano
Message 1 of 4 in “Getting first tag per branch for a commit”
  1. Orgad ShanehJun 25, 2017
  2. Junio C HamanoJun 25, 2017
  3. Junio C HamanoJun 25, 2017
  4. Orgad ShanehJun 26, 2017

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.