threads / discuss / 34465

Git tag output order is incorrect (IMHO)

Subject: Git tag output order is incorrect (IMHO)

## tl;dr

16 messages between Jul 18, 2013 and Oct 16, 2013.

replies: 15people: 8as markdown or json

Rahul Bansal· Jul 18, 2013, 15:27 UTC · lore
I am posting here first time, so please excuse me if this is not right place to send something like this.
Please check - http://stackoverflow.com/questions/6091306/can-i-make-git-print-x-y-z-style-tag-names-in-a-sensible-order
And also - https://github.com/gitlabhq/gitlabhq/issues/4565
IMHO "git tag" is expected to show tag-list ordered by versions. 
It may be case, that people do not follow same version numbering convention. Most people after x.9.x increment major version (that is why they may not be affected because of this)
Another option like "git tag --date-asc" can be added which will print tags by creation date. (As long as people do not create backdated tag, this will work).

Thanks, -Rahul

Duy Nguyen· Jul 18, 2013, 15:51 UTC · re: Rahul Bansal · lore

Re: Git tag output order is incorrect (IMHO)

On Thu, Jul 18, 2013 at 10:27 PM, Rahul Bansal <rahul.bansal@rtcamp.com> wrote:
Show 11 quoted lines
> I am posting here first time, so please excuse me if this is not right place to send something like this.
>
> Please check - http://stackoverflow.com/questions/6091306/can-i-make-git-print-x-y-z-style-tag-names-in-a-sensible-order
>
> And also - https://github.com/gitlabhq/gitlabhq/issues/4565
>
> IMHO "git tag" is expected to show tag-list ordered by versions.
>
> It may be case, that people do not follow same version numbering convention. Most people after x.9.x increment major version (that is why they may not be affected because of this)
>
> Another option like "git tag --date-asc" can be added which will print tags by creation date. (As long as people do not create backdated tag, this will work).
Try

git for-each-ref --sort=committerdate --format='%(refname:short)' refs/tags -- Duy

Duy Nguyen· Jul 18, 2013, 15:56 UTC · re: Duy Nguyen · lore

Re: Git tag output order is incorrect (IMHO)

On Thu, Jul 18, 2013 at 10:51 PM, Duy Nguyen <pclouds@gmail.com> wrote:
> Try
>
> git for-each-ref --sort=committerdate --format='%(refname:short)' refs/tags
And I wondered why it did not seem right. Use this one instead
git for-each-ref --sort=taggerdate --format='%(refname:short)' refs/tags

make it --sort=-taggerdate to reverse sort order. -- Duy

Rahul Bansal· Jul 18, 2013, 15:58 UTC · re: Duy Nguyen · lore

Re: Git tag output order is incorrect (IMHO)

Thanks again Duy. :-)
Sorry for misspelling your name in earlier email.
--
Rahul Bansal | Founder & CEO | rtCamp Solutions Pvt. Ltd.
Skype: rahul286 | Twitter: @rahul286 | Web: http://rtcamp.com/
On Thu, Jul 18, 2013 at 9:26 PM, Duy Nguyen <pclouds@gmail.com> wrote:
Show 12 quoted lines
> On Thu, Jul 18, 2013 at 10:51 PM, Duy Nguyen <pclouds@gmail.com> wrote:
>> Try
>>
>> git for-each-ref --sort=committerdate --format='%(refname:short)' refs/tags
>
> And I wondered why it did not seem right. Use this one instead
>
> git for-each-ref --sort=taggerdate --format='%(refname:short)' refs/tags
>
> make it --sort=-taggerdate to reverse sort order.
> --
> Duy
Rahul Bansal· Jul 18, 2013, 15:57 UTC · re: Duy Nguyen · lore

Re: Git tag output order is incorrect (IMHO)

Hi Day,
I am aware of that command as well.

I think `git tag` current default order is string-based sorting. I felt version-number based sorting and/or create-date based sorting will be more appropriate.

