]> git.ipfire.org Git - thirdparty/git.git/commit
t3430: drop unnecessary one-shot "VAR=val shell-func" invocation
authorEric Sunshine <sunshine@sunshineco.com>
Sat, 27 Jul 2024 05:35:05 +0000 (01:35 -0400)
committerJunio C Hamano <gitster@pobox.com>
Sat, 27 Jul 2024 05:49:40 +0000 (22:49 -0700)
commita26d7004f73abb1005acd98114faec3aa75f5090
tree950051188989582cdd9df847ceb82944fb561ef2
parentd19b6cd2dd72dc811f19df4b32c7ed223256c3ee
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 <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t3430-rebase-merges.sh