# Git tag output order is incorrect (IMHO)

16 messages from 2013-07-18 to 2013-10-16. Participants: Rahul Bansal, Duy Nguyen, Andreas Schwab, Junio C Hamano, Jeff King, Antoine Pelisse, Felipe Contreras, Phil Hord.
Thread: https://gitlist.dev/t/34465

## Rahul Bansal, 2013-07-18 15:27

Subject: Git tag output order is incorrect (IMHO)
Message-ID: <840FACA0-7E13-41DB-A0F8-124FAB53BFBD@rtcamp.com>
URL: https://gitlist.dev/e/840FACA0-7E13-41DB-A0F8-124FAB53BFBD%40rtcamp.com

```
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, 2013-07-18 15:51

Subject: Re: Git tag output order is incorrect (IMHO)
Message-ID: <CACsJy8CpZHTCr0=MkSpfurPW_fyLGN_zd4uSzvBSYbuqH8aXew@mail.gmail.com>
URL: https://gitlist.dev/e/CACsJy8CpZHTCr0%3DMkSpfurPW_fyLGN_zd4uSzvBSYbuqH8aXew%40mail.gmail.com
In-Reply-To: <840FACA0-7E13-41DB-A0F8-124FAB53BFBD@rtcamp.com>

```
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, 2013-07-18 15:56

Subject: Re: Git tag output order is incorrect (IMHO)
Message-ID: <CACsJy8Av7b9GMuO-HsT_+QHAc3iDUZQk5KdJ=p8VugaYc3nUPg@mail.gmail.com>
URL: https://gitlist.dev/e/CACsJy8Av7b9GMuO-HsT_%2BQHAc3iDUZQk5KdJ%3Dp8VugaYc3nUPg%40mail.gmail.com
In-Reply-To: <CACsJy8CpZHTCr0=MkSpfurPW_fyLGN_zd4uSzvBSYbuqH8aXew@mail.gmail.com>

```
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, 2013-07-18 15:57

Subject: Re: Git tag output order is incorrect (IMHO)
Message-ID: <CADtAFQ=DwTHv3n56xoTEN7JmwT+b3Bv0CdR_nBbyYudgoCmZUA@mail.gmail.com>
URL: https://gitlist.dev/e/CADtAFQ%3DDwTHv3n56xoTEN7JmwT%2Bb3Bv0CdR_nBbyYudgoCmZUA%40mail.gmail.com
In-Reply-To: <CACsJy8CpZHTCr0=MkSpfurPW_fyLGN_zd4uSzvBSYbuqH8aXew@mail.gmail.com>

```
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:
>
> 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

```

## Rahul Bansal, 2013-07-18 15:58

Subject: Re: Git tag output order is incorrect (IMHO)
Message-ID: <CADtAFQk3inn2C6s0f-uc55Y=wPvwAtmgRu67D9uw6pcMxLvWmA@mail.gmail.com>
URL: https://gitlist.dev/e/CADtAFQk3inn2C6s0f-uc55Y%3DwPvwAtmgRu67D9uw6pcMxLvWmA%40mail.gmail.com
In-Reply-To: <CACsJy8Av7b9GMuO-HsT_+QHAc3iDUZQk5KdJ=p8VugaYc3nUPg@mail.gmail.com>

```
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:
> 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

```

## Duy Nguyen, 2013-07-18 16:14

Subject: Re: Git tag output order is incorrect (IMHO)
Message-ID: <CACsJy8DSYPn+ZkyS+Ufs5QPvfQ1OzkWYB--1gWZQackkeFkyyw@mail.gmail.com>
URL: https://gitlist.dev/e/CACsJy8DSYPn%2BZkyS%2BUfs5QPvfQ1OzkWYB--1gWZQackkeFkyyw%40mail.gmail.com
In-Reply-To: <CADtAFQ=DwTHv3n56xoTEN7JmwT+b3Bv0CdR_nBbyYudgoCmZUA@mail.gmail.com>

```
On Thu, Jul 18, 2013 at 10:57 PM, Rahul Bansal <rahul.bansal@rtcamp.com> wrote:
> 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, 2013-07-18 17:42

Subject: Re: Git tag output order is incorrect (IMHO)
Message-ID: <87wqon7ok4.fsf@igel.home>
URL: https://gitlist.dev/e/87wqon7ok4.fsf%40igel.home
In-Reply-To: <840FACA0-7E13-41DB-A0F8-124FAB53BFBD@rtcamp.com>

```
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, 2013-07-19 19:40

Subject: Re: Git tag output order is incorrect (IMHO)
Message-ID: <7vli52uym0.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vli52uym0.fsf%40alter.siamese.dyndns.org
In-Reply-To: <87wqon7ok4.fsf@igel.home>

```
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.

