[PATCH v2 3/4] t4041 (diff-submodule-option): rewrite add_file() routine

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Instead of "cd there and then come back", use the "cd there in a
subshell" pattern.  Also fix '&&' chaining in one place.

Suggested-by: Junio C Hamano <gitster@xxxxxxxxx>
Signed-off-by: Ramkumar Ramachandra <artagnon@xxxxxxxxx>
---
 t/t4041-diff-submodule-option.sh |   23 +++++++++++------------
 1 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh
index 08d549a..d745197 100755
--- a/t/t4041-diff-submodule-option.sh
+++ b/t/t4041-diff-submodule-option.sh
@@ -11,18 +11,17 @@ This test tries to verify the sanity of the --submodule option of git diff.
 . ./test-lib.sh
 
 add_file () {
-	sm=$1
-	shift
-	owd=$(pwd)
-	cd "$sm"
-	for name; do
-		echo "$name" > "$name" &&
-		git add "$name" &&
-		test_tick &&
-		git commit -m "Add $name"
-	done >/dev/null
-	git rev-parse --short --verify HEAD
-	cd "$owd"
+	(
+		cd "$1" &&
+		shift &&
+		for name; do
+			echo "$name" > "$name" &&
+			git add "$name" &&
+			test_tick &&
+			git commit -m "Add $name" || exit
+		done >/dev/null &&
+		git rev-parse --short --verify HEAD
+	)
 }
 commit_file () {
 	test_tick &&
-- 
1.7.8.1.362.g5d6df.dirty

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]