From: Eric Sunshine Date: Tue, 10 May 2016 05:20:51 GMT Subject: [PATCH 2/6] t1500: reduce dependence upon global state Message-ID: <20160510052055.32924-3-sunshine@sunshineco.com> In-Reply-To: <20160510052055.32924-1-sunshine@sunshineco.com> This script pollutes its global state by changing its working directory and capturing that state via $(pwd) in the GIT_CONFIG environment variable. This makes it difficult to modernize the script since tests ideally should be self-contained and not rely upon such transient global state. With the ultimate goal of eliminating working directory changes, as a first step, avoid capturing global state by instead taking advantage of $ROOT which captured $(pwd) prior to any working directory changes, and compose GIT_CONFIG from it and local knowledge of the working directory. Subsequent patches will eliminate changes of working directory and drop GIT_CONFIG altogether. Signed-off-by: Eric Sunshine --- t/t1500-rev-parse.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/t/t1500-rev-parse.sh b/t/t1500-rev-parse.sh index 03f22fe..3d79568 100755 --- a/t/t1500-rev-parse.sh +++ b/t/t1500-rev-parse.sh @@ -49,7 +49,7 @@ test_rev_parse 'core.bare undefined' false false true mkdir work || exit 1 cd work || exit 1 GIT_DIR=../.git -GIT_CONFIG="$(pwd)"/../.git/config +GIT_CONFIG="$ROOT/work/../.git/config" export GIT_DIR GIT_CONFIG git config core.bare false @@ -63,7 +63,7 @@ test_rev_parse 'GIT_DIR=../.git, core.bare undefined' false false true '' mv ../.git ../repo.git || exit 1 GIT_DIR=../repo.git -GIT_CONFIG="$(pwd)"/../repo.git/config +GIT_CONFIG="$ROOT/work/../repo.git/config" git config core.bare false test_rev_parse 'GIT_DIR=../repo.git, core.bare = false' false false true '' -- 2.8.2.530.g51d527d