git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Matthew Timothy Kennerly <mtkennerly@gmail.com>
To: Kyle Meyer <kyle@kyleam.com>
Cc: git@vger.kernel.org, Jeff King <peff@peff.net>
Subject: Re: Differences in compound tag sorting between 2.27.0 and 2.21.0
Date: Sun, 27 Sep 2020 14:26:05 -0400	[thread overview]
Message-ID: <CAKqNo6QCa2bGF3Uj-0ewh-_O+_qTOeOFYOM2k_daXw-vGg+xVg@mail.gmail.com> (raw)
In-Reply-To: <877dsffaq0.fsf@kyleam.com>

Good call - I see the old behavior with 2.26.0.

> $ git tag --sort -taggerdate --sort '-*committerdate'

That gives me the desired result with the annotated tag example I
gave, but if I do the same repository setup steps with lightweight
tags, then it inverts the order:

    # Lightweight tag repo
    $ git tag --merged HEAD --sort -taggerdate --sort '-*committerdate'
    v0.1.0
    v0.1.1
    v0.2.0

It looks like I can support both setups at once by using
-committerdate plus -*committerdate, though:

    # Annotated tag repo
    $ git tag --merged HEAD --sort -taggerdate --sort -committerdate
--sort '-*committerdate'
    v0.2.0
    v0.1.1
    v0.1.0

    # Lightweight tag repo
    $ git tag --merged HEAD --sort -taggerdate --sort -committerdate
--sort '-*committerdate'
    v0.2.0
    v0.1.0
    v0.1.1

It's fine for me that the order isn't exactly the same, as long as
v0.2.0 is listed first.

Thanks for the help!

MTK

On Sun, Sep 27, 2020 at 12:25 PM Kyle Meyer <kyle@kyleam.com> wrote:
>
> Matthew Timothy Kennerly writes:
>
> > Hello,
> >
> > I've run into a difference in the results for a compound tag sort
> > between 2.21.0 and 2.27.0 (I believe also applies to 2.28.0), and I'm
> > not sure if it's an intentional difference or if there's still some
> > way to achieve the old behavior with newer Git versions. For
> > reference, I'm using Windows.
>
> This sounds like it's probably related to the fix in 7c5045fc18
> (ref-filter: apply fallback refname sort only after all user sorts,
> 2020-05-03).  That was part of the 2.27.0 release.  Let's see if that
> explains what you're seeing.
>
> > I need to sort tags first by the date of the pointed commit, then by
> > the date of the tag creation when available (I understand that
> > lightweight tags don't store their creation date, so multiple
> > lightweight tags on a single commit may not sort consistently). Let me
> > give a concrete example.
> >
> > Given a repository with this setup, using annotated tags:
> >
> > git init
> > echo hi > foo.txt
> > git add .
> > git commit -m "first"
> > git tag v0.1.0 -m "A"
> > echo bye > foo.txt
> > git add .
> > git commit -m "second"
> > git tag v0.2.0 -m "B"
> > git tag v0.1.1 HEAD~1 -m "C"
> >
> > I get the desired sort results in 2.21.0:
> >
> > $ git tag --merged HEAD --sort -taggerdate --sort -committerdate
> > v0.2.0
> > v0.1.1
> > v0.1.0
>
> As far as I understand, committerdate should have no effect on annotated
> tags (i.e. it's always a tie).  So I'd guess that you're just happening
> to see the sorting you expect due the inappropriate refname fallback
> described in 7c5045fc18:
>
>   This worked correctly for a single "--sort" option, but not for multiple
>   ones. We'd break any ties in the first key with the refname and never
>   evaluate the second key at all.
>
> > However, in 2.27.0, the first listed tag is the tag that was most
> > recently created, rather than the one pointing to the newest commit:
> >
> >
> > $ git tag --merged HEAD --sort -taggerdate --sort -committerdate
> > v0.1.1
> > v0.2.0
> > v0.1.0
>
> Based on the description above, I think the second key (-taggerdate) is
> now coming into play.
>
> > If this is intentional, how can I achieve the desired sort order in
> > newer versions of Git?
>
> Try using * to refer to the commit that the tag points to:
>
>     $ git tag --sort -taggerdate --sort '-*committerdate'

  reply	other threads:[~2020-09-27 18:26 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-27 14:26 Differences in compound tag sorting between 2.27.0 and 2.21.0 Matthew Timothy Kennerly
2020-09-27 16:25 ` Kyle Meyer
2020-09-27 18:26   ` Matthew Timothy Kennerly [this message]
2020-09-27 19:55     ` Kyle Meyer
2020-09-27 20:35       ` Matthew Timothy Kennerly

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAKqNo6QCa2bGF3Uj-0ewh-_O+_qTOeOFYOM2k_daXw-vGg+xVg@mail.gmail.com \
    --to=mtkennerly@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=kyle@kyleam.com \
    --cc=peff@peff.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).