Thread (5 messages) flat view 5 messages, 1 author, 2016-06-15
DORMANTno replies

Revision v1 of 2 in this series.

Revisions (2)
  1. v1 current
  2. v2 [diff vs current]

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

From: Ramkumar Ramachandra <hidden>
Date: 2016-06-15 22:55:25
Subsystem: the rest · Maintainer: Linus Torvalds

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 <redacted>
Signed-off-by: Ramkumar Ramachandra <redacted>
---
 t/t4041-diff-submodule-option.sh |   13 +++++--------
 1 files changed, 5 insertions(+), 8 deletions(-)
diff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh
index cfb71e5..103c690 100755
--- a/t/t4041-diff-submodule-option.sh
+++ b/t/t4041-diff-submodule-option.sh
@@ -11,18 +11,15 @@ 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
+	(cd "$1" &&
+	    shift &&
+	    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"
+	    done >/dev/null &&
+	    git rev-parse --short --verify HEAD)
 }
 commit_file () {
 	test_tick &&
-- 
1.7.8.1.362.g5d6df.dirty
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help