Skip to content

Commit 0d314ce

Browse files
avargitster
authored andcommitted
test-lib: use subshell instead of cd $new && .. && cd $old
Change the test_create_repo code added in v1.2.2~6 to use a subshell instead of keeping track of the old working directory and cd-ing back when it's done. Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 07431fc commit 0d314ce

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

t/test-lib.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -650,14 +650,14 @@ test_when_finished () {
650650
test_create_repo () {
651651
test "$#" = 1 ||
652652
error "bug in the test script: not 1 parameter to test-create-repo"
653-
owd=`pwd`
654653
repo="$1"
655654
mkdir -p "$repo"
656-
cd "$repo" || error "Cannot setup test environment"
657-
"$GIT_EXEC_PATH/git-init" "--template=$GIT_BUILD_DIR/templates/blt/" >&3 2>&4 ||
658-
error "cannot run git init -- have you built things yet?"
659-
mv .git/hooks .git/hooks-disabled
660-
cd "$owd"
655+
(
656+
cd "$repo" || error "Cannot setup test environment"
657+
"$GIT_EXEC_PATH/git-init" "--template=$GIT_BUILD_DIR/templates/blt/" >&3 2>&4 ||
658+
error "cannot run git init -- have you built things yet?"
659+
mv .git/hooks .git/hooks-disabled
660+
) || exit
661661
}
662662

663663
test_done () {

0 commit comments

Comments
 (0)