--
Rahul Bansal | Founder & CEO | rtCamp Solutions Pvt. Ltd.
Skype: rahul286 | Twitter: @rahul286 | Web: http://rtcamp.com/
On Thu, Jul 18, 2013 at 9:21 PM, Duy Nguyen <pclouds@gmail.com> wrote:
Show 27 quoted lines
>
> On Thu, Jul 18, 2013 at 10:27 PM, Rahul Bansal <rahul.bansal@rtcamp.com>
> wrote:
> > I am posting here first time, so please excuse me if this is not right
> > place to send something like this.
> >
> > Please check -
> > http://stackoverflow.com/questions/6091306/can-i-make-git-print-x-y-z-style-tag-names-in-a-sensible-order
> >
> > And also - https://github.com/gitlabhq/gitlabhq/issues/4565
> >
> > IMHO "git tag" is expected to show tag-list ordered by versions.
> >
> > It may be case, that people do not follow same version numbering
> > convention. Most people after x.9.x increment major version (that is why
> > they may not be affected because of this)
> >
> > Another option like "git tag --date-asc" can be added which will print
> > tags by creation date. (As long as people do not create backdated tag, this
> > will work).
>
> Try
>
> git for-each-ref --sort=committerdate --format='%(refname:short)'
> refs/tags
> --
> Duy
Duy Nguyen· Jul 18, 2013, 16:14 UTC · re: Rahul Bansal · lore

Re: Git tag output order is incorrect (IMHO)

On Thu, Jul 18, 2013 at 10:57 PM, Rahul Bansal <rahul.bansal@rtcamp.com> wrote:
Show 7 quoted lines
> Hi Day,
>
> I am aware of that command as well.
>
> I think `git tag` current default order is string-based sorting. I
> felt version-number based sorting and/or create-date based sorting
> will be more appropriate.

ok you mean the _default_ order? What about other non-version tags (even temporary ones just to mark something then removed)? -- Duy

Andreas Schwab· Jul 18, 2013, 17:42 UTC · re: Rahul Bansal · lore

Re: Git tag output order is incorrect (IMHO)

Rahul Bansal <rahul.bansal@rtcamp.com> writes:
> IMHO "git tag" is expected to show tag-list ordered by versions. 
A git tag can be anything, not related to versions at all.
Andreas.
-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."
Junio C Hamano· Jul 19, 2013, 19:40 UTC · re: Andreas Schwab · lore

Re: Git tag output order is incorrect (IMHO)

Andreas Schwab <schwab@linux-m68k.org> writes:
Show 5 quoted lines
> Rahul Bansal <rahul.bansal@rtcamp.com> writes:
>
>> IMHO "git tag" is expected to show tag-list ordered by versions. 
>
> A git tag can be anything, not related to versions at all.
Correct.

But that does not prevent somebody to add "git tag --sort=X" option to the command, just like "git for-each-ref" has "--sort=X" option.

Jeff King· Jul 20, 2013, 00:22 UTC · re: Junio C Hamano · lore

Re: Git tag output order is incorrect (IMHO)

On Fri, Jul 19, 2013 at 12:40:55PM -0700, Junio C Hamano wrote:
Show 12 quoted lines
> Andreas Schwab <schwab@linux-m68k.org> writes:
> 
> > Rahul Bansal <rahul.bansal@rtcamp.com> writes:
> >
> >> IMHO "git tag" is expected to show tag-list ordered by versions. 
> >
> > A git tag can be anything, not related to versions at all.
> 
> Correct.
> 
> But that does not prevent somebody to add "git tag --sort=X" option
> to the command, just like "git for-each-ref" has "--sort=X" option.

A while ago I started on (but did not get very far on) unifying the ref selection code for for-each-ref, tag, and branch. It would be nice if they all supported the same set of --contains/--points-at/--merged/--sort, etc.

I do plan to finish it eventually, but if anyone else feels like picking it up, I'd be glad to review patches and/or share my work-in-progress as a starting point.

-Peff
Antoine Pelisse· Aug 20, 2013, 15:12 UTC · re: Jeff King · lore

Re: Git tag output order is incorrect (IMHO)

