git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Artur Skawina <art.08.09@gmail.com>
To: martin f krafft <madduck@madduck.net>
Cc: git discussion list <git@vger.kernel.org>
Subject: Re: Find the next tag on a given branch
Date: Thu, 09 Sep 2010 18:12:28 +0200	[thread overview]
Message-ID: <4C89076C.2040308@gmail.com> (raw)
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

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

      parent reply	other threads:[~2010-09-09 16:12 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-09  5:28 Find the next tag on a given branch martin f krafft
2010-09-09  8:07 ` Thomas Rast
2010-09-09  9:34   ` martin f krafft
2010-09-09 16:12 ` Artur Skawina [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4C89076C.2040308@gmail.com \
    --to=art.08.09@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=madduck@madduck.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).