All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: <rsbecker@nexbridge.com>
Cc: "'brian m. carlson'" <sandals@crustytoothpaste.net>,
	 "'Thaina Yu'" <thainayu@gmail.com>,  <git@vger.kernel.org>
Subject: Re: [feature request] Is it possible to have git tag can be sorted and filtered by semver?
Date: Mon, 22 Jul 2024 16:40:36 -0700	[thread overview]
Message-ID: <xmqqy15t6lmz.fsf@gitster.g> (raw)
In-Reply-To: <031701dadc8c$db6d3370$92479a50$@nexbridge.com> (rsbecker@nexbridge.com's message of "Mon, 22 Jul 2024 19:14:03 -0400")

<rsbecker@nexbridge.com> writes:

> Currently, tags would be sorted as follows (simple example):
> 1.10.0
> 1.2.0
> 1.9.1
>
> With semver, the tags would be:
> 1.2.0
> 1.9.1
> 1.10.0
>
> My take is that this, if implemented, would need to be more general, and include prefix and suffix handling, so:
> v1.2.0
> v1.9.0
> v1.10.0

Without implemeting anything, wouldn't "--sort=version:refname"
suggested by Brian work just fine?

In the git repository:

    $ git tag --sort=version:refname | grep -e 'v2\.[0-9][0-9]*\.[0-9][0-9]*$'
    v2.0.0
    ...
    v2.0.5
    v2.1.0
    v2.1.1
    v2.1.2
    v2.1.3
    v2.1.4
    v2.2.0
    ...
    v2.9.0
    ...
    v2.9.5
    v2.10.0
    v2.10.1
    v2.10.2
    v2.10.3
    v2.10.4
    v2.10.5
    v2.11.0
    ...
    v2.45.1
    v2.45.2

sorting 2.1.x series a lot earlier than 2.10.x series that is sorted
after 2.9.x series.

Isn't it exactly what the original requester wants to see?

One mechanism I find it lacking is a mechanism to tell the tool that
-preW in X.Y.Z-preW is a suffix that signals that X.Y.Z-preW comes
before X.Y.Z, while -postW in X.Y.Z-postW is a suffix that signals
that X.Y.Z-postW comes after X.Y.Z.  Using such a mechanism, we
could say v2.1.0-rc0 comes before v2.1.0-rc1, which in turn comes
before v2.1.0-rc2, which in turn comes before v2.1.0 proper.

But other than the ordering of the final release and -rcX, I think
"--sort=version:refname" does the right thing already.


  reply	other threads:[~2024-07-22 23:40 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-22 16:58 [feature request] Is it possible to have git tag can be sorted and filtered by semver? Thaina Yu
2024-07-22 21:30 ` brian m. carlson
2024-07-22 23:14   ` rsbecker
2024-07-22 23:40     ` Junio C Hamano [this message]
2024-07-23  0:05     ` brian m. carlson
2024-07-23  3:06       ` Thaina Yu

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

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

  git send-email \
    --in-reply-to=xmqqy15t6lmz.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=rsbecker@nexbridge.com \
    --cc=sandals@crustytoothpaste.net \
    --cc=thainayu@gmail.com \
    /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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.