Commits

Ramkumar Ramachandra  committed 2934975

t4041 (diff-submodule-option): rewrite add_file() routine

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

  • Participants
  • Parent commits 20fa538

Comments (0)

Files changed (1)

File t/t4041-diff-submodule-option.sh

 . ./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 &&