git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Duy Nguyen <pclouds@gmail.com>
Cc: Jeff King <peff@peff.net>, Git Mailing List <git@vger.kernel.org>
Subject: Re: Support customized reordering in version sort
Date: Fri, 20 Feb 2015 21:12:49 -0800	[thread overview]
Message-ID: <CAPc5daVJJcC--mwq0PfAczge3zG44ToDKP853FkyZ3x1KUfsig@mail.gmail.com> (raw)
In-Reply-To: <CACsJy8BFZ2O62f+QofSqZRoQ9BOX0SLnXHY_g93iMnyikW8H7g@mail.gmail.com>

On Fri, Feb 20, 2015 at 7:33 PM, Duy Nguyen <pclouds@gmail.com> wrote:
> On Sat, Feb 21, 2015 at 10:25 AM, Junio C Hamano <gitster@pobox.com> wrote:
>> On Fri, Feb 20, 2015 at 7:02 PM, Duy Nguyen <pclouds@gmail.com> wrote:
>>>
>>> My idea is to make it easy for the user to change the sort algorithm.
>>> And it's probably intuitive to just substitute a string with
>>> something. So if "1-rc1" is put incorrectly before "1.1" and you
>>> realize that "1.999" ought to be the last one before "2". You could
>>> tell git to internally replace "1-rc1" with "1.999".
>>>
>>> This patch does that. The user feeds substitution rules via
>>> versionsort.substitute config keys, e.g.
>>>
>>>     git config versionsort.substitute "-rc .999"
>>
>> I would say 1-rc1 comes and then 1-rc2 and then 1-rc3 ... 1-rc10 and then
>> 1-rc11 and then finally 1. It will probably be followed by 1.1-rc1, 1.1-rc2, ...
>> and then 1.1 (aka 1.1-final).
>>
>> If 1-rc1 is equated with 1.9991 because -rc is replaced with .999, how does
>> it make 1 come after 1.99911, and 1.1.9992 come before 1.1?
>>
>> I didn't read the patch text and perhaps the explanation above is the only
>> thing faulty about your message, or perhaps my reading is faulty and the
>> above describes a sound idea, but I do not see how the above makes sense.
>
> No, faulty thinking. Back to the whiteboard..

One version of vercmp() I read went like this:

 (1) Chomp the version strings into an alternate runs of digits and
non-digits. e.g. 1.2.13 becomes
      "1", ".", "2", "." and "13" while 1.2.9 becomes "1", ".", "2",
"." and "9".
 (2) Compare corresponding elements with strcmp() for runs of
non-digits, and numerically for
      runs of digits. In the above example, up to the shared "1.2."
would compare equal, and the
      final run of digits, "13" and "9" are compared numerically and
we declare that 1.2.13 comes
      later.

I think you can add a twist by introducing "optionally this can
appear" substring. When there is
such an optional substring defined, you also define if the side that
lack the optional substring
comes before or after the side that has one. For example, you declare
"[-]rc" as "optional
substring that makes the owner of such a substring sort before others"
(call it "optional negative
substring") and comparing 2.0-rc12, 2.0-rc2 and 2.0:

 - "2.0" becomes "2", ".", "0" and "2.0-rc2" becomes "2", ".", "0",
"-rc", "2". Comparing them
   from left to right, the first difference is "lack of anything (2.0
side runs out tokens)" and
   "-rc", which is marked as optional negative. Hence 2.0-rc2 sorts before 2.0

 - "2.0-rc12" and "2.0-rc2" splits into tokens similarly. The first
difference you see will be
   after you match "-rc" and "-rc", which is "12" vs "2". Comparing
them numerically, you
   know "2.0-rc12" comes later.

You can define values to optional negatives and optional positives to
express a more
elaborate sort order e.g.

  1.0-pre12 < 1.0-rc0 < 1.0 < 1.0-post1

even though "-post" does not have to be declared as optional positive.

  reply	other threads:[~2015-02-21  5:13 UTC|newest]

