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

Re: [PATCH] t4205: don't rely on en_US.UTF-8 locale existing

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 3, 2013, 21:41 UTC
Message-ID
<7vr4ffcoel.fsf@alter.siamese.dyndns.org>
In-Reply-To
<f607decdc65b86b1759438e375ddf77fd5b91042.1372882590.git.john@keeping.me.uk>
John Keeping <john@keeping.me.uk> writes:
Show 9 quoted lines
> My system doesn't have the en_US.UTF-8 locale (or plain en_US), which
> causes t4205 to fail by counting bytes instead of UTF-8 codepoints.
>
> Instead of using sed for this, use Perl which behaves predictably
> whatever locale is in use.
>
> Signed-off-by: John Keeping <john@keeping.me.uk>
> ---
> This patch is on top of 'as/log-output-encoding-in-user-format'.

Thanks. I think Alexey is going to send incremental updates to the topic so I won't interfere by applying this patch on top of the version I have in my tree.

But I do agree that using Perl may be a workable solution.

An alternative might be not to use this cryptic 3-arg form of commit_msg at all. They are used only for these three:

	$(commit_msg "" "8" "..*$")
	$(commit_msg "" "0" ".\{11\}")
	$(commit_msg "" "4" ".\{11\}")

I somehow find them simply not readable, in order to figure out what is going on.

Just using three variables to hold what are expected would be far more portable and readable.

# "anfänglich" whatever it means. sample_utf8_part=$(printf "anf\303\244ng")

commit_msg () {
	msg="initial. ${sample_utf8_part}lich";
	if test -n "$1"
	then
		echo "$msg" | iconv -f utf-8 -t "$1"
	else
		echo "$msg"
        fi
}
And then instead of writing in the expected test output.
	$(commit_msg "" "8" "..*$")
	$(commit_msg "" "0" ".\{11\}")
	$(commit_msg "" "4" ".\{11\}")
we can just say
	initial...
        ..an${sample_utf8_part}lich
	init..lich

It is no worse than those cryptic 0, 4, 8 and 11 magic numbers we see in the test, no?

Previous: Alexey ShumkinNext: John Keeping
Message 4 of 7 in “t4205: don't rely on en_US.UTF-8 locale existing”
  1. t4205: don't rely on en_US.UTF-8 locale existingJohn Keeping, Jul 3, 2013
  2. Alexey ShumkinJul 3, 2013
  3. Alexey ShumkinJul 3, 2013
  4. Junio C HamanoJul 3, 2013
  5. John KeepingJul 3, 2013
  6. Alexey ShumkinJul 3, 2013
  7. Alexey ShumkinJul 3, 2013

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.