@matheusbsbs / matheus-bagliano / commits / 0d314ce834
Fork 0

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 <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ævar Arnfjörð Bjarmason committed Aug 30, 2010 at 12:00 UTC 0d314ce834df9ad6bb5d6e9583c38aefd047fc9b
1 file changed +6 -6
t/test-lib.sh
+6 -6
@@ -650,14 +650,14 @@ test_when_finished () {
650 test_create_repo () {
651 test "$#" = 1 ||
652 error "bug in the test script: not 1 parameter to test-create-repo"
653 - owd=`pwd`
653 repo="$1"
654 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
661 }
662
663 test_done () {