{"thread":{"id":"25051","subject":"Find the next tag on a given branch","startedAt":"2010-09-09T05:28:41Z","lastAt":"2010-09-09T16:12:28Z","messageCount":4,"participants":["martin f krafft","Thomas Rast","Artur Skawina"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"150354","messageId":"20100909052841.GA16722@fishbowl.rw.madduck.net","threadId":"25051","inReplyTo":null,"subject":"Find the next tag on a given branch","fromName":"martin f krafft","fromEmail":"madduck@madduck.net","sentAt":"2010-09-09T05:28:41Z","receivedAt":"2010-09-09T05:28:41Z","isPatch":false,"sender":{"key":"madduck@madduck.net","avatar":null},"body":"Dear list,\n\nI want to find the next tag (the tag following a commit), but\nrequire that it lie on a given branch. Alternatively, a filter\npattern might work too.\n\nMy challenge is to answer the question:\n\n  \"Which is the first Debian release including a given commit\"\n\nThe way Debian packages are (mostly) maintained in Git is that\nthere are at least an upstream and a Debian branch (usually\n\"master\"). master branched off upstream, and upstream is merged into\nmaster at regular intervals. Whenever a Debian release is made, the\ncorresponding branch is tagged.\n\nIf I run\n\n  git describe --contains mycommitish\n\nit prints the next tag, which is usually upstream's tag, which is\nnot quite what I want (it's usually enough for me to figure it out,\nbut this is Git and so I should be able to do even better! ;\\) )\n\nI would like to have it continue the search until it reaches the\nmaster branch. For instance, a command like\n\n  git describe --contains mycommit --on-branch master\n\nwould basically search into the future (breadth-first?) until it\nlanded on the specified branch, and then continue the normal search\nroutine (and find the commit on another branch actually, the\nimportant point is that it only started to search for tags once it\nreached the specified branch).\n\nThe alternative is\n\n  git describe --contains mycommit --pattern='debian/*'\n\nwhich would keep searching for tags until it found a tag/ref-name\nthat matched the specified glob.\n\nIs this already possible somehow? Am I simply looking at the wrong\ntools?\n\nThanks,\n\n-- \nmartin | http://madduck.net/ | http://two.sentenc.es/\n \ni don't want to get myself into a hot babe situation.\n                         -- jonathan mcdowll, #debian-uk, 6 jul 2009\n \nspamtraps: madduck.bogus@madduck.net\n"},{"id":"150357","messageId":"201009091007.35275.trast@student.ethz.ch","threadId":"25051","inReplyTo":"20100909052841.GA16722@fishbowl.rw.madduck.net","subject":"Re: Find the next tag on a given branch","fromName":"Thomas Rast","fromEmail":"trast@student.ethz.ch","sentAt":"2010-09-09T08:07:35Z","receivedAt":"2010-09-09T08:07:35Z","isPatch":false,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"martin f krafft wrote:\n> The alternative is\n> \n>   git describe --contains mycommit --pattern='debian/*'\n\nMaybe\n\n  git tag --contains mycommit | grep ^debian/\n\n?\n\n-- \nThomas Rast\ntrast@{inf,student}.ethz.ch\n"},{"id":"150363","messageId":"20100909093438.GE8776@fishbowl.rw.madduck.net","threadId":"25051","inReplyTo":"201009091007.35275.trast@student.ethz.ch","subject":"Re: Find the next tag on a given branch","fromName":"martin f krafft","fromEmail":"madduck@madduck.net","sentAt":"2010-09-09T09:34:38Z","receivedAt":"2010-09-09T09:34:38Z","isPatch":false,"sender":{"key":"madduck@madduck.net","avatar":null},"body":"also sprach Thomas Rast <trast@student.ethz.ch> [2010.09.09.1007 +0200]:\n>   git tag --contains mycommit | grep ^debian/\n\nAwesome. Thank you so much!\n\n-- \nmartin | http://madduck.net/ | http://two.sentenc.es/\n \nwind catches lily,\nscattering petals to the ground.\nsegmentation fault.\n \nspamtraps: madduck.bogus@madduck.net\n"},{"id":"150372","messageId":"4C89076C.2040308@gmail.com","threadId":"25051","inReplyTo":"20100909052841.GA16722@fishbowl.rw.madduck.net","subject":"Re: Find the next tag on a given branch","fromName":"Artur Skawina","fromEmail":"art.08.09@gmail.com","sentAt":"2010-09-09T16:12:28Z","receivedAt":"2010-09-09T16:12:28Z","isPatch":false,"sender":{"key":"art.08.09@gmail.com","avatar":null},"body":"On 09/09/10 07:28, martin f krafft wrote:\n> I want to find the next tag (the tag following a commit), but\n> require that it lie on a given branch. Alternatively, a filter\n\n> The way Debian packages are (mostly) maintained in Git is that\n> there are at least an upstream and a Debian branch (usually\n> \"master\"). master branched off upstream, and upstream is merged into\n> master at regular intervals. Whenever a Debian release is made, the\n> corresponding branch is tagged.\n> \n> If I run\n> \n>   git describe --contains mycommitish\n> \n> it prints the next tag, which is usually upstream's tag, which is\n> not quite what I want (it's usually enough for me to figure it out,\n> but this is Git and so I should be able to do even better! ;\\) )\n> \n> I would like to have it continue the search until it reaches the\n> master branch. For instance, a command like\n> \n>   git describe --contains mycommit --on-branch master\n\nIt's not that simple, as 'mycommit', once merged, /is/ technically part\nof master.\n\nIf 'upstream' contains just imports, ie has no merges whatsoever, like\neg git://git.debian.org/collab-maint/batmand.git, you could use something\nlike this: \n\n$ git rev-list --ancestry-path --merges mycommit..master | xargs -n1 git describe --contains\n\n(this doesn't catch the very first initial import (and release tag),\n but that case isn't very interesting anyway)\n\n\nWith a more complicated history, with many merges, you'd have to\ndo something more like\n\n1) git rev-list --ancestry-path --merges mycommit..master\n2) filter out all the merge ids from this list that are reachable from\n   'upstream'\n3) git describe --contains \n\nEasily scriptable, but i don't see a way to express the 2nd step\nin pure git-speak right now. [1] Is there a way?\n\nOr you could just extend 'git describe --contains' to take another\noptional ref, check if the object pointed to by the tag that it finds\nis reachable from that ref, and skip this tag if yes.\nThen you could do `git describe --contains mycommit --skip upstream`. ;)\n\nartur\n\n[1] iff i got it right. Consider history such as:\n               \n         ...-> c\n                \\    \nupstream -> C -> m -> c ----> ... ---> c ---> upstream\n                       \\                \\\nmaster   -------------> M -> m -> ... -> m -> master\n                            /\n         ... ------------> c\n\nAsking for a released 'C' must result in 'M'. \n(Merging 'master' into 'upstream' must not happen, obviously)\n"}]}