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.

0 commit comments

Comments
 (0)