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

[PATCH 11/12] t0001: drop useless subshells

From
Jeff King <peff@peff.net>
Date
Mar 20, 2014, 23:21 UTC
Message-ID
<20140320232125.GK8479@sigill.intra.peff.net>
In-Reply-To
<20140320231159.GA7774@sigill.intra.peff.net>

Many tests use subshells, but don't actually change the shell environment. They were probably cargo-culted from earlier tests which did need subshells. Drop the useless ones.

Signed-off-by: Jeff King <peff@peff.net>
---
These ones should produce no behavior change at all; they're purely
mechanical "(foo && bar)" to "foo && bar" (though of course I did them
by hand, because you need to know that "foo" and "bar" do not affect the
environment).
 t/t0001-init.sh | 61 +++++++++++++++++++++------------------------------------
 1 file changed, 22 insertions(+), 39 deletions(-)
diff --git a/t/t0001-init.sh b/t/t0001-init.sh
index 4560bba..55a68bc 100755
--- a/t/t0001-init.sh
+++ b/t/t0001-init.sh
@@ -106,11 +106,8 @@ test_expect_success 'plain bare with GIT_WORK_TREE' '
 '
 
 test_expect_success 'GIT_DIR bare' '
-
-	(
-		mkdir git-dir-bare.git &&
-		GIT_DIR=git-dir-bare.git git init
-	) &&
+	mkdir git-dir-bare.git &&
+	GIT_DIR=git-dir-bare.git git init &&
 	check_config git-dir-bare.git true unset
 '
 
@@ -242,36 +239,28 @@ test_expect_success 'init rejects insanely long --template' '
 
 test_expect_success 'init creates a new directory' '
 	rm -fr newdir &&
-	(
-		git init newdir &&
-		test_path_is_dir newdir/.git/refs
-	)
+	git init newdir &&
+	test_path_is_dir newdir/.git/refs
 '
 
 test_expect_success 'init creates a new bare directory' '
 	rm -fr newdir &&
-	(
-		git init --bare newdir &&
-		test_path_is_dir newdir/refs
-	)
+	git init --bare newdir &&
+	test_path_is_dir newdir/refs
 '
 
 test_expect_success 'init recreates a directory' '
 	rm -fr newdir &&
-	(
-		mkdir newdir &&
-		git init newdir &&
-		test_path_is_dir newdir/.git/refs
-	)
+	mkdir newdir &&
+	git init newdir &&
+	test_path_is_dir newdir/.git/refs
 '
 
 test_expect_success 'init recreates a new bare directory' '
 	rm -fr newdir &&
-	(
-		mkdir newdir &&
-		git init --bare newdir &&
-		test_path_is_dir newdir/refs
-	)
+	mkdir newdir &&
+	git init --bare newdir &&
+	test_path_is_dir newdir/refs
 '
 
 test_expect_success 'init creates a new deep directory' '
@@ -297,30 +286,24 @@ test_expect_success POSIXPERM 'init creates a new deep directory (umask vs. shar
 
 test_expect_success 'init notices EEXIST (1)' '
 	rm -fr newdir &&
-	(
-		>newdir &&
-		test_must_fail git init newdir &&
-		test_path_is_file newdir
-	)
+	>newdir &&
+	test_must_fail git init newdir &&
+	test_path_is_file newdir
 '
 
 test_expect_success 'init notices EEXIST (2)' '
 	rm -fr newdir &&
-	(
-		mkdir newdir &&
-		>newdir/a
-		test_must_fail git init newdir/a/b &&
-		test_path_is_file newdir/a
-	)
+	mkdir newdir &&
+	>newdir/a
+	test_must_fail git init newdir/a/b &&
+	test_path_is_file newdir/a
 '
 
 test_expect_success POSIXPERM,SANITY 'init notices EPERM' '
 	rm -fr newdir &&
-	(
-		mkdir newdir &&
-		chmod -w newdir &&
-		test_must_fail git init newdir/a/b
-	)
+	mkdir newdir &&
+	chmod -w newdir &&
+	test_must_fail git init newdir/a/b
 '
 
 test_expect_success 'init creates a new bare directory with global --bare' '
-- 
1.9.0.560.g01ceb46
Previous: Jeff KingNext: Eric Sunshine
Message 24 of 28 in “tests: set temp variables using 'env' in test function instead of subshell”
  1. tests: set temp variables using 'env' in test function instead of subshellDavid Tran, Mar 18, 2014
  2. Junio C HamanoMar 18, 2014
  3. Jeff KingMar 18, 2014
  4. Junio C HamanoMar 18, 2014
  5. Jeff KingMar 18, 2014
  6. Junio C HamanoMar 19, 2014
  7. 0/12 GIT_CONFIG in the test suiteJeff King, Mar 20, 2014
  8. 01/12 t/Makefile: stop setting GIT_CONFIGJeff King, Mar 20, 2014
  9. 02/12 t/test-lib: drop redundant unset of GIT_CONFIGJeff King, Mar 20, 2014
  10. 03/12 t: drop useless sane_unset GIT_* callsJeff King, Mar 20, 2014
  11. Junio C HamanoMar 21, 2014
  12. Jeff KingMar 24, 2014
  13. Junio C HamanoMar 24, 2014
  14. Junio C HamanoMar 25, 2014
  15. 04/12 t: stop using GIT_CONFIG to cross repo boundariesJeff King, Mar 20, 2014
  16. Junio C HamanoMar 21, 2014
  17. Jeff KingMar 24, 2014
  18. 05/12 t: prefer "git config --file" to GIT_CONFIG with test_must_failJeff King, Mar 20, 2014
  19. 06/12 t: prefer "git config --file" to GIT_CONFIGJeff King, Mar 20, 2014
  20. 07/12 t0001: make symlink reinit test more carefulJeff King, Mar 20, 2014
  21. 08/12 t0001: use test_path_is_*Jeff King, Mar 20, 2014
  22. 09/12 t0001: use test_config_globalJeff King, Mar 20, 2014
  23. 10/12 t0001: use test_must_failJeff King, Mar 20, 2014
  24. 11/12 t0001: drop useless subshellsJeff King, Mar 20, 2014
  25. Eric SunshineMar 21, 2014
  26. 12/12 t0001: drop subshells just for "cd"Jeff King, Mar 20, 2014
  27. Eric SunshineMar 18, 2014
  28. Eric SunshineMar 18, 2014

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.