Skip to content

Commit 466f94e

Browse files
committed
Merge branch 'ab/detox-gettext-tests'
Get rid of "GETTEXT_POISON" support altogether, which may or may not be controversial. * ab/detox-gettext-tests: tests: remove uses of GIT_TEST_GETTEXT_POISON=false tests: remove support for GIT_TEST_GETTEXT_POISON ci: remove GETTEXT_POISON jobs
2 parents 59ace28 + 73c01d2 commit 466f94e

22 files changed

+29
-173
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ jobs:
289289
- jobname: osx-gcc
290290
cc: gcc
291291
pool: macos-latest
292-
- jobname: GETTEXT_POISON
292+
- jobname: linux-gcc-default
293293
cc: gcc
294294
pool: ubuntu-latest
295295
env:

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ compiler:
1616

1717
matrix:
1818
include:
19-
- env: jobname=GETTEXT_POISON
19+
- env: jobname=linux-gcc-default
2020
os: linux
2121
compiler:
2222
addons:

Documentation/MyFirstContribution.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,7 @@ mention the right animal somewhere:
664664
----
665665
test_expect_success 'runs correctly with no args and good output' '
666666
git psuh >actual &&
667-
test_i18ngrep Pony actual
667+
grep Pony actual
668668
'
669669
----
670670

ci/install-dependencies.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ Documentation)
7272
test -n "$ALREADY_HAVE_ASCIIDOCTOR" ||
7373
sudo gem install --version 1.5.8 asciidoctor
7474
;;
75-
linux-gcc-4.8|GETTEXT_POISON)
75+
linux-gcc-default|linux-gcc-4.8)
7676
sudo apt-get -q update
7777
sudo apt-get -q -y install $UBUNTU_COMMON_PKGS
7878
;;

ci/lib.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,7 @@ osx-clang|osx-gcc)
220220
# Travis CI OS X
221221
export GIT_SKIP_TESTS="t9810 t9816"
222222
;;
223-
GETTEXT_POISON)
224-
export GIT_TEST_GETTEXT_POISON=true
223+
linux-gcc-default)
225224
;;
226225
Linux32)
227226
CC=gcc

config.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1155,15 +1155,6 @@ static void die_bad_number(const char *name, const char *value)
11551155
if (!value)
11561156
value = "";
11571157

1158-
if (!strcmp(name, "GIT_TEST_GETTEXT_POISON"))
1159-
/*
1160-
* We explicitly *don't* use _() here since it would
1161-
* cause an infinite loop with _() needing to call
1162-
* use_gettext_poison(). This is why marked up
1163-
* translations with N_() above.
1164-
*/
1165-
die(bad_numeric, value, name, error_type);
1166-
11671158
if (!(cf && cf->name))
11681159
die(_(bad_numeric), value, name, _(error_type));
11691160

gettext.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,6 @@ const char *get_preferred_languages(void)
6565
return NULL;
6666
}
6767