Thread overview: 74+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-18 19:14 [RFH] GSoC 2015 application Jeff King
2015-02-18 19:32 ` Jeff King
2015-02-24 12:01   ` Johannes Schindelin
2015-02-24 12:06     ` [msysGit] " Jeff King
2015-02-24 12:25       ` Johannes Schindelin
2015-02-24 12:28         ` [msysGit] " Jeff King
2015-02-25  9:25           ` Johannes Schindelin
2015-02-25  9:39             ` Matthieu Moy
2015-02-25 10:25             ` Matthieu Moy
2015-02-25 12:15               ` Johannes Schindelin
2015-02-24 17:32     ` Matthieu Moy
2015-02-24 18:25       ` Junio C Hamano
2015-02-24 20:33         ` Johannes Schindelin
2015-02-24 21:02           ` Junio C Hamano
2015-02-24 23:56           ` Matthieu Moy
2015-02-25  0:34             ` [msysGit] " Stefan Beller
2015-02-25  9:25               ` Michael J Gruber
2015-02-25  8:44             ` Johannes Schindelin
2015-02-25 10:04               ` [msysGit] " Christian Couder
2015-02-25 10:02             ` Duy Nguyen
2015-02-25 12:10               ` Johannes Schindelin
2015-02-18 21:54 ` Junio C Hamano
2015-02-19  5:49   ` Junio C Hamano
2015-02-19 10:32 ` Matthieu Moy
2015-02-20  2:00   ` Jeff King
2015-02-20 10:06     ` Matthieu Moy
2015-02-20 10:22       ` Dennis Kaarsemaker
2015-02-20 10:34         ` Matthieu Moy
2015-02-20 23:06       ` Eric Sunshine
2015-02-20 10:31     ` [PATCH 1/3] microprojects: tweaks after discussion with Peff Matthieu Moy
2015-02-20 10:31       ` [PATCH 2/3] GSoC ideas: git bisect fixed/unfixed Matthieu Moy
2015-02-20 10:31       ` [PATCH 3/3] idea: Be nicer to the user on tracked/untracked merge conflicts Matthieu Moy
2015-02-20  3:26 ` [RFH] GSoC 2015 application Duy Nguyen
2015-02-20  7:13   ` Jeff King
2015-02-20  8:26     ` Junio C Hamano
2015-02-21  3:02       ` Support customized reordering in version sort Duy Nguyen
2015-02-21  3:25         ` Junio C Hamano
2015-02-21  3:33           ` Duy Nguyen
2015-02-21  5:12             ` Junio C Hamano [this message]
2015-02-21  5:37               ` Junio C Hamano
2015-02-26 10:44               ` [PATCH] versionsort: support reorder prerelease suffixes Nguyễn Thái Ngọc Duy
2015-02-27 21:37                 ` Junio C Hamano
2015-03-05  1:28                   ` Junio C Hamano
2015-03-09  1:01                     ` Duy Nguyen
2015-03-10  7:52                       ` Junio C Hamano
2015-03-10  8:03                         ` Eric Sunshine
2015-03-10 10:16                     ` [PATCH] config.txt: update versioncmp.prereleaseSuffix Nguyễn Thái Ngọc Duy
2015-02-20  5:35 ` [RFH] GSoC 2015 application Michael Haggerty
2015-02-20  7:29   ` Jeff King
2015-02-20  8:06     ` Junio C Hamano
2015-02-20  9:39     ` Matthieu Moy
2015-02-20  9:48       ` Jeff King
2015-02-20 11:35         ` Jeff King
2015-02-23  8:02           ` Matthieu Moy
2015-02-23 15:36             ` Jeff King
2015-03-04 22:05       ` Philip Oakley
2015-03-04 23:55         ` Stefan Beller
2015-03-05  0:17           ` Philip Oakley
2015-03-05  0:22             ` Junio C Hamano
2015-03-05  0:32               ` Stefan Beller
2015-03-05  1:17                 ` Junio C Hamano
2015-03-05  6:19                 ` Junio C Hamano
2015-03-06 11:24                   ` Duy Nguyen
2015-03-05  0:26           ` Duy Nguyen
2015-03-05 10:28         ` Nguyễn Thái Ngọc Duy
2015-03-05 10:28           ` [PATCH 1/6] upload-pack: move shallow deepen code out of receive_needs() Nguyễn Thái Ngọc Duy
2015-03-05 10:28           ` [PATCH 2/6] upload-pack: move "shallow" sending code out of deepen() Nguyễn Thái Ngọc Duy
2015-03-05 10:28           ` [PATCH 3/6] upload-pack: remove unused variable "backup" Nguyễn Thái Ngọc Duy
2015-03-05 10:28           ` [PATCH 4/6] upload-pack: move "unshallow" sending code out of deepen() Nguyễn Thái Ngọc Duy
2015-03-05 10:28           ` [PATCH 5/6] shallow.c: implement a generic shallow boundary finder based on rev-list Nguyễn Thái Ngọc Duy
2015-03-05 10:28           ` [PATCH 6/6] upload-pack: example code to use get_shallow_commits_by_rev_list Nguyễn Thái Ngọc Duy
2015-02-26 13:10 ` [RFH] GSoC 2015 application Duy Nguyen
2015-03-04 10:31   ` Jeff King
2015-03-04 11:21     ` Duy Nguyen

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=CAPc5daVJJcC--mwq0PfAczge3zG44ToDKP853FkyZ3x1KUfsig@mail.gmail.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=pclouds@gmail.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).