git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 1/2] ref-filter: apply --ignore-case to all sorting keys

From
Junio C Hamano <gitster@pobox.com>
Date
May 4, 2020, 21:00 UTC
Message-ID
<xmqqh7wvfmar.fsf@gitster.c.googlers.com>
In-Reply-To
<20200503091157.GA170902@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 13 quoted lines
> would sort the primary key (taggername) case-insensitively, but sort the
> refname case-sensitively. We have two options here:
>
>   - teach callers to set ignore_case on the whole list
>
>   - replace the ref_sorting list with a struct that contains both the
>     list of sorting keys, as well as options that apply to _all_
>     keys
>
> I went with the first one here, as it gives more flexibility if we later
> want to let the users set the flag per-key (presumably through some
> special syntax when defining the key; for now it's all or nothing
> through --ignore-case).
A good design decision I would fully support.
> +test_expect_success 'for-each-ref --ignore-case works on multiple sort keys' '
> +	# name refs numerically to avoid case-insensitive filesystem conflicts

Very considerate. If I were writing these nested loops, I am sure I would have used "tag-$email-$subject" to be cute.

Queued.  Thanks.
Show 39 quoted lines
> +	nr=0 &&
> +	for email in a A b B
> +	do
> +		for subject in a A b B
> +		do
> +			GIT_COMMITTER_EMAIL="$email@example.com" \
> +			git tag -m "tag $subject" icase-$(printf %02d $nr) &&
> +			nr=$((nr+1))||
> +			return 1
> +		done
> +	done &&
> +	git for-each-ref --ignore-case \
> +		--format="%(taggeremail) %(subject) %(refname)" \
> +		--sort=refname \
> +		--sort=subject \
> +		--sort=taggeremail \
> +		refs/tags/icase-* >actual &&
> +	cat >expect <<-\EOF &&
> +	<a@example.com> tag a refs/tags/icase-00
> +	<a@example.com> tag A refs/tags/icase-01
> +	<A@example.com> tag a refs/tags/icase-04
> +	<A@example.com> tag A refs/tags/icase-05
> +	<a@example.com> tag b refs/tags/icase-02
> +	<a@example.com> tag B refs/tags/icase-03
> +	<A@example.com> tag b refs/tags/icase-06
> +	<A@example.com> tag B refs/tags/icase-07
> +	<b@example.com> tag a refs/tags/icase-08
> +	<b@example.com> tag A refs/tags/icase-09
> +	<B@example.com> tag a refs/tags/icase-12
> +	<B@example.com> tag A refs/tags/icase-13
> +	<b@example.com> tag b refs/tags/icase-10
> +	<b@example.com> tag B refs/tags/icase-11
> +	<B@example.com> tag b refs/tags/icase-14
> +	<B@example.com> tag B refs/tags/icase-15
> +	EOF
> +	test_cmp expect actual
> +'
> +
>  test_done
Previous: Junio C HamanoNext: Jeff King
Message 15 of 21 in “git for-each-ref - sorting by multiple keys”
  1. climeMay 2, 2020
  2. Jeff KingMay 3, 2020
  3. 1/2 ref-filter: apply --ignore-case to all sorting keysJeff King, May 3, 2020
  4. Danh DoanMay 3, 2020
  5. Jeff KingMay 4, 2020
  6. Junio C HamanoMay 4, 2020
  7. CodingGuidelines: drop arithmetic expansion advice to use "$x"Jeff King, May 4, 2020
  8. Carlo Marcelo Arenas BelónMay 4, 2020
  9. Jeff KingMay 4, 2020
  10. Junio C HamanoMay 4, 2020
  11. Danh DoanMay 4, 2020
  12. Junio C HamanoMay 5, 2020
  13. Jeff KingMay 5, 2020
  14. Junio C HamanoMay 5, 2020
  15. Junio C HamanoMay 4, 2020
  16. Jeff KingMay 5, 2020
  17. Taylor BlauMay 5, 2020
  18. 2/2 ref-filter: apply fallback refname sort only after all user sortsJeff King, May 3, 2020
  19. Junio C HamanoMay 4, 2020
  20. Taylor BlauMay 5, 2020
  21. climeMay 3, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.