]> git.ipfire.org Git - thirdparty/git.git/commit - t/t3200-branch.sh
tests: use "env" to run commands with temporary env-var settings
authorDavid Tran <unsignedzero@gmail.com>
Tue, 18 Mar 2014 18:54:05 +0000 (18:54 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 19 Mar 2014 19:55:57 +0000 (12:55 -0700)
commit512477b175288a429aaf4071dc9fe94f17f0e4ee
tree972f6fa1820571ca7bd2e257f020dd1e1caacb7e
parent5f95c9f850b19b368c43ae399cc831b17a26a5ac
tests: use "env" to run commands with temporary env-var settings

Ordinarily, we would say "VAR=VAL command" to execute a tested
command with environment variable(s) set only for that command.
This however does not work if 'command' is a shell function (most
notably 'test_must_fail'); the result of the assignment is retained
and affects later commands.

To avoid this, we used to assign and export environment variables
and run such a test in a subshell, like so:

        (
                VAR=VAL && export VAR &&
                test_must_fail git command to be tested
        )

But with "env" utility, we should be able to say:

        test_must_fail env VAR=VAL git command to be tested

which is much shorter and easier to read.

Signed-off-by: David Tran <unsignedzero@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 files changed:
t/t1300-repo-config.sh
t/t1510-repo-setup.sh
t/t3200-branch.sh
t/t3301-notes.sh
t/t3404-rebase-interactive.sh
t/t3413-rebase-hook.sh
t/t4014-format-patch.sh
t/t5305-include-tag.sh
t/t5602-clone-remote-exec.sh
t/t5801-remote-helpers.sh
t/t6006-rev-list-format.sh
t/t7006-pager.sh