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>

Ramkumar Ramachandra committed Nov 30, 2012 at 17:07 UTC 2934975f2df4ab7fd93c0f7a2fff80414d090547
1 file changed +12 -12
t/t4041-diff-submodule-option.sh
+12 -12
@@ -11,18 +11,18 @@ This test tries to verify the sanity of the --submodule option of git diff.
11 . ./test-lib.sh
12
13 add_file () {
14 - sm=$1
15 - shift
16 - owd=$(pwd)
17 - cd "$sm"
18 - for name; do
19 - echo "$name" > "$name" &&
20 - git add "$name" &&
21 - test_tick &&
22 - git commit -m "Add $name"
23 - done >/dev/null
24 - git rev-parse --short --verify HEAD
25 - cd "$owd"
14 + (
15 + cd "$1" &&
16 + shift &&
17 + for name
18 + do
19 + echo "$name" >"$name" &&
20 + git add "$name" &&
21 + test_tick &&
22 + git commit -m "Add $name" || exit
23 + done >/dev/null &&
24 + git rev-parse --short --verify HEAD
25 + )
26 }
27 commit_file () {
28 test_tick &&