On Sat, Jul 20, 2013 at 2:22 AM, Jeff King <peff@peff.net> wrote:
> I do plan to finish it eventually, but if anyone else feels like picking
> it up, I'd be glad to review patches and/or share my work-in-progress as
> a starting point.

Hi Jeff, I have some free time to come, and would like to work on that feature. Does the offer still hold ? If it does, I would be interested in your patches.

Cheers,
Jeff King· Sep 8, 2013, 08:03 UTC · re: Antoine Pelisse · lore

Re: Git tag output order is incorrect (IMHO)

On Tue, Aug 20, 2013 at 05:12:47PM +0200, Antoine Pelisse wrote:
Show 8 quoted lines
> On Sat, Jul 20, 2013 at 2:22 AM, Jeff King <peff@peff.net> wrote:
> > I do plan to finish it eventually, but if anyone else feels like picking
> > it up, I'd be glad to review patches and/or share my work-in-progress as
> > a starting point.
> 
> I have some free time to come, and would like to work on that feature.
> Does the offer still hold ?
> If it does, I would be interested in your patches.

I'm sorry I have taken so long to get back to you on this. I was hoping to revisit the topic and make sure the patches were in a sensible state for showing to somebody. But it took me some time to get around to it, and now that I have, they're really not looking very good.

My general strategy was to factor out all of the "which refs to select" code from git-tag (which knows --contains and --points-at) and git-branch (which knows --merged, --no-merged, and --contains), and then make them all available in a library-ish way to both commands, as well as for-each-ref (which also knows name matching, which all 3 should know, too). You can see my messy in-progress commit (that does not even compile) at:

  git://github.com/peff/git.git jk/contains-wip

Part of the complication is that the filters have to happen at different times (you can efficiently ask "--contains" for each ref as you see it, but asking "--merged" must happen after you have collected each one).

I do not recall at this point what other issues led me to stop working on it (it may simply have been time for dinner, and I never came back to it). So the patches there may or may not actually be helpful to you.

Sorry I can't be more helpful. I'd be happy to discuss or review if you want to work on it.

-Peff
Jeff King· Oct 16, 2013, 17:56 UTC · re: Jeff King · lore

Re: Git tag output order is incorrect (IMHO)

On Sun, Sep 08, 2013 at 04:03:11AM -0400, Jeff King wrote:
Show 8 quoted lines
> > I have some free time to come, and would like to work on that feature.
> > Does the offer still hold ?
> > If it does, I would be interested in your patches.
> 
> I'm sorry I have taken so long to get back to you on this. I was hoping
> to revisit the topic and make sure the patches were in a sensible state
> for showing to somebody. But it took me some time to get around to it,
> and now that I have, they're really not looking very good.
Hi Antoine,

Since I haven't heard anything, I assume you haven't been working on this. But in case you have, I wanted to let you know I found some time and moved the topic forward a bit. It's not quite ready to share with the list, but I wanted to notify you so we didn't duplicate effort.

-Peff
Antoine Pelisse· Oct 16, 2013, 18:06 UTC · re: Jeff King · lore

Re: Git tag output order is incorrect (IMHO)

On Wed, Oct 16, 2013 at 7:56 PM, Jeff King <peff@peff.net> wrote:
Show 17 quoted lines
> On Sun, Sep 08, 2013 at 04:03:11AM -0400, Jeff King wrote:
>
>> > I have some free time to come, and would like to work on that feature.
>> > Does the offer still hold ?
>> > If it does, I would be interested in your patches.
>>
>> I'm sorry I have taken so long to get back to you on this. I was hoping
>> to revisit the topic and make sure the patches were in a sensible state
>> for showing to somebody. But it took me some time to get around to it,
>> and now that I have, they're really not looking very good.
>
> Hi Antoine,
>
> Since I haven't heard anything, I assume you haven't been working on
> this. But in case you have, I wanted to let you know I found some time
> and moved the topic forward a bit. It's not quite ready to share with
> the list, but I wanted to notify you so we didn't duplicate effort.

Unfortunately, I didn't have as much time as expected to work on this topic. I'm glad to hear that it's moving forward and will definitely have a look when you send the patches to the list. Thank you for letting me know,

