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

Re: Find the next tag on a given branch

From
ASArtur Skawina <art.08.09@gmail.com>
Date
Sep 9, 2010, 16:12 UTC
Message-ID
<4C89076C.2040308@gmail.com>
In-Reply-To
<20100909052841.GA16722@fishbowl.rw.madduck.net>
On 09/09/10 07:28, martin f krafft wrote:
> I want to find the next tag (the tag following a commit), but
> require that it lie on a given branch. Alternatively, a filter
Show 18 quoted lines
> The way Debian packages are (mostly) maintained in Git is that
> there are at least an upstream and a Debian branch (usually
> "master"). master branched off upstream, and upstream is merged into
> master at regular intervals. Whenever a Debian release is made, the
> corresponding branch is tagged.
> 
> If I run
> 
>   git describe --contains mycommitish
> 
> it prints the next tag, which is usually upstream's tag, which is
> not quite what I want (it's usually enough for me to figure it out,
> but this is Git and so I should be able to do even better! ;\) )
> 
> I would like to have it continue the search until it reaches the
> master branch. For instance, a command like
> 
>   git describe --contains mycommit --on-branch master

It's not that simple, as 'mycommit', once merged, /is/ technically part of master.

If 'upstream' contains just imports, ie has no merges whatsoever, like eg git://git.debian.org/collab-maint/batmand.git, you could use something like this:

$ git rev-list --ancestry-path --merges mycommit..master | xargs -n1 git describe --contains
(this doesn't catch the very first initial import (and release tag),
 but that case isn't very interesting anyway)

With a more complicated history, with many merges, you'd have to do something more like

1) git rev-list --ancestry-path --merges mycommit..master
2) filter out all the merge ids from this list that are reachable from
   'upstream'
3) git describe --contains 

Easily scriptable, but i don't see a way to express the 2nd step in pure git-speak right now. [1] Is there a way?

Or you could just extend 'git describe --contains' to take another optional ref, check if the object pointed to by the tag that it finds is reachable from that ref, and skip this tag if yes. Then you could do `git describe --contains mycommit --skip upstream`. ;)

artur
[1] iff i got it right. Consider history such as:
               
         ...-> c
                \    
upstream -> C -> m -> c ----> ... ---> c ---> upstream
                       \                \
master   -------------> M -> m -> ... -> m -> master
                            /
         ... ------------> c

Asking for a released 'C' must result in 'M'. (Merging 'master' into 'upstream' must not happen, obviously)

Previous: martin f krafft
Message 4 of 4 in “Find the next tag on a given branch”
  1. martin f krafftSep 9, 2010
  2. Thomas RastSep 9, 2010
  3. martin f krafftSep 9, 2010
  4. Artur SkawinaSep 9, 2010

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.