git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] test-lib: use subshell instead of cd $new && .. && cd $old

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Aug 30, 2010, 12:00 UTC
Message-ID
<1283169642-21917-1-git-send-email-avarab@gmail.com>

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>
---
 t/test-lib.sh |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/t/test-lib.sh b/t/test-lib.sh
index dc934b8..778ba8d 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -687,14 +687,12 @@ test_when_finished () {
 test_create_repo () {
 	test "$#" = 1 ||
 	error "bug in the test script: not 1 parameter to test-create-repo"
-	owd=`pwd`
 	repo="$1"
 	mkdir -p "$repo"
-	cd "$repo" || error "Cannot setup test environment"
+	(cd "$repo" || error "Cannot setup test environment"
 	"$GIT_EXEC_PATH/git-init" "--template=$GIT_BUILD_DIR/templates/blt/" >&3 2>&4 ||
 	error "cannot run git init -- have you built things yet?"
-	mv .git/hooks .git/hooks-disabled
-	cd "$owd"
+	mv .git/hooks .git/hooks-disabled)
 }
 
 test_done () {
-- 
1.7.2.2.518.gf0ba8
Next: Jonathan Nieder
Message 1 of 6 in “test-lib: use subshell instead of cd $new && .. && cd $old”
  1. test-lib: use subshell instead of cd $new && .. && cd $oldÆvar Arnfjörð Bjarmason, Aug 30, 2010
  2. Jonathan NiederAug 30, 2010
  3. Ævar Arnfjörð BjarmasonAug 30, 2010
  4. Jonathan NiederAug 30, 2010
  5. Junio C HamanoAug 31, 2010
  6. Ævar Arnfjörð BjarmasonAug 31, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.