Cheers, Antoine

Felipe Contreras· Sep 8, 2013, 22:49 UTC · re: Rahul Bansal · lore

Re: Git tag output order is incorrect (IMHO)

On Thu, Jul 18, 2013 at 10:27 AM, Rahul Bansal <rahul.bansal@rtcamp.com> wrote:
Show 11 quoted lines
> I am posting here first time, so please excuse me if this is not right place to send something like this.
>
> Please check - http://stackoverflow.com/questions/6091306/can-i-make-git-print-x-y-z-style-tag-names-in-a-sensible-order
>
> And also - https://github.com/gitlabhq/gitlabhq/issues/4565
>
> IMHO "git tag" is expected to show tag-list ordered by versions.
>
> It may be case, that people do not follow same version numbering convention. Most people after x.9.x increment major version (that is why they may not be affected because of this)
>
> Another option like "git tag --date-asc" can be added which will print tags by creation date. (As long as people do not create backdated tag, this will work).

I completely agree, and there was a proposal to an option like this a long time ago:

http://article.gmane.org/gmane.comp.version-control.git/111032
-- 
Felipe Contreras
Phil Hord· Sep 11, 2013, 13:42 UTC · re: Felipe Contreras · lore

Re: Git tag output order is incorrect (IMHO)

Someone at $work asked me this week how to find the current and previous tags on his branch so he could generate release notes. I just need "last two tags on head in topo-order". I was surprised by how complicated this turned out to be. I ended up with this:

  git log --decorate=full --pretty=format:'%d' HEAD |
    sed -n -e 's-^.* refs/tags/\(.*\)[ )].*$-\1-p' |
    head -2
Surely there's a cleaner way, right?
Phil

On Sun, Sep 8, 2013 at 6:49 PM, Felipe Contreras <felipe.contreras@gmail.com> wrote:

Show 24 quoted lines
> On Thu, Jul 18, 2013 at 10:27 AM, Rahul Bansal <rahul.bansal@rtcamp.com> wrote:
>> I am posting here first time, so please excuse me if this is not right place to send something like this.
>>
>> Please check - http://stackoverflow.com/questions/6091306/can-i-make-git-print-x-y-z-style-tag-names-in-a-sensible-order
>>
>> And also - https://github.com/gitlabhq/gitlabhq/issues/4565
>>
>> IMHO "git tag" is expected to show tag-list ordered by versions.
>>
>> It may be case, that people do not follow same version numbering convention. Most people after x.9.x increment major version (that is why they may not be affected because of this)
>>
>> Another option like "git tag --date-asc" can be added which will print tags by creation date. (As long as people do not create backdated tag, this will work).
>
> I completely agree, and there was a proposal to an option like this a
> long time ago:
>
> http://article.gmane.org/gmane.comp.version-control.git/111032
>
> --
> Felipe Contreras
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
Junio C Hamano· Sep 11, 2013, 17:54 UTC · re: Phil Hord · lore

Re: Git tag output order is incorrect (IMHO)

Phil Hord <phil.hord@gmail.com> writes:
Show 10 quoted lines
> Someone at $work asked me this week how to find the current and
> previous tags on his branch so he could generate release notes.  I
> just need "last two tags on head in topo-order". I was surprised by
> how complicated this turned out to be. I ended up with this:
>
>   git log --decorate=full --pretty=format:'%d' HEAD |
>     sed -n -e 's-^.* refs/tags/\(.*\)[ )].*$-\1-p' |
>     head -2
>
> Surely there's a cleaner way, right?

That looks clean enough (I would have used "head -n 2" though) and in line with the way how you can exercise the flexibility of the system, at least to me ;-).

Joking aside, I agree that a "--merged X" primitive, i.e. "what refs can be reachable from commit X?", in the listing mode of "git tag" or "git for-each-ref" would have helped. As the sorting and formatting primitives are already there in for-each-ref, it would have been

	git for-each-ref \
            --format='%(refname:short)' \
            --sort='-*committerdate' \
            --count=2 \
            --merged my-branch \
            refs/tags/
or something like that.

← back to recent threads