git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] t7610: cd inside subshell instead of around
@ 2010-08-24  2:37 Brian Gernhardt
  2010-08-24  3:05 ` Jonathan Nieder
  0 siblings, 1 reply; 8+ messages in thread
From: Brian Gernhardt @ 2010-08-24  2:37 UTC (permalink / raw)
  To: Git List; +Cc: Junio C Hamano

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 <brian@gernhardtsoftware.com>
---
 t/t7610-mergetool.sh |   49 ++++++++++++++++++++++++++-----------------------
 1 files changed, 26 insertions(+), 23 deletions(-)

diff --git a/t/t7610-mergetool.sh b/t/t7610-mergetool.sh
index f5a7bf4..3c436e1 100755
--- a/t/t7610-mergetool.sh
+++ b/t/t7610-mergetool.sh
@@ -68,22 +68,24 @@ test_expect_success 'mergetool crlf' '
 '
 
 test_expect_success 'mergetool in subdir' '
-    git checkout -b test3 branch1
-    cd subdir && (
-    test_must_fail git merge master >/dev/null 2>&1 &&
-    ( yes "" | git mergetool file3 >/dev/null 2>&1 ) &&
-    test "$(cat file3)" = "master new sub") &&
-    cd ..
+    git checkout -b test3 branch1 &&
+    (
+        cd subdir &&
+        test_must_fail git merge master >/dev/null 2>&1 &&
+        ( yes "" | git mergetool file3 >/dev/null 2>&1 ) &&
+        test "$(cat file3)" = "master new sub"
+    )
 '
 
 test_expect_success 'mergetool on file in parent dir' '
-    cd subdir && (
-    ( yes "" | git mergetool ../file1 >/dev/null 2>&1 ) &&
-    ( yes "" | git mergetool ../file2 >/dev/null 2>&1 ) &&
-    test "$(cat ../file1)" = "master updated" &&
-    test "$(cat ../file2)" = "master new" &&
-    git commit -m "branch1 resolved with mergetool - subdir") &&
-    cd ..
+    (
+        cd subdir && 
+        ( yes "" | git mergetool ../file1 >/dev/null 2>&1 ) &&
+        ( yes "" | git mergetool ../file2 >/dev/null 2>&1 ) &&
+        test "$(cat ../file1)" = "master updated" &&
+        test "$(cat ../file2)" = "master new" &&
+        git commit -m "branch1 resolved with mergetool - subdir"
+    )
 '
 
 test_expect_success 'mergetool skips autoresolved' '
@@ -96,16 +98,17 @@ test_expect_success 'mergetool skips autoresolved' '
 '
 
 test_expect_success 'mergetool merges all from subdir' '
-    cd subdir && (
-    git config rerere.enabled false &&
-    test_must_fail git merge master &&
-    git mergetool --no-prompt &&
-    test "$(cat ../file1)" = "master updated" &&
-    test "$(cat ../file2)" = "master new" &&
-    test "$(cat file3)" = "master new sub" &&
-    git add ../file1 ../file2 file3 &&
-    git commit -m "branch2 resolved by mergetool from subdir") &&
-    cd ..
+    (
+        cd subdir &&
+        git config rerere.enabled false &&
+        test_must_fail git merge master &&
+        git mergetool --no-prompt &&
+        test "$(cat ../file1)" = "master updated" &&
+        test "$(cat ../file2)" = "master new" &&
+        test "$(cat file3)" = "master new sub" &&
+        git add ../file1 ../file2 file3 &&
+        git commit -m "branch2 resolved by mergetool from subdir"
+    )
 '
 
 test_done
-- 
1.7.2.2.399.g628fd

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2010-08-26  8:38 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-24  2:37 [PATCH] t7610: cd inside subshell instead of around Brian Gernhardt
2010-08-24  3:05 ` Jonathan Nieder
2010-08-24  3:51   ` Brian Gernhardt
2010-08-24  5:03     ` Jonathan Nieder
2010-08-25  0:25   ` [PATCH v2] t7610 (mergetool): more nitpicks Jonathan Nieder
2010-08-25  7:40     ` David Aguilar
2010-08-25  7:56       ` Charles Bailey
2010-08-26  8:38         ` David Aguilar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).