All of lore.kernel.org
 help / color / mirror / Atom feed
* Find the next tag on a given branch
@ 2010-09-09  5:28 martin f krafft
  2010-09-09  8:07 ` Thomas Rast
  2010-09-09 16:12 ` Artur Skawina
  0 siblings, 2 replies; 4+ messages in thread
From: martin f krafft @ 2010-09-09  5:28 UTC (permalink / raw)
  To: git discussion list

[-- Attachment #1: Type: text/plain, Size: 1804 bytes --]

Dear list,

I want to find the next tag (the tag following a commit), but
require that it lie on a given branch. Alternatively, a filter
pattern might work too.

My challenge is to answer the question:

  "Which is the first Debian release including a given commit"

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

would basically search into the future (breadth-first?) until it
landed on the specified branch, and then continue the normal search
routine (and find the commit on another branch actually, the
important point is that it only started to search for tags once it
reached the specified branch).

The alternative is

  git describe --contains mycommit --pattern='debian/*'

which would keep searching for tags until it found a tag/ref-name
that matched the specified glob.

Is this already possible somehow? Am I simply looking at the wrong
tools?

Thanks,

-- 
martin | http://madduck.net/ | http://two.sentenc.es/
 
i don't want to get myself into a hot babe situation.
                         -- jonathan mcdowll, #debian-uk, 6 jul 2009
 
spamtraps: madduck.bogus@madduck.net

[-- Attachment #2: Digital signature (see http://martin-krafft.net/gpg/) --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Find the next tag on a given branch
  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
  1 sibling, 1 reply; 4+ messages in thread
From: Thomas Rast @ 2010-09-09  8:07 UTC (permalink / raw)
  To: martin f krafft; +Cc: git discussion list

martin f krafft wrote:
> The alternative is
> 
>   git describe --contains mycommit --pattern='debian/*'

Maybe

  git tag --contains mycommit | grep ^debian/

?

-- 
Thomas Rast
trast@{inf,student}.ethz.ch

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Find the next tag on a given branch
  2010-09-09  8:07 ` Thomas Rast
@ 2010-09-09  9:34   ` martin f krafft
  0 siblings, 0 replies; 4+ messages in thread
From: martin f krafft @ 2010-09-09  9:34 UTC (permalink / raw)
  To: Thomas Rast, git discussion list

[-- Attachment #1: Type: text/plain, Size: 335 bytes --]

also sprach Thomas Rast <trast@student.ethz.ch> [2010.09.09.1007 +0200]:
>   git tag --contains mycommit | grep ^debian/

Awesome. Thank you so much!

-- 
martin | http://madduck.net/ | http://two.sentenc.es/
 
wind catches lily,
scattering petals to the ground.
segmentation fault.
 
spamtraps: madduck.bogus@madduck.net

[-- Attachment #2: Digital signature (see http://martin-krafft.net/gpg/) --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Find the next tag on a given branch
  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 16:12 ` Artur Skawina
  1 sibling, 0 replies; 4+ messages in thread
From: Artur Skawina @ 2010-09-09 16:12 UTC (permalink / raw)
  To: martin f krafft; +Cc: git discussion list

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)

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-09-09 16:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.