Making gettext poison second citizen makes it easy to forget to run
the test suite with it. This is step one to running test suite with
gettext poison by default.

The runtime cost should be small. "gcc -O2" inlines _() and
use_gettext_poison(). But even if it does not, performance should not
be impacted as _() calls are usually not on critical path. If some of
them are, we better fix there as gettext() may or may not be cheap

A new target is added to run test with poisoned gettext: test-poison

Signed-off-by: Nguyễn Thái Ngọc Duy <>
 I don't know the story behind this compile-time switch. The series [1]
 that introduces it does not say much.

 This at least makes it easier for me to run poison tests instead of
 building another binary, if I remember it. Next step could be make
 "make test" run both normal and poison modes, but I'm not sure how to
 do it nicely yet.


 Makefile  | 12 +++---------
 gettext.c | 10 ----------
 gettext.h | 12 +++++++-----
 po/README | 13 ++++---------
 4 files changed, 14 insertions(+), 33 deletions(-)

diff --git a/Makefile b/Makefile
index 6b0c961..8255fb9 100644
--- a/Makefile
+++ b/Makefile
@@ -258,11 +258,6 @@ all::
 # Define HAVE_DEV_TTY if your system can open /dev/tty to interact with the
 # user.
-# Define GETTEXT_POISON if you are debugging the choice of strings marked
-# for translation.  In a GETTEXT_POISON build, you can turn all strings marked
-# for translation into gibberish by setting the GIT_GETTEXT_POISON variable
-# (to any value) in your environment.
 # Define JSMIN to point to JavaScript minifier that functions as
 # a filter to have gitweb.js minified.
@@ -1594,9 +1589,6 @@ endif
        USE_GETTEXT_SCHEME ?= fallthrough
@@ -2497,7 +2489,6 @@ ifdef GIT_TEST_CMP_USE_COPIED_CONTEXT
        @echo GIT_TEST_CMP_USE_COPIED_CONTEXT=YesPlease >>$@
        @echo NO_GETTEXT=\''$(subst ','\'',$(subst ','\'',$(NO_GETTEXT)))'\' 
-       @echo GETTEXT_POISON=\''$(subst ','\'',$(subst 
','\'',$(GETTEXT_POISON)))'\' >>$@
        @echo GIT_PERF_REPEAT_COUNT=\''$(subst ','\'',$(subst 
','\'',$(GIT_PERF_REPEAT_COUNT)))'\' >>$@
@@ -2545,6 +2536,9 @@ export NO_SVN_TESTS
 test: all
        $(MAKE) -C t/ all
+poison-test: all
+       $(MAKE) POISON_GETTEXT=YesPlease -C t/ all
 perf: all
        $(MAKE) -C t/perf/ all
diff --git a/gettext.c b/gettext.c
index f75bca7..6aa822c 100644
--- a/gettext.c
+++ b/gettext.c
@@ -16,16 +16,6 @@
 #      endif
-int use_gettext_poison(void)
-       static int poison_requested = -1;
-       if (poison_requested == -1)
-               poison_requested = getenv("GIT_GETTEXT_POISON") ? 1 : 0;
-       return poison_requested;
 #ifndef NO_GETTEXT
 static void init_gettext_charset(const char *domain)
diff --git a/gettext.h b/gettext.h
index 57ba8bb..a77554f 100644
--- a/gettext.h
+++ b/gettext.h
@@ -36,11 +36,13 @@ static inline void git_setup_gettext(void)
-extern int use_gettext_poison(void);
-#define use_gettext_poison() 0
+static inline int use_gettext_poison(void)
+       static int poison_requested = -1;
+       if (poison_requested == -1)
+               poison_requested = getenv("GIT_GETTEXT_POISON") ? 1 : 0;
+       return poison_requested;
 static inline FORMAT_PRESERVING(1) const char *_(const char *msgid)
diff --git a/po/README b/po/README
index c1520e8..e25752b 100644
--- a/po/README
+++ b/po/README
@@ -270,16 +270,11 @@ something in the test suite might still depend on the US 
 version of the strings, e.g. to grep some error message or other
-To smoke out issues like these Git can be compiled with gettext poison
-support, at the top-level:
+To smoke out issues like these you should run the test suite with
+gettext poison support, which emits gibberish on every call to
-    make GETTEXT_POISON=YesPlease
-That'll give you a git which emits gibberish on every call to
-gettext. It's obviously not meant to be installed, but you should run
-the test suite with it:
-    cd t && prove -j 9 ./t[0-9]*.sh
+    cd t && GETTEXT_POISON=YesPlease prove -j 9 ./t[0-9]*.sh
 If tests break with it you should inspect them manually and see if
 what you're translating is sane, i.e. that you're not translating

To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to
More majordomo info at

Reply via email to