]> git.ipfire.org Git - thirdparty/git.git/blobdiff - t/t3701-add-interactive.sh
Merge branch 'jk/add-i-fixes'
[thirdparty/git.git] / t / t3701-add-interactive.sh
index 1a24db7fcfe8744fcb802fed5d0433a81460e0d4..1590cf6b98fbe2a19379feee5e39336b45536939 100755 (executable)
@@ -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)' '
@@ -612,7 +621,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`' '