```

## Jeff King, 2013-07-20 00:22

Subject: Re: Git tag output order is incorrect (IMHO)
Message-ID: <20130720002241.GA22143@sigill.intra.peff.net>
URL: https://gitlist.dev/e/20130720002241.GA22143%40sigill.intra.peff.net
In-Reply-To: <7vli52uym0.fsf@alter.siamese.dyndns.org>

```
On Fri, Jul 19, 2013 at 12:40:55PM -0700, Junio C Hamano wrote:

> 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, 2013-08-20 15:12

Subject: Re: Git tag output order is incorrect (IMHO)
Message-ID: <CALWbr2w7XCuD5tUSwR+Cwv4wyXLk8MHDGyU2Dr+jA9vOfDYqig@mail.gmail.com>
URL: https://gitlist.dev/e/CALWbr2w7XCuD5tUSwR%2BCwv4wyXLk8MHDGyU2Dr%2BjA9vOfDYqig%40mail.gmail.com
In-Reply-To: <20130720002241.GA22143@sigill.intra.peff.net>

```
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, 2013-09-08 08:03

Subject: Re: Git tag output order is incorrect (IMHO)
Message-ID: <20130908080311.GA25498@sigill.intra.peff.net>
URL: https://gitlist.dev/e/20130908080311.GA25498%40sigill.intra.peff.net
In-Reply-To: <CALWbr2w7XCuD5tUSwR+Cwv4wyXLk8MHDGyU2Dr+jA9vOfDYqig@mail.gmail.com>

```
On Tue, Aug 20, 2013 at 05:12:47PM +0200, Antoine Pelisse wrote:

> 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

```

## Felipe Contreras, 2013-09-08 22:49

Subject: Re: Git tag output order is incorrect (IMHO)
Message-ID: <CAMP44s3p_DRTvBhKbM0ejKgea9hauSCzahPux4jCWL7JP4nxKw@mail.gmail.com>
URL: https://gitlist.dev/e/CAMP44s3p_DRTvBhKbM0ejKgea9hauSCzahPux4jCWL7JP4nxKw%40mail.gmail.com
In-Reply-To: <840FACA0-7E13-41DB-A0F8-124FAB53BFBD@rtcamp.com>

```
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

```

## Phil Hord, 2013-09-11 13:42

Subject: Re: Git tag output order is incorrect (IMHO)
Message-ID: <CABURp0o5tOswiv_avfAQOZwGREpX3v7MwcdVzt7dkubY2Y0O6g@mail.gmail.com>
URL: https://gitlist.dev/e/CABURp0o5tOswiv_avfAQOZwGREpX3v7MwcdVzt7dkubY2Y0O6g%40mail.gmail.com
In-Reply-To: <CAMP44s3p_DRTvBhKbM0ejKgea9hauSCzahPux4jCWL7JP4nxKw@mail.gmail.com>

```
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:
> 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, 2013-09-11 17:54

Subject: Re: Git tag output order is incorrect (IMHO)
Message-ID: <xmqqioy7tfba.fsf@gitster.dls.corp.google.com>
URL: https://gitlist.dev/e/xmqqioy7tfba.fsf%40gitster.dls.corp.google.com
In-Reply-To: <CABURp0o5tOswiv_avfAQOZwGREpX3v7MwcdVzt7dkubY2Y0O6g@mail.gmail.com>

```
Phil Hord <phil.hord@gmail.com> writes:

> 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.

```

## Jeff King, 2013-10-16 17:56

Subject: Re: Git tag output order is incorrect (IMHO)
Message-ID: <20131016175621.GA4308@sigill.intra.peff.net>
URL: https://gitlist.dev/e/20131016175621.GA4308%40sigill.intra.peff.net
In-Reply-To: <20130908080311.GA25498@sigill.intra.peff.net>

```
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.

-Peff

```

## Antoine Pelisse, 2013-10-16 18:06

Subject: Re: Git tag output order is incorrect (IMHO)
Message-ID: <CALWbr2zMrUL0cmtYuoGZ_Sm33i29fJRdJtDZmd6kR_KrabU+PQ@mail.gmail.com>
URL: https://gitlist.dev/e/CALWbr2zMrUL0cmtYuoGZ_Sm33i29fJRdJtDZmd6kR_KrabU%2BPQ%40mail.gmail.com
In-Reply-To: <20131016175621.GA4308@sigill.intra.peff.net>

```
On Wed, Oct 16, 2013 at 7:56 PM, Jeff King <peff@peff.net> wrote:
> 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

```
