Skip to content

Commit 25641fc

Browse files
Benabikgitster
authored andcommitted
t7610: cd inside subshell instead of around
Instead of using `cd dir && (...) && cd..` use `(cd dir && ...)` This ensures that the test doesn't get caught in the subdirectory if there is an error in the subshell. Signed-off-by: Brian Gernhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent bc38219 commit 25641fc

File tree

1 file changed

+26
-23
lines changed

1 file changed

+26
-23
lines changed

t/t7610-mergetool.sh

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -68,22 +68,24 @@ test_expect_success 'mergetool crlf' '
6868
'
6969

7070
test_expect_success 'mergetool in subdir' '
71-
git checkout -b test3 branch1
72-
cd subdir && (
73-
test_must_fail git merge master >/dev/null 2>&1 &&
74-
( yes "" | git mergetool file3 >/dev/null 2>&1 ) &&
75-
test "$(cat file3)" = "master new sub") &&
76-
cd ..
71+
git checkout -b test3 branch1 &&
72+
(
73+
cd subdir &&
74+
test_must_fail git merge master >/dev/null 2>&1 &&
75+
( yes "" | git mergetool file3 >/dev/null 2>&1 ) &&
76+
test "$(cat file3)" = "master new sub"
77+
)
7778
'
7879

7980
test_expect_success 'mergetool on file in parent dir' '
80-
cd subdir && (
81-
( yes "" | git mergetool ../file1 >/dev/null 2>&1 ) &&
82-
( yes "" | git mergetool ../file2 >/dev/null 2>&1 ) &&
83-
test "$(cat ../file1)" = "master updated" &&
84-
test "$(cat ../file2)" = "master new" &&
85-
git commit -m "branch1 resolved with mergetool - subdir") &&
86-
cd ..
81+
(
82+
cd subdir &&
83+
( yes "" | git mergetool ../file1 >/dev/null 2>&1 ) &&
84+
( yes "" | git mergetool ../file2 >/dev/null 2>&1 ) &&
85+
test "$(cat ../file1)" = "master updated" &&
86+
test "$(cat ../file2)" = "master new" &&
87+
git commit -m "branch1 resolved with mergetool - subdir"
88+
)
8789
'
8890

8991
test_expect_success 'mergetool skips autoresolved' '
@@ -96,16 +98,17 @@ test_expect_success 'mergetool skips autoresolved' '
9698
'
9799

98100
test_expect_success 'mergetool merges all from subdir' '
99-
cd subdir && (
100-
git config rerere.enabled false &&
101-
test_must_fail git merge master &&
102-
git mergetool --no-prompt &&
103-
test "$(cat ../file1)" = "master updated" &&
104-
test "$(cat ../file2)" = "master new" &&
105-
test "$(cat file3)" = "master new sub" &&
106-
git add ../file1 ../file2 file3 &&
107-
git commit -m "branch2 resolved by mergetool from subdir") &&
108-
cd ..
101+
(
102+
cd subdir &&
103+
git config rerere.enabled false &&
104+
test_must_fail git merge master &&
105+
git mergetool --no-prompt &&
106+
test "$(cat ../file1)" = "master updated" &&
107+
test "$(cat ../file2)" = "master new" &&
108+
test "$(cat file3)" = "master new sub" &&
109+
git add ../file1 ../file2 file3 &&
110+
git commit -m "branch2 resolved by mergetool from subdir"
111+
)
109112
'
110113

111114
test_done

0 commit comments

Comments
 (0)