{"thread":{"id":"22015","subject":"git tag --contains <commit> -n=1 ?","startedAt":"2009-12-23T16:19:51Z","lastAt":"2009-12-24T05:52:58Z","messageCount":4,"participants":["NODA, Kai","Andreas Schwab","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"130281","messageId":"4B324327.5010809@gmail.com","threadId":"22015","inReplyTo":null,"subject":"git tag --contains <commit> -n=1 ?","fromName":"NODA, Kai","fromEmail":"nodakai@gmail.com","sentAt":"2009-12-23T16:19:51Z","receivedAt":"2009-12-23T16:19:51Z","isPatch":false,"sender":{"key":"nodakai@gmail.com","avatar":null},"body":"Hi,\nI'm thinking how to find the oldest tag containing a specified commit.\nEg.\n$ cd /usr/src/linux-linus/Documentation\n$ for i in *.txt; do\nfor> echo $i\nfor> hash=`git log -1 --format=format:%H -- $i`\nfor> git tag --contains $hash -l 'v2.6.[0-9][0-9]'|head -1\nfor> done\nDMA-API.txt\nv2.6.31\nDMA-ISA-LPC.txt\nv2.6.20\nDMA-attributes.txt\nv2.6.27\n...\n\nHere I wonder whether \"head -1\" is generally correct or not when I want\nthe oldest tag.\nMoreover, as \"git tag --contains ...\" takes considerable time, I will\nbe happy if I can set the maximum number in searching tags containing\na commit.  Or are there already some (better) ways to achieve this?\n\nAny advice is welcome.\n\nThanks,\nKai\n"},{"id":"130282","messageId":"m2fx71pq0p.fsf@whitebox.home","threadId":"22015","inReplyTo":"4B324327.5010809@gmail.com","subject":"Re: git tag --contains <commit> -n=1 ?","fromName":"Andreas Schwab","fromEmail":"schwab@linux-m68k.org","sentAt":"2009-12-23T17:19:02Z","receivedAt":"2009-12-23T17:19:02Z","isPatch":false,"sender":{"key":"schwab@linux-m68k.org","avatar":"https://avatars.githubusercontent.com/u/2175493?v=4"},"body":"\"NODA, Kai\" <nodakai@gmail.com> writes:\n\n> Here I wonder whether \"head -1\" is generally correct or not when I want\n> the oldest tag.\n\nSince the output of git tag is sorted by name, generally not.\n\nAndreas.\n\n-- \nAndreas Schwab, schwab@linux-m68k.org\nGPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5\n\"And now for something completely different.\"\n"},{"id":"130294","messageId":"4B327F8F.2060106@gmail.com","threadId":"22015","inReplyTo":"m2fx71pq0p.fsf@whitebox.home","subject":"Re: git tag --contains <commit> -n=1 ?","fromName":"NODA, Kai","fromEmail":"nodakai@gmail.com","sentAt":"2009-12-23T20:37:35Z","receivedAt":"2009-12-23T20:37:35Z","isPatch":false,"sender":{"key":"nodakai@gmail.com","avatar":null},"body":"Thank you for your reply, Andreas\n\nAndreas Schwab wrote:\n...\n>> Here I wonder whether \"head -1\" is generally correct or not when I want\n>> the oldest tag.\n> \n> Since the output of git tag is sorted by name, generally not.\n\nWow, I didn't know that.\nBut then, under the assumption that tags have names like verNNN,\nthat behavior ensures me that \"head -1\" works as intended.\n\nMaybe I look at its implementation ( refs.c:do_for_each_ref , right?)\nbut this seems a tough code to comprehend, especially around\npacked/loose/extra ...\n\nThanks,\nKai\n"},{"id":"130298","messageId":"20091224055257.GA419@sigill.intra.peff.net","threadId":"22015","inReplyTo":"4B327F8F.2060106@gmail.com","subject":"Re: git tag --contains <commit> -n=1 ?","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2009-12-24T05:52:58Z","receivedAt":"2009-12-24T05:52:58Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Dec 24, 2009 at 05:37:35AM +0900, NODA, Kai wrote:\n\n> >Since the output of git tag is sorted by name, generally not.\n> \n> Wow, I didn't know that.\n> But then, under the assumption that tags have names like verNNN,\n> that behavior ensures me that \"head -1\" works as intended.\n\nIf that assumption does not hold, you can also sort by date. See:\n\n  http://article.gmane.org/gmane.comp.version-control.git/133586\n\n-Peff\n"}]}