git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: John Keeping <john@keeping.me.uk>
Cc: git@vger.kernel.org, Alexey Shumkin <Alex.Crezoff@gmail.com>
Subject: Re: [PATCH] t4205: don't rely on en_US.UTF-8 locale existing
Date: Wed, 03 Jul 2013 14:41:06 -0700	[thread overview]
Message-ID: <7vr4ffcoel.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <f607decdc65b86b1759438e375ddf77fd5b91042.1372882590.git.john@keeping.me.uk> (John Keeping's message of "Wed, 3 Jul 2013 21:18:08 +0100")

John Keeping <john@keeping.me.uk> writes:

> 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?

  parent reply	other threads:[~2013-07-03 21:41 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-03 20:18 [PATCH] t4205: don't rely on en_US.UTF-8 locale existing John Keeping
2013-07-03 20:40 ` Alexey Shumkin
2013-07-03 20:47   ` Alexey Shumkin
2013-07-03 21:41 ` Junio C Hamano [this message]
2013-07-03 21:53   ` John Keeping
2013-07-03 22:27     ` Alexey Shumkin
2013-07-03 22:25   ` Alexey Shumkin

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=7vr4ffcoel.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=Alex.Crezoff@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=john@keeping.me.uk \
    /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 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 NNTP newsgroup(s).