[PATCH 1/8] test-lib.sh: preserve GIT_GETTEXT_POISON from the environment

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Setting GIT_GETTEXT_POISON can be useful when testing translated
builds.

However, preserving its value from the environment is not as simple as
adding it to the list of GIT_* variables that should not be scrubbed
from the environment:

  - GIT_GETTEXT_POISON should not influence git commands executed
    during initialization of test-lib and the test repo.

    Save its value before it gets scrubbed from the environment, so it
    will be unset for the duration of the initialization, and restore
    its original value after initialization is finished.

  - When testing a GETTEXT_POISON build, 'test-lib.sh' always sets
    GIT_GETTEXT_POISON to 'YesPlease'.  This was fine while all that
    mattered was whether it's set or not.  However, the following
    patches will introduce meaningful values (e.g. "set but empty" to
    disable poisoning even in a GETTEXT_POISON build), so only set it
    like this if GIT_GETTEXT_POISON was not set in the environment.

Signed-off-by: SZEDER Gábor <szeder.dev@xxxxxxxxx>
---
 t/test-lib.sh | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/t/test-lib.sh b/t/test-lib.sh
index ea2bbaaa7a..282c05110d 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -95,6 +95,16 @@ PAGER=cat
 TZ=UTC
 export LANG LC_ALL PAGER TZ
 EDITOR=:
+
+# GIT_GETTEXT_POISON should not influence git commands executed during
+# initialization of test-lib and the test repo.
+# Back it up, unset and then restore after initialization is finished.
+if test -n "${GIT_GETTEXT_POISON-set}"
+then
+	git_gettext_poison_backup=$GIT_GETTEXT_POISON
+	unset GIT_GETTEXT_POISON
+fi
+
 # A call to "unset" with no arguments causes at least Solaris 10
 # /usr/xpg4/bin/sh and /bin/ksh to bail out.  So keep the unsets
 # deriving from the command substitution clustered with the other
@@ -1073,7 +1083,12 @@ test -z "$NO_GETTEXT" && test_set_prereq GETTEXT
 # Can we rely on git's output in the C locale?
 if test -n "$GETTEXT_POISON"
 then
-	GIT_GETTEXT_POISON=YesPlease
+	if test -n "${git_gettext_poison_backup-set}"
+	then
+		GIT_GETTEXT_POISON=$git_gettext_poison_backup
+	else
+		GIT_GETTEXT_POISON=YesPlease
+	fi
 	export GIT_GETTEXT_POISON
 	test_set_prereq GETTEXT_POISON
 else
-- 
2.19.1.681.g6bd79da3f5




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux