summaryrefslogtreecommitdiff
path: root/t/t3701-add-interactive.sh
diff options
context:
space:
mode:
authorDenton Liu <liu.denton@gmail.com>2020-07-07 06:04:34 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-07-07 20:07:26 (GMT)
commit4d9e7c153df9b411d782759bbc8def1c8458f4a6 (patch)
treead4115c702dad32602545865d45d4cb8d4dc3700 /t/t3701-add-interactive.sh
parent4a0fcf9f760c9774be77f51e1e88a7499b53d2e2 (diff)
downloadgit-4d9e7c153df9b411d782759bbc8def1c8458f4a6.zip
git-4d9e7c153df9b411d782759bbc8def1c8458f4a6.tar.gz
git-4d9e7c153df9b411d782759bbc8def1c8458f4a6.tar.bz2
t3701: stop using `env` in force_color()
In a future patch, we plan on making the test_must_fail()-family of functions accept only git commands. Even though force_color() wraps an invocation of `env git`, test_must_fail() will not be able to figure this out since it will assume that force_color() is just some random function which is disallowed. Instead of using `env` in force_color() (which does not support shell functions), export the environment variables in a subshell. Write the invocation as `force_color test_must_fail git ...` since shell functions are now supported. Signed-off-by: Denton Liu <liu.denton@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t3701-add-interactive.sh')
-rwxr-xr-xt/t3701-add-interactive.sh13
1 files changed, 11 insertions, 2 deletions
diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh
index 49decba..fb73a84 100755
--- a/t/t3701-add-interactive.sh
+++ b/t/t3701-add-interactive.sh
@@ -31,7 +31,16 @@ diff_cmp () {
# indicates a dumb terminal, so we set that variable, too.
force_color () {
- env GIT_PAGER_IN_USE=true TERM=vt100 "$@"
+ # The first element of $@ may be a shell function, as a result POSIX
+ # does not guarantee that "one-shot assignment" will not persist after
+ # the function call. Thus, we prevent these variables from escaping
+ # this function's context with this subshell.
+ (
+ GIT_PAGER_IN_USE=true &&
+ TERM=vt100 &&
+ export GIT_PAGER_IN_USE TERM &&
+ "$@"
+ )
}
test_expect_success 'setup (initial)' '
@@ -604,7 +613,7 @@ test_expect_success 'detect bogus diffFilter output' '
echo content >test &&
test_config interactive.diffFilter "sed 1d" &&
printf y >y &&
- test_must_fail force_color git add -p <y
+ force_color test_must_fail git add -p <y
'
test_expect_success 'diff.algorithm is passed to `git diff-files`' '