git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] for-each-ref: delay parsing of --sort=<atom> options
Date: Wed, 20 Oct 2021 14:32:21 -0700	[thread overview]
Message-ID: <xmqqpmrzo00q.fsf@gitster.g> (raw)
In-Reply-To: <YXCAuAwZenM6EPug@coredump.intra.peff.net> (Jeff King's message of "Wed, 20 Oct 2021 16:48:56 -0400")

Jeff King <peff@peff.net> writes:

> Yeah, I faced something similar with 7c5045fc18 (ref-filter: apply
> fallback refname sort only after all user sorts, 2020-05-03). I suspect
> you could use the same keys as those tests, though I am OK if we simply
> leave it as a quietly-fixed bug.

Ah, I guess I can cheat and add a new test after these.

If --no-sort weren't taking effect, the expected outcome would be
the asme as the previous step this copied from, but with --no-sort
clearing the sort keys, we sort by taggerdate and then tiebreak with
the refname, and taggeremail does not get into the picture (other
than being repeated at the end of the refname).

 t/t6300-for-each-ref.sh | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git c/t/t6300-for-each-ref.sh w/t/t6300-for-each-ref.sh
index 83921502a4..9f2c706c12 100755
--- c/t/t6300-for-each-ref.sh
+++ w/t/t6300-for-each-ref.sh
@@ -1024,6 +1024,27 @@ test_expect_success 'equivalent sorts fall back on refname' '
 	test_cmp expected actual
 '
 
+test_expect_success '--no-sort cancels the previous sort keys' '
+	cat >expected <<-\EOF &&
+	100000 <user1@example.com> refs/tags/multi-ref1-100000-user1
+	100000 <user2@example.com> refs/tags/multi-ref1-100000-user2
+	100000 <user1@example.com> refs/tags/multi-ref2-100000-user1
+	100000 <user2@example.com> refs/tags/multi-ref2-100000-user2
+	200000 <user1@example.com> refs/tags/multi-ref1-200000-user1
+	200000 <user2@example.com> refs/tags/multi-ref1-200000-user2
+	200000 <user1@example.com> refs/tags/multi-ref2-200000-user1
+	200000 <user2@example.com> refs/tags/multi-ref2-200000-user2
+	EOF
+	git for-each-ref \
+		--format="%(taggerdate:unix) %(taggeremail) %(refname)" \
+		--sort=-refname \
+		--sort=taggeremail \
+		--no-sort \
+		--sort=taggerdate \
+		"refs/tags/multi-*" >actual &&
+	test_cmp expected actual
+'
+
 test_expect_success 'do not dereference NULL upon %(HEAD) on unborn branch' '
 	test_when_finished "git checkout main" &&
 	git for-each-ref --format="%(HEAD) %(refname:short)" refs/heads/ >actual &&

  reply	other threads:[~2021-10-20 21:32 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-18 18:32 [PATCH] for-each-ref: delay parsing of --sort=<atom> options Junio C Hamano
2021-10-19 22:18 ` Jeff King
2021-10-20  2:20   ` Jeff King
2021-10-20 12:30     ` Ævar Arnfjörð Bjarmason
2021-10-20 13:24       ` [RFC PATCH v2 0/4] for-each-ref: delay parsing of --sort=<atom> options + linux-leaks fixes Ævar Arnfjörð Bjarmason
2021-10-20 13:24         ` [RFC PATCH v2 1/4] tag: use a "goto cleanup" pattern, leak less memory Ævar Arnfjörð Bjarmason
2021-10-20 14:37           ` Junio C Hamano
2021-10-20 13:24         ` [RFC PATCH v2 2/4] ref-filter API user: add and use a ref_sorting_release() Ævar Arnfjörð Bjarmason
2021-10-20 14:39           ` Junio C Hamano
2021-10-20 13:24         ` [RFC PATCH v2 3/4] for-each-ref: delay parsing of --sort=<atom> options Ævar Arnfjörð Bjarmason
2021-10-20 13:24         ` [RFC PATCH v2 4/4] branch: use ref_sorting_release() Ævar Arnfjörð Bjarmason
2021-10-20 14:43         ` [RFC PATCH v2 0/4] for-each-ref: delay parsing of --sort=<atom> options + linux-leaks fixes Junio C Hamano
2021-10-20 18:27         ` [PATCH 0/3] ref-filter: add a ref_sorting_release() Ævar Arnfjörð Bjarmason
2021-10-20 18:27           ` [PATCH 1/3] tag: use a "goto cleanup" pattern, leak less memory Ævar Arnfjörð Bjarmason
2021-10-20 18:27           ` [PATCH 2/3] ref-filter API user: add and use a ref_sorting_release() Ævar Arnfjörð Bjarmason
2021-10-20 18:27           ` [PATCH 3/3] branch: use ref_sorting_release() Ævar Arnfjörð Bjarmason
2021-10-20 13:58   ` [PATCH] for-each-ref: delay parsing of --sort=<atom> options Junio C Hamano
2021-10-20 20:48     ` Jeff King
2021-10-20 21:32       ` Junio C Hamano [this message]
2021-10-21 14:54         ` Jeff King

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=xmqqpmrzo00q.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --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).