{"thread":{"id":"39917","subject":"Feature Request: Passing a number as an option to git tags for displaying latest tags","startedAt":"2015-07-22T17:17:45Z","lastAt":"2015-07-23T18:21:39Z","messageCount":10,"participants":["Halil Öztürk","Jacob Keller","Andreas Schwab","Junio C Hamano","Michael J Gruber"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"266611","messageId":"CALpYpjE1WE=fO0q=rGPHedZwP8JovJ0CxELBd_EhAmncRS6ZYA@mail.gmail.com","threadId":"39917","inReplyTo":null,"subject":"Feature Request: Passing a number as an option to git tags for displaying latest tags","fromName":"Halil Öztürk","fromEmail":"halilozturk55@gmail.com","sentAt":"2015-07-22T17:17:45Z","receivedAt":"2015-07-22T17:17:45Z","isPatch":false,"sender":{"key":"halilozturk55@gmail.com","avatar":null},"body":"Hello team,\n\nPassing a number as an option to \"git tags\" command should display latest tags.\n\ne.g. \"git tags -5\" will display last 5 tags only.\n\nSimilar behavior to \"git log -5\"\n\nThanks,\nHalil\n"},{"id":"266615","messageId":"CA+P7+xpkt+23rdiKt4Cx=+K0m9cgLnd9u+g4f1W+k=-FSNumXg@mail.gmail.com","threadId":"39917","inReplyTo":"CALpYpjE1WE=fO0q=rGPHedZwP8JovJ0CxELBd_EhAmncRS6ZYA@mail.gmail.com","subject":"Re: Feature Request: Passing a number as an option to git tags for displaying latest tags","fromName":"Jacob Keller","fromEmail":"jacob.keller@gmail.com","sentAt":"2015-07-22T18:36:00Z","receivedAt":"2015-07-22T18:36:00Z","isPatch":false,"sender":{"key":"jacob.keller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/874719?v=4"},"body":"On Wed, Jul 22, 2015 at 10:17 AM, Halil Öztürk <halilozturk55@gmail.com> wrote:\n> Hello team,\n>\n> Passing a number as an option to \"git tags\" command should display latest tags.\n>\n> e.g. \"git tags -5\" will display last 5 tags only.\n>\n> Similar behavior to \"git log -5\"\n>\n> Thanks,\n> Halil\n> --\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n\n\nWhile interesting, this would only really work for annotated tags. How\nwould you define order? tags are normally shown in sorted lexical\norder (or version-order if you pass the --sort parameter).\nNon-annotated tags do not contain the date time, and using the\ncommit's date information may not be accurate. While it is possible to\nsay show \"the 5 most recent tags on a particular branch of history\"\nthat would be using the log to determine this.\n\nWhat exactly would you expect the behavior to be with tags? That might\nhelp figure out what could be done instead.\n\nRegards,\nJake\n"},{"id":"266617","messageId":"87lhe8f29f.fsf@igel.home","threadId":"39917","inReplyTo":"CALpYpjE1WE=fO0q=rGPHedZwP8JovJ0CxELBd_EhAmncRS6ZYA@mail.gmail.com","subject":"Re: Feature Request: Passing a number as an option to git tags for displaying latest tags","fromName":"Andreas Schwab","fromEmail":"schwab@linux-m68k.org","sentAt":"2015-07-22T18:58:20Z","receivedAt":"2015-07-22T18:58:20Z","isPatch":false,"sender":{"key":"schwab@linux-m68k.org","avatar":"https://avatars.githubusercontent.com/u/2175493?v=4"},"body":"Halil Öztürk <halilozturk55@gmail.com> writes:\n\n> Passing a number as an option to \"git tags\" command should display latest tags.\n\nHow do you define \"the latest tags\"?  By tag creation?  Lightweight\ntags don't have any kind of creation time attached.\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":"266620","messageId":"xmqqbnf4rohs.fsf@gitster.dls.corp.google.com","threadId":"39917","inReplyTo":"CALpYpjE1WE=fO0q=rGPHedZwP8JovJ0CxELBd_EhAmncRS6ZYA@mail.gmail.com","subject":"Re: Feature Request: Passing a number as an option to git tags for displaying latest tags","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-07-22T19:17:19Z","receivedAt":"2015-07-22T19:17:19Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Halil Öztürk <halilozturk55@gmail.com> writes:\n\n> Passing a number as an option to \"git tags\" command should display latest tags.\n>\n> e.g. \"git tags -5\" will display last 5 tags only.\n\nI think this conflates two unrelated things.\n\n - Ordering tags not by refnames (i.e. default) but by \"time\".\n\n - Limiting the output by count.\n\nThe latter is what \"| head -n 5\" and/or \"| tail -n 5\" are for, so it\nwould be at most \"nice to have\"; I am indifferent in the sense that\nI won't work on it, but I'd take a look if somebody sent a patch\nthat was cleanly done.\n\nThe former, sort by \"time\", is interesting, but you need to define\nwhat to do with various corner cases.  For example, some people may\nbe have one or more of the following desires:\n\n * My project did not use tags for a long time, and started using it\n   recently starting from v1.1.0.  The first release only said\n   \"Frotz version 1.0.0\" in its commit log message.  I retroactively\n   did \"git tag -s -m 'Frotz 1.1.0' v1.1.0\" on that commit.\n\n   In such a case, it is likely that I would want the sorting done\n   based on the committer date on the underlying commit, not the\n   tag's tagger date.\n\n * When a bug is found, it is customary in my project to add a\n   \"break-<something>\" tag to the commit that introduces the bug\n   (and \"fix-<something>\" tag to the commit that fixes it).\n\n   When I want to find recently discovered breakages, I want the\n   tags whose names match \"break-*\" sorted by tagger dates, not the\n   underlying commit's committer dates.\n\nThe necessary ordering machinery to do the above already exists in\n\"for-each-ref\".  There is a GSoC project that works to unify various\nfeatures spread across \"for-each-ref\", \"branch -l\" and \"tag -l\" and\nmake them available to all of the three.\n"},{"id":"266622","messageId":"xmqq7fpsroc1.fsf@gitster.dls.corp.google.com","threadId":"39917","inReplyTo":"xmqqbnf4rohs.fsf@gitster.dls.corp.google.com","subject":"Re: Feature Request: Passing a number as an option to git tags for displaying latest tags","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-07-22T19:20:46Z","receivedAt":"2015-07-22T19:20:46Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> The former, sort by \"time\", is interesting, but you need to define\n> what to do with various corner cases.  For example, some people may\n> have one or more of the following desires:\n>\n>  * My project did not use tags for a long time, and started using it\n>    recently starting from v1.1.0.  The first release only said\n>    \"Frotz version 1.0.0\" in its commit log message.  I retroactively\n>    did \"git tag -s -m 'Frotz 1.1.0' v1.1.0\" on that commit.\n\nObviously, I meant \"git tag -s -m 'Frotz 1.0.0' v1.0.0\" here.\n\n>    In such a case, it is likely that I would want the sorting done\n>    based on the committer date on the underlying commit, not the\n>    tag's tagger date.\n>\n>  * When a bug is found, it is customary in my project to add a\n>    \"break-<something>\" tag to the commit that introduces the bug\n>    (and \"fix-<something>\" tag to the commit that fixes it).\n>\n>    When I want to find recently discovered breakages, I want the\n>    tags whose names match \"break-*\" sorted by tagger dates, not the\n>    underlying commit's committer dates.\n\nAnother use case may be one in which older tags are interesting.  In\nother words, you need to be able to sort in reverse, too.\n\n> The necessary ordering machinery to do the above already exists in\n> \"for-each-ref\".  There is a GSoC project that works to unify various\n> features spread across \"for-each-ref\", \"branch -l\" and \"tag -l\" and\n> make them available to all of the three.\n\nAnd the above is still true even with reverse-order use case.\n"},{"id":"266652","messageId":"55B0B667.6000103@drmicha.warpmail.net","threadId":"39917","inReplyTo":"xmqq7fpsroc1.fsf@gitster.dls.corp.google.com","subject":"Re: Feature Request: Passing a number as an option to git tags for displaying latest tags","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2015-07-23T09:39:51Z","receivedAt":"2015-07-23T09:39:51Z","isPatch":false,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Junio C Hamano venit, vidit, dixit 22.07.2015 21:20:\n> Junio C Hamano <gitster@pobox.com> writes:\n> \n>> The former, sort by \"time\", is interesting, but you need to define\n>> what to do with various corner cases.  For example, some people may\n>> have one or more of the following desires:\n>>\n>>  * My project did not use tags for a long time, and started using it\n>>    recently starting from v1.1.0.  The first release only said\n>>    \"Frotz version 1.0.0\" in its commit log message.  I retroactively\n>>    did \"git tag -s -m 'Frotz 1.1.0' v1.1.0\" on that commit.\n> \n> Obviously, I meant \"git tag -s -m 'Frotz 1.0.0' v1.0.0\" here.\n> \n>>    In such a case, it is likely that I would want the sorting done\n>>    based on the committer date on the underlying commit, not the\n>>    tag's tagger date.\n>>\n>>  * When a bug is found, it is customary in my project to add a\n>>    \"break-<something>\" tag to the commit that introduces the bug\n>>    (and \"fix-<something>\" tag to the commit that fixes it).\n>>\n>>    When I want to find recently discovered breakages, I want the\n>>    tags whose names match \"break-*\" sorted by tagger dates, not the\n>>    underlying commit's committer dates.\n> \n> Another use case may be one in which older tags are interesting.  In\n> other words, you need to be able to sort in reverse, too.\n> \n>> The necessary ordering machinery to do the above already exists in\n>> \"for-each-ref\".  There is a GSoC project that works to unify various\n>> features spread across \"for-each-ref\", \"branch -l\" and \"tag -l\" and\n>> make them available to all of the three.\n> \n> And the above is still true even with reverse-order use case.\n> \n\nWhile not quite being intended for that purpose,\n\ngit log --oneline --decorate --simplify-by-decoration [-n] --tags\n\n(or with a custom format instead of \"--oneline --decorate\") may come\nclose to what you want.[*]\n\nMichael\n\n[*] As Linus once described it (iirc): oooh, evil. I like it.\n"},{"id":"266671","messageId":"CA+P7+xpasr7gOYiSsdAyCgh6+D8nYQf9vuEhRna8k7HWMu1Rcg@mail.gmail.com","threadId":"39917","inReplyTo":"55B0B667.6000103@drmicha.warpmail.net","subject":"Re: Feature Request: Passing a number as an option to git tags for displaying latest tags","fromName":"Jacob Keller","fromEmail":"jacob.keller@gmail.com","sentAt":"2015-07-23T17:21:39Z","receivedAt":"2015-07-23T17:21:39Z","isPatch":false,"sender":{"key":"jacob.keller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/874719?v=4"},"body":"On Thu, Jul 23, 2015 at 2:39 AM, Michael J Gruber\n<git@drmicha.warpmail.net> wrote:\n>\n> While not quite being intended for that purpose,\n>\n> git log --oneline --decorate --simplify-by-decoration [-n] --tags\n>\n> (or with a custom format instead of \"--oneline --decorate\") may come\n> close to what you want.[*]\n>\n> Michael\n>\n> [*] As Linus once described it (iirc): oooh, evil. I like it.\n> --\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n\nYep, that's pretty much how a build system I've had to use does it.\nSadly, this is quite slow, and I'm not sure if doing it built into the\ntag via for-each-ref would be faster? I mean obviously having to look\nat each commit is slower than just the tag name, but it might be\nfaster than parsing through the log process? Though the log output has\nthe advantage that it only shows you tags \"on\" a given branch.\n\nRegards,\nJake\n"},{"id":"266677","messageId":"xmqqd1zipxc3.fsf@gitster.dls.corp.google.com","threadId":"39917","inReplyTo":"CA+P7+xpasr7gOYiSsdAyCgh6+D8nYQf9vuEhRna8k7HWMu1Rcg@mail.gmail.com","subject":"Re: Feature Request: Passing a number as an option to git tags for displaying latest tags","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-07-23T18:01:32Z","receivedAt":"2015-07-23T18:01:32Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jacob Keller <jacob.keller@gmail.com> writes:\n\n> Yep, that's pretty much how a build system I've had to use does it.\n> Sadly, this is quite slow, and I'm not sure if doing it built into the\n> tag via for-each-ref would be faster?\n\nIs the description in \"git for-each-ref --help\" somehow unreadable?\n\n       An example directly producing formatted text. Show the most\n       recent 3 tagged commits:\n\n           #!/bin/sh\n\n           git for-each-ref --count=3 --sort='-*authordate' \\\n           --format='From: %(*authorname) %(*authoremail)\n           Subject: %(*subject)\n           Date: %(*authordate)\n           Ref: %(*refname)\n\n           %(*body)\n           ' 'refs/tags'\n\nIf you only need the name of the ref, you can use a lot simpler\nformat string, e.g.\n\n    git for-each-ref --count=3 --sort='-*authordate' \\\n      --format='%(refname:short)' refs/tags\n\n    git for-each-ref --count=3 --sort='-taggerdate' \\\n      --format='%(refname:short)' refs/tags\n"},{"id":"266679","messageId":"CA+P7+xpy86GMmdtcag4kaxDrB4TrdeQYraabNS0pASdBG+P+OQ@mail.gmail.com","threadId":"39917","inReplyTo":"xmqqd1zipxc3.fsf@gitster.dls.corp.google.com","subject":"Re: Feature Request: Passing a number as an option to git tags for displaying latest tags","fromName":"Jacob Keller","fromEmail":"jacob.keller@gmail.com","sentAt":"2015-07-23T18:12:54Z","receivedAt":"2015-07-23T18:12:54Z","isPatch":false,"sender":{"key":"jacob.keller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/874719?v=4"},"body":"On Thu, Jul 23, 2015 at 11:01 AM, Junio C Hamano <gitster@pobox.com> wrote:\n> Jacob Keller <jacob.keller@gmail.com> writes:\n>\n>> Yep, that's pretty much how a build system I've had to use does it.\n>> Sadly, this is quite slow, and I'm not sure if doing it built into the\n>> tag via for-each-ref would be faster?\n>\n> Is the description in \"git for-each-ref --help\" somehow unreadable?\n>\n>        An example directly producing formatted text. Show the most\n>        recent 3 tagged commits:\n>\n>            #!/bin/sh\n>\n>            git for-each-ref --count=3 --sort='-*authordate' \\\n>            --format='From: %(*authorname) %(*authoremail)\n>            Subject: %(*subject)\n>            Date: %(*authordate)\n>            Ref: %(*refname)\n>\n>            %(*body)\n>            ' 'refs/tags'\n>\n> If you only need the name of the ref, you can use a lot simpler\n> format string, e.g.\n>\n>     git for-each-ref --count=3 --sort='-*authordate' \\\n>       --format='%(refname:short)' refs/tags\n>\n>     git for-each-ref --count=3 --sort='-taggerdate' \\\n>       --format='%(refname:short)' refs/tags\n>\n\nThat's significantly better than what this system does, but sadly the\nteam that owns it doesn't exactly understand git. Pretty sure they\ntend to just use whatever scriptlet they got working, which happens to\nbe based on log...  I've tried to help them, but generally hasn't been\na successful relationship there.\n\nRegards,\nJake\n"},{"id":"266680","messageId":"xmqq8ua6pwek.fsf@gitster.dls.corp.google.com","threadId":"39917","inReplyTo":"CA+P7+xpy86GMmdtcag4kaxDrB4TrdeQYraabNS0pASdBG+P+OQ@mail.gmail.com","subject":"Re: Feature Request: Passing a number as an option to git tags for displaying latest tags","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-07-23T18:21:39Z","receivedAt":"2015-07-23T18:21:39Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jacob Keller <jacob.keller@gmail.com> writes:\n\n> On Thu, Jul 23, 2015 at 11:01 AM, Junio C Hamano <gitster@pobox.com> wrote:\n>> Jacob Keller <jacob.keller@gmail.com> writes:\n>>\n>>> Yep, that's pretty much how a build system I've had to use does it.\n>>> Sadly, this is quite slow, and I'm not sure if doing it built into the\n>>> tag via for-each-ref would be faster?\n>>\n>> Is the description in \"git for-each-ref --help\" somehow unreadable?\n>> ...\n>> If you only need the name of the ref, you can use a lot simpler\n>> format string, e.g.\n>>\n>>     git for-each-ref --count=3 --sort='-*authordate' \\\n>>       --format='%(refname:short)' refs/tags\n>>\n>>     git for-each-ref --count=3 --sort='-taggerdate' \\\n>>       --format='%(refname:short)' refs/tags\n>>\n>\n> That's significantly better than what this system does, but sadly the\n> team that owns it doesn't exactly understand git. Pretty sure they\n> tend to just use whatever scriptlet they got working, which happens to\n> be based on log...  I've tried to help them, but generally hasn't been\n> a successful relationship there.\n\nIf your build people refuse to switch from an unreliable way of\nparsing \"log\" output that is not meant for machine consumption, then\nit wouldn't make any difference what the answer to your \"I'm not\nsure if doing it built into ... be faster?\" X-<.\n\nBy the way, I was referring to that question, pointing out that you\ndo not have be wondering.  It is already there, and as I said a few\nmessages ago already in this thread, the cross-pollination among\n\"for-each-ref\", \"branch -l\" and \"tag -l\" is happening as part of\nthis year's GSoC program.\n"}]}