From 512477b175288a429aaf4071dc9fe94f17f0e4ee Mon Sep 17 00:00:00 2001 From: David Tran Date: Tue, 18 Mar 2014 18:54:05 +0000 Subject: 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 Signed-off-by: Junio C Hamano --- t/t5305-include-tag.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 't/t5305-include-tag.sh') diff --git a/t/t5305-include-tag.sh b/t/t5305-include-tag.sh index b061864a8..21517c70c 100755 --- a/t/t5305-include-tag.sh +++ b/t/t5305-include-tag.sh @@ -45,9 +45,7 @@ test_expect_success 'unpack objects' ' test_expect_success 'check unpacked result (have commit, no tag)' ' git rev-list --objects $commit >list.expect && ( - GIT_DIR=clone.git && - export GIT_DIR && - test_must_fail git cat-file -e $tag && + test_must_fail env GIT_DIR=clone.git git cat-file -e $tag && git rev-list --objects $commit ) >list.actual && test_cmp list.expect list.actual -- cgit v1.2.1