Skip to content

Commit 2934975

Browse files
artagnongitster
authored andcommitted
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 <[email protected]> Signed-off-by: Ramkumar Ramachandra <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 20fa538 commit 2934975

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

t/t4041-diff-submodule-option.sh

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,18 @@ This test tries to verify the sanity of the --submodule option of git diff.
1111
. ./test-lib.sh
1212

1313
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+
)
2626
}
2727
commit_file () {
2828
test_tick &&

0 commit comments

Comments
 (0)