68-
int use_gettext_poison(void)
69-
{
70-
static int poison_requested = -1;
71-
if (poison_requested == -1)
72-
poison_requested = git_env_bool("GIT_TEST_GETTEXT_POISON", 0);
73-
return poison_requested;
74-
}
75-
7668
#ifndef NO_GETTEXT
7769
static int test_vsnprintf(const char *fmt, ...)
7870
{
@@ -117,8 +109,6 @@ void git_setup_gettext(void)
117109
if (!podir)
118110
podir = p = system_path(GIT_LOCALE_PATH);
119111

120-
use_gettext_poison(); /* getenv() reentrancy paranoia */
121-
122112
if (!is_directory(podir)) {
123113
free(p);
124114
return;

gettext.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,12 @@
2828

2929
#define FORMAT_PRESERVING(n) __attribute__((format_arg(n)))
3030

31-
int use_gettext_poison(void);
32-
3331
#ifndef NO_GETTEXT
3432
void git_setup_gettext(void);
3533
int gettext_width(const char *s);
3634
#else
3735
static inline void git_setup_gettext(void)
3836
{
39-
use_gettext_poison(); /* getenv() reentrancy paranoia */
4037
}
4138
static inline int gettext_width(const char *s)
4239
{
@@ -48,14 +45,12 @@ static inline FORMAT_PRESERVING(1) const char *_(const char *msgid)
4845
{
4946
if (!*msgid)
5047
return "";
51-
return use_gettext_poison() ? "# GETTEXT POISON #" : gettext(msgid);
48+
return gettext(msgid);
5249
}
5350

5451
static inline FORMAT_PRESERVING(1) FORMAT_PRESERVING(2)
5552
const char *Q_(const char *msgid, const char *plu, unsigned long n)
5653
{
57-
if (use_gettext_poison())
58-
return "# GETTEXT POISON #";
5954
return ngettext(msgid, plu, n);
6055
}
6156

git-sh-i18n.sh

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,7 @@ export TEXTDOMAINDIR
1717

1818
# First decide what scheme to use...
1919
GIT_INTERNAL_GETTEXT_SH_SCHEME=fallthrough
20-
if test -n "$GIT_TEST_GETTEXT_POISON" &&
21-
git env--helper --type=bool --default=0 --exit-code \
22-
GIT_TEST_GETTEXT_POISON
23-
then
24-
GIT_INTERNAL_GETTEXT_SH_SCHEME=poison
25-
elif test -n "@@USE_GETTEXT_SCHEME@@"
20+
if test -n "@@USE_GETTEXT_SCHEME@@"
2621
then
2722
GIT_INTERNAL_GETTEXT_SH_SCHEME="@@USE_GETTEXT_SCHEME@@"
2823
elif test -n "$GIT_INTERNAL_GETTEXT_TEST_FALLBACKS"
@@ -63,21 +58,6 @@ gettext_without_eval_gettext)
6358
)
6459
}
6560
;;
66-
poison)
67-
# Emit garbage so that tests that incorrectly rely on translatable
68-
# strings will fail.
69-
gettext () {
70-
printf "%s" "# GETTEXT POISON #"
71-
}
72-
73-
eval_gettext () {
74-
printf "%s" "# GETTEXT POISON #"
75-
}
76-
77-
eval_ngettext () {
78-
printf "%s" "# GETTEXT POISON #"
79-
}
80-
;;
8161
*)
8262
gettext () {
8363
printf "%s" "$1"

po/README

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -284,23 +284,5 @@ Perl:
284284
Testing marked strings
285285
----------------------
286286

287-
Even if you've correctly marked porcelain strings for translation
288-
something in the test suite might still depend on the US English
289-
version of the strings, e.g. to grep some error message or other
290-
output.
291-
292-
To smoke out issues like these, Git tested with a translation mode that
293-
emits gibberish on every call to gettext. To use it run the test suite
294-
with it, e.g.:
295-
296-
cd t && GIT_TEST_GETTEXT_POISON=true prove -j 9 ./t[0-9]*.sh
297-
298-
If tests break with it you should inspect them manually and see if
299-
what you're translating is sane, i.e. that you're not translating
300-
plumbing output.
301-
302-
If not you should replace calls to grep with test_i18ngrep, or
303-
test_cmp calls with test_i18ncmp. If that's not enough you can skip
304-
the whole test by making it depend on the C_LOCALE_OUTPUT
305-
prerequisite. See existing test files with this prerequisite for
306-
examples.
287+
Git's tests are run under LANG=C LC_ALL=C. So the tests do not need be
288+
changed to account for translations as they're added.

t/README

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -358,12 +358,6 @@ whether this mode is active, and e.g. skip some tests that are hard to
358358
refactor to deal with it. The "SYMLINKS" prerequisite is currently
359359
excluded as so much relies on it, but this might change in the future.
360360

361-
GIT_TEST_GETTEXT_POISON=<boolean> turns all strings marked for
362-
translation into gibberish if true. Used for spotting those tests that
363-
need to be marked with a C_LOCALE_OUTPUT prerequisite when adding more
364-
strings for translation. See "Testing marked strings" in po/README for
365-
details.
366-
367361
GIT_TEST_SPLIT_INDEX=<boolean> forces split-index mode on the whole
368362
test suite. Accept any boolean values that are accepted by git-config.
369363

t/lib-gettext.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ else
1717
. "$GIT_BUILD_DIR"/git-sh-i18n
1818
fi
1919

20-
if test_have_prereq GETTEXT && test_have_prereq C_LOCALE_OUTPUT
20+
if test_have_prereq GETTEXT
2121
then
2222
# is_IS.UTF-8 on Solaris and FreeBSD, is_IS.utf8 on Debian
2323
is_IS_locale=$(locale -a 2>/dev/null |

t/lib-rebase.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ set_fake_editor () {
2929
*/COMMIT_EDITMSG)
3030
test -z "$EXPECT_HEADER_COUNT" ||
3131
test "$EXPECT_HEADER_COUNT" = "$(sed -n '1s/^# This is a combination of \(.*\) commits\./\1/p' < "$1")" ||
32-
test "# # GETTEXT POISON #" = "$(sed -n '1p' < "$1")" ||
3332
exit
3433
test -z "$FAKE_COMMIT_MESSAGE" || echo "$FAKE_COMMIT_MESSAGE" > "$1"
3534
test -z "$FAKE_COMMIT_AMEND" || echo "$FAKE_COMMIT_AMEND" >> "$1"

t/t0017-env-helper.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,14 @@ test_expect_success 'env--helper reads config thanks to trace2' '
8686
git config -f home/cycle include.path .gitconfig &&
8787
8888
test_must_fail \
89-
env HOME="$(pwd)/home" GIT_TEST_GETTEXT_POISON=false \
89+
env HOME="$(pwd)/home" \
9090
git config -l 2>err &&
9191
grep "exceeded maximum include depth" err &&
9292
9393
test_must_fail \
94-
env HOME="$(pwd)/home" GIT_TEST_GETTEXT_POISON=true \
95-
git -C cycle env--helper --type=bool --default=0 --exit-code GIT_TEST_GETTEXT_POISON 2>err &&
96-
grep "# GETTEXT POISON #" err
94+
env HOME="$(pwd)/home" GIT_TEST_ENV_HELPER=true \
95+
git -C cycle env--helper --type=bool --default=0 --exit-code GIT_TEST_ENV_HELPER 2>err &&
96+
grep "exceeded maximum include depth" err
9797
'
9898

9999
test_done

t/t0205-gettext-poison.sh

Lines changed: 0 additions & 39 deletions
This file was deleted.

t/t1305-config-include.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -352,9 +352,7 @@ test_expect_success 'include cycles are detected' '
352352
git init --bare cycle &&
353353
git -C cycle config include.path cycle &&
354354
git config -f cycle/cycle include.path config &&
355-
test_must_fail \
356-
env GIT_TEST_GETTEXT_POISON=false \
357-
git -C cycle config --get-all test.value 2>stderr &&
355+
test_must_fail git -C cycle config --get-all test.value 2>stderr &&
358356
grep "exceeded maximum include depth" stderr
359357
'
360358

t/t3406-rebase-message.sh

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,6 @@ test_expect_success 'rebase -n overrides config rebase.stat config' '
6767
! grep "^ fileX | *1 +$" diffstat.txt
6868
'
6969

70-
# Output to stderr:
71-
#
72-
# "Does not point to a valid commit: invalid-ref"
73-
#
74-
# NEEDSWORK: This "grep" is fine in real non-C locales, but
75-
# GIT_TEST_GETTEXT_POISON poisons the refname along with the enclosing
76-
# error message.
7770
test_expect_success 'rebase --onto outputs the invalid ref' '
7871
test_must_fail git rebase --onto invalid-ref HEAD HEAD 2>err &&
7972
test_i18ngrep "invalid-ref" err

t/t5411/common-functions.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,8 @@ create_commits_in () {
3636
# without having to worry about future changes of the commit ID and spaces
3737
# of the output. Single quotes are replaced with double quotes, because
3838
# it is boring to prepare unquoted single quotes in expect text. We also
39-
# remove some locale error messages, which break test if we turn on
40-
# `GIT_TEST_GETTEXT_POISON=true` in order to test unintentional translations
41-
# on plumbing commands.
39+
# remove some locale error messages. The emitted human-readable errors are
40+
# redundant to the more machine-readable output the tests already assert.
4241
make_user_friendly_and_stable_output () {
4342
sed \
4443
-e "s/ *\$//" \

t/t7201-co.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ test_expect_success 'checkout to detach HEAD' '
248248
rev=$(git rev-parse --short renamer^) &&
249249
git checkout -f renamer &&
250250
git clean -f &&
251-
GIT_TEST_GETTEXT_POISON=false git checkout renamer^ 2>messages &&
251+
git checkout renamer^ 2>messages &&
252252
grep "HEAD is now at $rev" messages &&
253253
test_line_count -gt 1 messages &&
254254
H=$(git rev-parse --verify HEAD) &&

t/t9902-completion.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2366,7 +2366,6 @@ test_expect_success 'sourcing the completion script clears cached commands' '
23662366
'
23672367

23682368
test_expect_success 'sourcing the completion script clears cached merge strategies' '
2369-
GIT_TEST_GETTEXT_POISON=false &&
23702369
__git_compute_merge_strategies &&
23712370
verbose test -n "$__git_merge_strategies" &&
23722371
. "$GIT_BUILD_DIR/contrib/completion/git-completion.bash" &&

t/test-lib-functions.sh

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,19 +1016,16 @@ test_cmp_bin () {
10161016
cmp "$@"
10171017
}
10181018

1019-
# Use this instead of test_cmp to compare files that contain expected and
1020-
# actual output from git commands that can be translated. When running
1021-
# under GIT_TEST_GETTEXT_POISON this pretends that the command produced expected
1022-
# results.
1019+
# Wrapper for test_cmp which used to be used for
1020+
# GIT_TEST_GETTEXT_POISON=false. Only here as a shim for other
1021+
# in-flight changes. Should not be used and will be removed soon.
10231022
test_i18ncmp () {
1024-
! test_have_prereq C_LOCALE_OUTPUT || test_cmp "$@"
1023+
test_cmp "$@"
10251024
}
10261025

1027-
# Use this instead of "grep expected-string actual" to see if the
1028-
# output from a git command that can be translated either contains an
1029-
# expected string, or does not contain an unwanted one. When running
1030-
# under GIT_TEST_GETTEXT_POISON this pretends that the command produced expected
1031-
# results.
1026+
# Wrapper for grep which used to be used for
1027+
# GIT_TEST_GETTEXT_POISON=false. Only here as a shim for other
1028+
# in-flight changes. Should not be used and will be removed soon.
10321029
test_i18ngrep () {
10331030
eval "last_arg=\${$#}"
10341031

@@ -1041,12 +1038,6 @@ test_i18ngrep () {
10411038
BUG "too few parameters to test_i18ngrep"
10421039
fi
10431040

1044-
if test_have_prereq !C_LOCALE_OUTPUT
1045-
then
1046-
# pretend success
1047-
return 0
1048-
fi
1049-
10501041
if test "x!" = "x$1"
10511042
then
10521043
shift

t/test-lib.sh

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -404,15 +404,6 @@ TZ=UTC
404404
export LANG LC_ALL PAGER TZ
405405
EDITOR=:
406406

407-
# GIT_TEST_GETTEXT_POISON should not influence git commands executed
408-
# during initialization of test-lib and the test repo. Back it up,
409-
# unset and then restore after initialization is finished.
410-
if test -n "$GIT_TEST_GETTEXT_POISON"
411-
then
412-
GIT_TEST_GETTEXT_POISON_ORIG=$GIT_TEST_GETTEXT_POISON
413-
unset GIT_TEST_GETTEXT_POISON
414-
fi
415-
416407
# A call to "unset" with no arguments causes at least Solaris 10
417408
# /usr/xpg4/bin/sh and /bin/ksh to bail out. So keep the unsets
418409
# deriving from the command substitution clustered with the other
@@ -1528,16 +1519,10 @@ test -n "$USE_LIBPCRE2" && test_set_prereq PCRE
15281519
test -n "$USE_LIBPCRE2" && test_set_prereq LIBPCRE2
15291520
test -z "$NO_GETTEXT" && test_set_prereq GETTEXT
15301521

1531-
if test -n "$GIT_TEST_GETTEXT_POISON_ORIG"
1532-
then
1533-
GIT_TEST_GETTEXT_POISON=$GIT_TEST_GETTEXT_POISON_ORIG
1534-
export GIT_TEST_GETTEXT_POISON
1535-
unset GIT_TEST_GETTEXT_POISON_ORIG
1536-
fi
1537-
1538-
test_lazy_prereq C_LOCALE_OUTPUT '
1539-
! test_bool_env GIT_TEST_GETTEXT_POISON false
1540-
'
1522+
# Used to be used for GIT_TEST_GETTEXT_POISON=false. Only here as a
1523+
# shim for other in-flight changes. Should not be used and will be
1524+
# removed soon.
1525+
test_set_prereq C_LOCALE_OUTPUT
15411526

15421527
if test -z "$GIT_TEST_CHECK_CACHE_TREE"
15431528
then

0 commit comments

Comments
 (0)