Re* [PATCH] t9129: fix UTF-8 locale detection
From: Junio C Hamano <hidden>
Date: 2016-06-15 22:48:54
Subsystem:
the rest · Maintainer:
Linus Torvalds
Linus Torvalds [off-list ref] writes:
Wouldn't it be easier to just make it ignore case, and do grep -qi '^en_US\.utf-?8$' instead? I'm also not entirely sure you want to make that pattern stricter - the whole problem with the old pattern was that it was too exact, so why add the beginning/end requirement?
Sorry for being late to the party... The prerequisite test is supposed to protect a real test that does this: LC_ALL=en_US.UTF-8 svn log `git svn info --url` | perl -w -e '...' and the original patch at least matches what we check with what we actually ask for from the system. I don't know if the above "svn log" test would still work if we run it under any locale with UTF-8 (I checked with ja_JP.UTF-8 and it seems to be Ok), but if it does, then a patch like this might be a better alternative. t/t9129-git-svn-i18n-commitencoding.sh | 20 +++++++++++++------- 1 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/t/t9129-git-svn-i18n-commitencoding.sh b/t/t9129-git-svn-i18n-commitencoding.sh
index b9224bd..1e9a2eb 100755
--- a/t/t9129-git-svn-i18n-commitencoding.sh
+++ b/t/t9129-git-svn-i18n-commitencoding.sh@@ -14,10 +14,22 @@ compare_git_head_with () { test_cmp current "$1" } +a_utf8_locale=$(locale -a | sed -n '/\.[uU][tT][fF]-*8$/{ + p + q +}') + +if test -n "$a_utf8_locale" +then + test_set_prereq UTF8 +else + say "UTF-8 locale not available, some tests are skipped" +fi + compare_svn_head_with () { # extract just the log message and strip out committer info. # don't use --limit here since svn 1.1.x doesn't have it, - LC_ALL=en_US.UTF-8 svn log `git svn info --url` | perl -w -e ' + LC_ALL="$a_utf8_locale" svn log `git svn info --url` | perl -w -e ' use bytes; $/ = ("-"x72) . "\n"; my @x = <STDIN>;
@@ -69,12 +81,6 @@ do ' done -if locale -a |grep -q en_US.utf8; then - test_set_prereq UTF8 -else - say "UTF-8 locale not available, test skipped" -fi - test_expect_success UTF8 'ISO-8859-1 should match UTF-8 in svn' ' ( cd ISO8859-1 &&