Skip to content

Commit a26d700

Browse files
sunshinecogitster
authored andcommitted
t3430: drop unnecessary one-shot "VAR=val shell-func" invocation
The behavior of a one-shot environment variable assignment of the form "VAR=val cmd" is unspecified according to POSIX when "cmd" is a shell function. Indeed the behavior differs between shell implementations and even different versions of the same shell. One such problematic behavior is that, with some shells, the assignment will outlive the invocation of the function, thus may potentially impact subsequent commands in the test, as well as subsequent tests. A common way to work around the problem is to wrap a subshell around the one-shot assignment, thus ensuring that the assignment is short-lived. In this test, the subshell is employed precisely for this purpose; other side-effects of the subshell, such as losing the effect of `test_tick` which is invoked by `test_commit`, are immaterial. These days, we can take advantage of `test_commit --author` to more clearly convey that the test is interested only in overriding the author of the commit. Signed-off-by: Eric Sunshine <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d19b6cd commit a26d700

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

t/t3430-rebase-merges.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -392,8 +392,7 @@ test_expect_success 'refuse to merge ancestors of HEAD' '
392392

393393
test_expect_success 'root commits' '
394394
git checkout --orphan unrelated &&
395-
(GIT_AUTHOR_NAME="Parsnip" GIT_AUTHOR_EMAIL="[email protected]" \
396-
test_commit second-root) &&
395+
test_commit --author "Parsnip <[email protected]>" second-root &&
397396
test_commit third-root &&
398397
cat >script-from-scratch <<-\EOF &&
399398
pick third-root

0 commit comments

Comments
 (0)