{"thread":{"id":"24844","subject":"[PATCH] t7610: cd inside subshell instead of around","startedAt":"2010-08-24T02:37:24Z","lastAt":"2010-08-26T08:38:21Z","messageCount":8,"participants":["Brian Gernhardt","Jonathan Nieder","David Aguilar","Charles Bailey"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"148805","messageId":"1282617444-641-1-git-send-email-brian@gernhardtsoftware.com","threadId":"24844","inReplyTo":null,"subject":"[PATCH] t7610: cd inside subshell instead of around","fromName":"Brian Gernhardt","fromEmail":"brian@gernhardtsoftware.com","sentAt":"2010-08-24T02:37:24Z","receivedAt":"2010-08-24T02:37:24Z","isPatch":true,"sender":{"key":"brian@gernhardtsoftware.com","avatar":"https://avatars.githubusercontent.com/u/133455?v=4"},"body":"Instead of using `cd dir && (...) && cd..` use `(cd dir && ...)`\n\nThis ensures that the test doesn't get caught in the subdirectory if\nthere is an error in the subshell.\n\nSigned-off-by: Brian Gernhardt <brian@gernhardtsoftware.com>\n---\n t/t7610-mergetool.sh |   49 ++++++++++++++++++++++++++-----------------------\n 1 files changed, 26 insertions(+), 23 deletions(-)\n\ndiff --git a/t/t7610-mergetool.sh b/t/t7610-mergetool.sh\nindex f5a7bf4..3c436e1 100755\n--- a/t/t7610-mergetool.sh\n+++ b/t/t7610-mergetool.sh\n@@ -68,22 +68,24 @@ test_expect_success 'mergetool crlf' '\n '\n \n test_expect_success 'mergetool in subdir' '\n-    git checkout -b test3 branch1\n-    cd subdir && (\n-    test_must_fail git merge master >/dev/null 2>&1 &&\n-    ( yes \"\" | git mergetool file3 >/dev/null 2>&1 ) &&\n-    test \"$(cat file3)\" = \"master new sub\") &&\n-    cd ..\n+    git checkout -b test3 branch1 &&\n+    (\n+        cd subdir &&\n+        test_must_fail git merge master >/dev/null 2>&1 &&\n+        ( yes \"\" | git mergetool file3 >/dev/null 2>&1 ) &&\n+        test \"$(cat file3)\" = \"master new sub\"\n+    )\n '\n \n test_expect_success 'mergetool on file in parent dir' '\n-    cd subdir && (\n-    ( yes \"\" | git mergetool ../file1 >/dev/null 2>&1 ) &&\n-    ( yes \"\" | git mergetool ../file2 >/dev/null 2>&1 ) &&\n-    test \"$(cat ../file1)\" = \"master updated\" &&\n-    test \"$(cat ../file2)\" = \"master new\" &&\n-    git commit -m \"branch1 resolved with mergetool - subdir\") &&\n-    cd ..\n+    (\n+        cd subdir && \n+        ( yes \"\" | git mergetool ../file1 >/dev/null 2>&1 ) &&\n+        ( yes \"\" | git mergetool ../file2 >/dev/null 2>&1 ) &&\n+        test \"$(cat ../file1)\" = \"master updated\" &&\n+        test \"$(cat ../file2)\" = \"master new\" &&\n+        git commit -m \"branch1 resolved with mergetool - subdir\"\n+    )\n '\n \n test_expect_success 'mergetool skips autoresolved' '\n@@ -96,16 +98,17 @@ test_expect_success 'mergetool skips autoresolved' '\n '\n \n test_expect_success 'mergetool merges all from subdir' '\n-    cd subdir && (\n-    git config rerere.enabled false &&\n-    test_must_fail git merge master &&\n-    git mergetool --no-prompt &&\n-    test \"$(cat ../file1)\" = \"master updated\" &&\n-    test \"$(cat ../file2)\" = \"master new\" &&\n-    test \"$(cat file3)\" = \"master new sub\" &&\n-    git add ../file1 ../file2 file3 &&\n-    git commit -m \"branch2 resolved by mergetool from subdir\") &&\n-    cd ..\n+    (\n+        cd subdir &&\n+        git config rerere.enabled false &&\n+        test_must_fail git merge master &&\n+        git mergetool --no-prompt &&\n+        test \"$(cat ../file1)\" = \"master updated\" &&\n+        test \"$(cat ../file2)\" = \"master new\" &&\n+        test \"$(cat file3)\" = \"master new sub\" &&\n+        git add ../file1 ../file2 file3 &&\n+        git commit -m \"branch2 resolved by mergetool from subdir\"\n+    )\n '\n \n test_done\n-- \n1.7.2.2.399.g628fd\n"},{"id":"148806","messageId":"20100824030524.GF17406@burratino","threadId":"24844","inReplyTo":"1282617444-641-1-git-send-email-brian@gernhardtsoftware.com","subject":"Re: [PATCH] t7610: cd inside subshell instead of around","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-08-24T03:05:24Z","receivedAt":"2010-08-24T03:05:24Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Brian Gernhardt wrote:\n\n> Instead of using `cd dir && (...) && cd..` use `(cd dir && ...)`\n\nThank you.\n\n> +++ b/t/t7610-mergetool.sh\n> @@ -68,22 +68,24 @@ test_expect_success 'mergetool crlf' '\n>  '\n>  \n>  test_expect_success 'mergetool in subdir' '\n> -    git checkout -b test3 branch1\n> -    cd subdir && (\n> -    test_must_fail git merge master >/dev/null 2>&1 &&\n> -    ( yes \"\" | git mergetool file3 >/dev/null 2>&1 ) &&\n> -    test \"$(cat file3)\" = \"master new sub\") &&\n> -    cd ..\n> +    git checkout -b test3 branch1 &&\n> +    (\n> +        cd subdir &&\n> +        test_must_fail git merge master >/dev/null 2>&1 &&\n> +        ( yes \"\" | git mergetool file3 >/dev/null 2>&1 ) &&\n> +        test \"$(cat file3)\" = \"master new sub\"\n> +    )\n\n\nWhile we're looking at this test script, some more nitpicks for\nsquashing in. :)\n\n-- 8< --\nSubject: t7610 (mergetool): more nitpicks\n\n - use tabs to indent\n - do not redirect output away unnecessarily\n - avoid a subshell for 'yes \"\" | git mergetool file3'\n - use test_tick for reproducible, increasing timestamps\n - use test_cmp instead of 'test $foo = bar'; the former is much\n   nicer to debug with --verbose since it produces a diff.\n\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\n t/t7610-mergetool.sh |  186 ++++++++++++++++++++++++++++---------------------\n 1 files changed, 106 insertions(+), 80 deletions(-)\n\ndiff --git a/t/t7610-mergetool.sh b/t/t7610-mergetool.sh\nindex 3c436e1..908f934 100755\n--- a/t/t7610-mergetool.sh\n+++ b/t/t7610-mergetool.sh\n@@ -3,112 +3,138 @@\n # Copyright (c) 2008 Charles Bailey\n #\n \n-test_description='git mergetool\n+test_description='Testing basic merge tool invocation\n \n-Testing basic merge tool invocation'\n+All the mergetool tests work by checking out a temporary branch based\n+off branch1 and then merging in master and checking the results of\n+running mergetool.\n+'\n \n . ./test-lib.sh\n \n-# All the mergetool test work by checking out a temporary branch based\n-# off 'branch1' and then merging in master and checking the results of\n-# running mergetool\n-\n test_expect_success 'setup' '\n-    git config rerere.enabled true &&\n-    echo master >file1 &&\n-    mkdir subdir &&\n-    echo master sub >subdir/file3 &&\n-    git add file1 subdir/file3 &&\n-    git commit -m \"added file1\" &&\n+\tgit config rerere.enabled true &&\n+\techo master >file1 &&\n+\tmkdir subdir &&\n+\techo master sub >subdir/file3 &&\n+\tgit add file1 subdir/file3 &&\n+\ttest_tick &&\n+\tgit commit -m \"added file1\" &&\n \n-    git checkout -b branch1 master &&\n-    echo branch1 change >file1 &&\n-    echo branch1 newfile >file2 &&\n-    echo branch1 sub >subdir/file3 &&\n-    git add file1 file2 subdir/file3 &&\n-    git commit -m \"branch1 changes\" &&\n+\tgit checkout -b branch1 master &&\n+\techo branch1 change >file1 &&\n+\techo branch1 newfile >file2 &&\n+\techo branch1 sub >subdir/file3 &&\n+\tgit add file1 file2 subdir/file3 &&\n+\ttest_tick &&\n+\tgit commit -m \"branch1 changes\" &&\n \n-    git checkout master &&\n-    echo master updated >file1 &&\n-    echo master new >file2 &&\n-    echo master new sub >subdir/file3 &&\n-    git add file1 file2 subdir/file3 &&\n-    git commit -m \"master updates\" &&\n+\tgit checkout master &&\n+\techo master updated >file1 &&\n+\techo master new >file2 &&\n+\techo master new sub >subdir/file3 &&\n+\tgit add file1 file2 subdir/file3 &&\n+\ttest_tick &&\n+\tgit commit -m \"master updates\" &&\n \n-    git config merge.tool mytool &&\n-    git config mergetool.mytool.cmd \"cat \\\"\\$REMOTE\\\" >\\\"\\$MERGED\\\"\" &&\n-    git config mergetool.mytool.trustExitCode true\n+\tgit config merge.tool mytool &&\n+\tgit config mergetool.mytool.cmd \"cat \\\"\\$REMOTE\\\" >\\\"\\$MERGED\\\"\" &&\n+\tgit config mergetool.mytool.trustExitCode true\n '\n \n test_expect_success 'custom mergetool' '\n-    git checkout -b test1 branch1 &&\n-    test_must_fail git merge master >/dev/null 2>&1 &&\n-    ( yes \"\" | git mergetool file1 >/dev/null 2>&1 ) &&\n-    ( yes \"\" | git mergetool file2 >/dev/null 2>&1 ) &&\n-    ( yes \"\" | git mergetool subdir/file3 >/dev/null 2>&1 ) &&\n-    test \"$(cat file1)\" = \"master updated\" &&\n-    test \"$(cat file2)\" = \"master new\" &&\n-    test \"$(cat subdir/file3)\" = \"master new sub\" &&\n-    git commit -m \"branch1 resolved with mergetool\"\n+\techo master updated >file1.expected &&\n+\techo master new >file2.expected &&\n+\techo master new sub >sub.expected &&\n+\n+\tgit checkout -b test1 branch1 &&\n+\ttest_must_fail git merge master &&\n+\tyes \"\" | git mergetool file1 &&\n+\tyes \"\" | git mergetool file2 &&\n+\tyes \"\" | git mergetool subdir/file3 &&\n+\n+\ttest_cmp file1.expected file1 &&\n+\ttest_cmp file2.expected file2 &&\n+\ttest_cmp sub.expected subdir/file3 &&\n+\n+\tgit commit -m \"branch1 resolved with mergetool\"\n '\n \n test_expect_success 'mergetool crlf' '\n-    git config core.autocrlf true &&\n-    git checkout -b test2 branch1\n-    test_must_fail git merge master >/dev/null 2>&1 &&\n-    ( yes \"\" | git mergetool file1 >/dev/null 2>&1 ) &&\n-    ( yes \"\" | git mergetool file2 >/dev/null 2>&1 ) &&\n-    ( yes \"\" | git mergetool subdir/file3 >/dev/null 2>&1 ) &&\n-    test \"$(printf x | cat file1 -)\" = \"$(printf \"master updated\\r\\nx\")\" &&\n-    test \"$(printf x | cat file2 -)\" = \"$(printf \"master new\\r\\nx\")\" &&\n-    test \"$(printf x | cat subdir/file3 -)\" = \"$(printf \"master new sub\\r\\nx\")\" &&\n-    git commit -m \"branch1 resolved with mergetool - autocrlf\" &&\n-    git config core.autocrlf false &&\n-    git reset --hard\n+\tgit config core.autocrlf true &&\n+\ttest_when_finished \"git config --unset core.autocrlf\" &&\n+\techo master updated | append_cr >file1.expected &&\n+\techo master new | append_cr >file2.expected &&\n+\techo master new sub | append_cr >sub.expected &&\n+\n+\tgit checkout -b test2 branch1 &&\n+\ttest_must_fail git merge master &&\n+\ttest_when_finished \"git reset --hard\" &&\n+\tyes \"\" | git mergetool file1 &&\n+\tyes \"\" | git mergetool file2 &&\n+\tyes \"\" | git mergetool subdir/file3 &&\n+\n+\ttest_cmp file1.expected file1 &&\n+\ttest_cmp file2.expected file2 &&\n+\ttest_cmp sub.expected subdir/file3 &&\n+\n+\tgit commit -m \"branch1 resolved with mergetool - autocrlf\"\n '\n \n test_expect_success 'mergetool in subdir' '\n-    git checkout -b test3 branch1 &&\n-    (\n-        cd subdir &&\n-        test_must_fail git merge master >/dev/null 2>&1 &&\n-        ( yes \"\" | git mergetool file3 >/dev/null 2>&1 ) &&\n-        test \"$(cat file3)\" = \"master new sub\"\n-    )\n+\techo master new sub >sub.expected &&\n+\tgit checkout -b test3 branch1 &&\n+\t(\n+\t\tcd subdir &&\n+\t\ttest_must_fail git merge master &&\n+\t\tyes \"\" | git mergetool file3 &&\n+\t\ttest_cmp ../sub.expected file3\n+\t)\n '\n \n test_expect_success 'mergetool on file in parent dir' '\n-    (\n-        cd subdir && \n-        ( yes \"\" | git mergetool ../file1 >/dev/null 2>&1 ) &&\n-        ( yes \"\" | git mergetool ../file2 >/dev/null 2>&1 ) &&\n-        test \"$(cat ../file1)\" = \"master updated\" &&\n-        test \"$(cat ../file2)\" = \"master new\" &&\n-        git commit -m \"branch1 resolved with mergetool - subdir\"\n-    )\n+\techo master updated >file1.expected &&\n+\techo master new >file2.expected &&\n+\t(\n+\t\tcd subdir &&\n+\t\tyes \"\" | git mergetool ../file1 &&\n+\t\tyes \"\" | git mergetool ../file2 &&\n+\t\ttest_cmp ../file1.expected ../file1 &&\n+\t\ttest_cmp ../file2.expected ../file2 &&\n+\t\tgit commit -m \"branch1 resolved with mergetool - subdir\"\n+\t)\n '\n \n test_expect_success 'mergetool skips autoresolved' '\n-    git checkout -b test4 branch1 &&\n-    test_must_fail git merge master &&\n-    test -n \"$(git ls-files -u)\" &&\n-    output=\"$(git mergetool --no-prompt)\" &&\n-    test \"$output\" = \"No files need merging\" &&\n-    git reset --hard\n+\techo \"No files need merging\" >expected &&\n+\tgit checkout -b test4 branch1 &&\n+\ttest_must_fail git merge master &&\n+\ttest_when_finished \"git reset --hard\" &&\n+\ttest_must_fail git update-index --refresh &&\n+\tgit mergetool --no-prompt >actual &&\n+\ttest_cmp expected actual\n '\n \n test_expect_success 'mergetool merges all from subdir' '\n-    (\n-        cd subdir &&\n-        git config rerere.enabled false &&\n-        test_must_fail git merge master &&\n-        git mergetool --no-prompt &&\n-        test \"$(cat ../file1)\" = \"master updated\" &&\n-        test \"$(cat ../file2)\" = \"master new\" &&\n-        test \"$(cat file3)\" = \"master new sub\" &&\n-        git add ../file1 ../file2 file3 &&\n-        git commit -m \"branch2 resolved by mergetool from subdir\"\n-    )\n+\techo master updated >file1.expected &&\n+\techo master new >file2.expected &&\n+\techo master new sub >sub.expected &&\n+\n+\tgit config rerere.enabled false &&\n+\ttest_when_finished \"git config rerere.enabled true\" &&\n+\tmv .git/rr-cache .git/rr-cache-moved &&\n+\ttest_when_finished \"mv .git/rr-cache-moved .git/rr-cache\" &&\n+\t(\n+\t\tcd subdir &&\n+\t\ttest_must_fail git merge master &&\n+\t\ttest_when_finished \"git reset --hard\" &&\n+\t\tgit mergetool --no-prompt &&\n+\t\ttest_cmp ../file1.expected ../file1 &&\n+\t\ttest_cmp ../file2.expected ../file2 &&\n+\t\ttest_cmp ../sub.expected file3 &&\n+\t\tgit add ../file1 ../file2 file3 &&\n+\t\tgit commit -m \"branch2 resolved by mergetool from subdir\"\n+\t)\n '\n \n test_done\n-- \n1.7.2.2\n"},{"id":"148808","messageId":"432D99EA-303B-4201-9B07-7694800B4580@gernhardtsoftware.com","threadId":"24844","inReplyTo":"20100824030524.GF17406@burratino","subject":"Re: [PATCH] t7610: cd inside subshell instead of around","fromName":"Brian Gernhardt","fromEmail":"brian@gernhardtsoftware.com","sentAt":"2010-08-24T03:51:22Z","receivedAt":"2010-08-24T03:51:22Z","isPatch":true,"sender":{"key":"brian@gernhardtsoftware.com","avatar":"https://avatars.githubusercontent.com/u/133455?v=4"},"body":"\nOn Aug 23, 2010, at 11:05 PM, Jonathan Nieder wrote:\n\n> While we're looking at this test script, some more nitpicks for\n> squashing in. :)\n> \n> -- 8< --\n> Subject: t7610 (mergetool): more nitpicks\n> \n> - use tabs to indent\n> - do not redirect output away unnecessarily\n> - avoid a subshell for 'yes \"\" | git mergetool file3'\n> - use test_tick for reproducible, increasing timestamps\n> - use test_cmp instead of 'test $foo = bar'; the former is much\n>   nicer to debug with --verbose since it produces a diff.\n\nFair enough.  I just took a stab at the bit that irritated me the most.  Thanks for cleaning up the rest.\n\n~~ Brian\n"},{"id":"148817","messageId":"20100824050335.GD20037@burratino","threadId":"24844","inReplyTo":"432D99EA-303B-4201-9B07-7694800B4580@gernhardtsoftware.com","subject":"Re: [PATCH] t7610: cd inside subshell instead of around","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-08-24T05:03:35Z","receivedAt":"2010-08-24T05:03:35Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Brian Gernhardt wrote:\n\n> Thanks for cleaning up the rest.\n\nGlad you liked it.  BTW I did not mean to imply your cleanup was\nhalf-hearted or anything.  On the contrary, I was very happy with it.\n"},{"id":"148912","messageId":"20100825002552.GI2376@burratino","threadId":"24844","inReplyTo":"20100824030524.GF17406@burratino","subject":"[PATCH v2] t7610 (mergetool): more nitpicks","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-08-25T00:25:52Z","receivedAt":"2010-08-25T00:25:52Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":" - use tabs to indent\n - do not redirect output away unnecessarily\n - avoid a subshell for 'yes \"\" | git mergetool file3'\n - use test_tick for reproducible, increasing timestamps\n - use test_cmp instead of 'test $foo = bar'; the former is much\n   nicer to debug with --verbose since it produces a diff.\n\nHelped-by: Junio C Hamano <gitster@pobox.com>\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\nJonathan Nieder wrote:\n\n>  test_expect_success 'mergetool crlf' '\n>      git config core.autocrlf true &&\n> +\ttest_when_finished \"git config --unset core.autocrlf\" &&\n> +\techo master updated | append_cr >file1.expected &&\n> +\techo master new | append_cr >file2.expected &&\n> +\techo master new sub | append_cr >sub.expected &&\n> +\n> -    git checkout -b test2 branch1\n> +\tgit checkout -b test2 branch1 &&\n> -    test_must_fail git merge master >/dev/null 2>&1 &&\n> +\ttest_must_fail git merge master &&\n> +\ttest_when_finished \"git reset --hard\" &&\n> -    ( yes \"\" | git mergetool file1 >/dev/null 2>&1 ) &&\n> -    ( yes \"\" | git mergetool file2 >/dev/null 2>&1 ) &&\n> -    ( yes \"\" | git mergetool subdir/file3 >/dev/null 2>&1 ) &&\n> +\tyes \"\" | git mergetool file1 &&\n> +\tyes \"\" | git mergetool file2 &&\n> +\tyes \"\" | git mergetool subdir/file3 &&\n> -    test \"$(printf x | cat file1 -)\" = \"$(printf \"master updated\\r\\nx\")\" &&\n> -    test \"$(printf x | cat file2 -)\" = \"$(printf \"master new\\r\\nx\")\" &&\n> -    test \"$(printf x | cat subdir/file3 -)\" = \"$(printf \"master new sub\\r\\nx\")\" &&\n> +\n> +\ttest_cmp file1.expected file1 &&\n> +\ttest_cmp file2.expected file2 &&\n> +\ttest_cmp sub.expected subdir/file3 &&\n> -    git commit -m \"branch1 resolved with mergetool - autocrlf\" &&\n> +\n> +\tgit commit -m \"branch1 resolved with mergetool - autocrlf\"\n> -    git config core.autocrlf false &&\n> -    git reset --hard\n>  '\n\nAs Junio noticed, the net effect is to run \"reset --hard\" before\nthe \"[core] autocrlf\" configuration is removed, which could be\nan undesirable behavior change.  So this version runs \"reset --hard\"\nafter unsetting autocrlf for good measure.\n\n t/t7610-mergetool.sh |  187 +++++++++++++++++++++++++++++---------------------\n 1 files changed, 108 insertions(+), 79 deletions(-)\n\ndiff --git a/t/t7610-mergetool.sh b/t/t7610-mergetool.sh\nindex 3bd7404..a7f05b0 100755\n--- a/t/t7610-mergetool.sh\n+++ b/t/t7610-mergetool.sh\n@@ -3,112 +3,141 @@\n # Copyright (c) 2008 Charles Bailey\n #\n \n-test_description='git mergetool\n+test_description='Testing basic merge tool invocation\n \n-Testing basic merge tool invocation'\n+All the mergetool tests work by checking out a temporary branch based\n+off branch1 and then merging in master and checking the results of\n+running mergetool.\n+'\n \n . ./test-lib.sh\n \n-# All the mergetool test work by checking out a temporary branch based\n-# off 'branch1' and then merging in master and checking the results of\n-# running mergetool\n-\n test_expect_success 'setup' '\n-    git config rerere.enabled true &&\n-    echo master >file1 &&\n-    mkdir subdir &&\n-    echo master sub >subdir/file3 &&\n-    git add file1 subdir/file3 &&\n-    git commit -m \"added file1\" &&\n+\tgit config rerere.enabled true &&\n+\techo master >file1 &&\n+\tmkdir subdir &&\n+\techo master sub >subdir/file3 &&\n+\tgit add file1 subdir/file3 &&\n+\ttest_tick &&\n+\tgit commit -m \"added file1\" &&\n \n-    git checkout -b branch1 master &&\n-    echo branch1 change >file1 &&\n-    echo branch1 newfile >file2 &&\n-    echo branch1 sub >subdir/file3 &&\n-    git add file1 file2 subdir/file3 &&\n-    git commit -m \"branch1 changes\" &&\n+\tgit checkout -b branch1 master &&\n+\techo branch1 change >file1 &&\n+\techo branch1 newfile >file2 &&\n+\techo branch1 sub >subdir/file3 &&\n+\tgit add file1 file2 subdir/file3 &&\n+\ttest_tick &&\n+\tgit commit -m \"branch1 changes\" &&\n \n-    git checkout master &&\n-    echo master updated >file1 &&\n-    echo master new >file2 &&\n-    echo master new sub >subdir/file3 &&\n-    git add file1 file2 subdir/file3 &&\n-    git commit -m \"master updates\" &&\n+\tgit checkout master &&\n+\techo master updated >file1 &&\n+\techo master new >file2 &&\n+\techo master new sub >subdir/file3 &&\n+\tgit add file1 file2 subdir/file3 &&\n+\ttest_tick &&\n+\tgit commit -m \"master updates\" &&\n \n-    git config merge.tool mytool &&\n-    git config mergetool.mytool.cmd \"cat \\\"\\$REMOTE\\\" >\\\"\\$MERGED\\\"\" &&\n-    git config mergetool.mytool.trustExitCode true\n+\tgit config merge.tool mytool &&\n+\tgit config mergetool.mytool.cmd \"cat \\\"\\$REMOTE\\\" >\\\"\\$MERGED\\\"\" &&\n+\tgit config mergetool.mytool.trustExitCode true\n '\n \n test_expect_success 'custom mergetool' '\n-    git checkout -b test1 branch1 &&\n-    test_must_fail git merge master >/dev/null 2>&1 &&\n-    ( yes \"\" | git mergetool file1 >/dev/null 2>&1 ) &&\n-    ( yes \"\" | git mergetool file2 >/dev/null 2>&1 ) &&\n-    ( yes \"\" | git mergetool subdir/file3 >/dev/null 2>&1 ) &&\n-    test \"$(cat file1)\" = \"master updated\" &&\n-    test \"$(cat file2)\" = \"master new\" &&\n-    test \"$(cat subdir/file3)\" = \"master new sub\" &&\n-    git commit -m \"branch1 resolved with mergetool\"\n+\techo master updated >file1.expected &&\n+\techo master new >file2.expected &&\n+\techo master new sub >sub.expected &&\n+\n+\tgit checkout -b test1 branch1 &&\n+\ttest_must_fail git merge master &&\n+\tyes \"\" | git mergetool file1 &&\n+\tyes \"\" | git mergetool file2 &&\n+\tyes \"\" | git mergetool subdir/file3 &&\n+\n+\ttest_cmp file1.expected file1 &&\n+\ttest_cmp file2.expected file2 &&\n+\ttest_cmp sub.expected subdir/file3 &&\n+\n+\tgit commit -m \"branch1 resolved with mergetool\"\n '\n \n test_expect_success 'mergetool crlf' '\n-    git config core.autocrlf true &&\n-    git checkout -b test2 branch1\n-    test_must_fail git merge master >/dev/null 2>&1 &&\n-    ( yes \"\" | git mergetool file1 >/dev/null 2>&1 ) &&\n-    ( yes \"\" | git mergetool file2 >/dev/null 2>&1 ) &&\n-    ( yes \"\" | git mergetool subdir/file3 >/dev/null 2>&1 ) &&\n-    test \"$(printf x | cat file1 -)\" = \"$(printf \"master updated\\r\\nx\")\" &&\n-    test \"$(printf x | cat file2 -)\" = \"$(printf \"master new\\r\\nx\")\" &&\n-    test \"$(printf x | cat subdir/file3 -)\" = \"$(printf \"master new sub\\r\\nx\")\" &&\n-    git commit -m \"branch1 resolved with mergetool - autocrlf\" &&\n-    git config core.autocrlf false &&\n-    git reset --hard\n+\tgit config core.autocrlf true &&\n+\ttest_when_finished \"\n+\t\tgit config --unset core.autocrlf &&\n+\t\tgit reset --hard\n+\t\" &&\n+\techo master updated | append_cr >file1.expected &&\n+\techo master new | append_cr >file2.expected &&\n+\techo master new sub | append_cr >sub.expected &&\n+\n+\tgit checkout -b test2 branch1 &&\n+\ttest_must_fail git merge master &&\n+\ttest_when_finished \"git reset --hard\" &&\n+\tyes \"\" | git mergetool file1 &&\n+\tyes \"\" | git mergetool file2 &&\n+\tyes \"\" | git mergetool subdir/file3 &&\n+\n+\ttest_cmp file1.expected file1 &&\n+\ttest_cmp file2.expected file2 &&\n+\ttest_cmp sub.expected subdir/file3 &&\n+\n+\tgit commit -m \"branch1 resolved with mergetool - autocrlf\"\n '\n \n test_expect_success 'mergetool in subdir' '\n-    git checkout -b test3 branch1 &&\n-    (\n-\tcd subdir &&\n-\ttest_must_fail git merge master >/dev/null 2>&1 &&\n-\t( yes \"\" | git mergetool file3 >/dev/null 2>&1 ) &&\n-\ttest \"$(cat file3)\" = \"master new sub\"\n-    )\n+\techo master new sub >sub.expected &&\n+\tgit checkout -b test3 branch1 &&\n+\t(\n+\t\tcd subdir &&\n+\t\ttest_must_fail git merge master &&\n+\t\tyes \"\" | git mergetool file3 &&\n+\t\ttest_cmp ../sub.expected file3\n+\t)\n '\n \n test_expect_success 'mergetool on file in parent dir' '\n-    (\n-\tcd subdir &&\n-\t( yes \"\" | git mergetool ../file1 >/dev/null 2>&1 ) &&\n-\t( yes \"\" | git mergetool ../file2 >/dev/null 2>&1 ) &&\n-\ttest \"$(cat ../file1)\" = \"master updated\" &&\n-\ttest \"$(cat ../file2)\" = \"master new\" &&\n-\tgit commit -m \"branch1 resolved with mergetool - subdir\"\n-    )\n+\techo master updated >file1.expected &&\n+\techo master new >file2.expected &&\n+\t(\n+\t\tcd subdir &&\n+\t\tyes \"\" | git mergetool ../file1 &&\n+\t\tyes \"\" | git mergetool ../file2 &&\n+\t\ttest_cmp ../file1.expected ../file1 &&\n+\t\ttest_cmp ../file2.expected ../file2 &&\n+\t\tgit commit -m \"branch1 resolved with mergetool - subdir\"\n+\t)\n '\n \n test_expect_success 'mergetool skips autoresolved' '\n-    git checkout -b test4 branch1 &&\n-    test_must_fail git merge master &&\n-    test -n \"$(git ls-files -u)\" &&\n-    output=\"$(git mergetool --no-prompt)\" &&\n-    test \"$output\" = \"No files need merging\" &&\n-    git reset --hard\n+\techo \"No files need merging\" >expected &&\n+\tgit checkout -b test4 branch1 &&\n+\ttest_must_fail git merge master &&\n+\ttest_when_finished \"git reset --hard\" &&\n+\ttest_must_fail git update-index --refresh &&\n+\tgit mergetool --no-prompt >actual &&\n+\ttest_cmp expected actual\n '\n \n test_expect_success 'mergetool merges all from subdir' '\n-    (\n-\tcd subdir &&\n+\techo master updated >file1.expected &&\n+\techo master new >file2.expected &&\n+\techo master new sub >sub.expected &&\n+\n \tgit config rerere.enabled false &&\n-\ttest_must_fail git merge master &&\n-\tgit mergetool --no-prompt &&\n-\ttest \"$(cat ../file1)\" = \"master updated\" &&\n-\ttest \"$(cat ../file2)\" = \"master new\" &&\n-\ttest \"$(cat file3)\" = \"master new sub\" &&\n-\tgit add ../file1 ../file2 file3 &&\n-\tgit commit -m \"branch2 resolved by mergetool from subdir\"\n-    )\n+\ttest_when_finished \"git config rerere.enabled true\" &&\n+\tmv .git/rr-cache .git/rr-cache-moved &&\n+\ttest_when_finished \"mv .git/rr-cache-moved .git/rr-cache\" &&\n+\t(\n+\t\tcd subdir &&\n+\t\ttest_must_fail git merge master &&\n+\t\ttest_when_finished \"git reset --hard\" &&\n+\t\tgit mergetool --no-prompt &&\n+\t\ttest_cmp ../file1.expected ../file1 &&\n+\t\ttest_cmp ../file2.expected ../file2 &&\n+\t\ttest_cmp ../sub.expected file3 &&\n+\t\tgit add ../file1 ../file2 file3 &&\n+\t\tgit commit -m \"branch2 resolved by mergetool from subdir\"\n+\t)\n '\n \n test_done\n-- \n1.7.2.2\n"},{"id":"148956","messageId":"20100825074034.GA4058@gmail.com","threadId":"24844","inReplyTo":"20100825002552.GI2376@burratino","subject":"Re: [PATCH v2] t7610 (mergetool): more nitpicks","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2010-08-25T07:40:38Z","receivedAt":"2010-08-25T07:40:38Z","isPatch":true,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"On Tue, Aug 24, 2010 at 07:25:52PM -0500, Jonathan Nieder wrote:\n>  - use tabs to indent\n> [...]\n\nCool.  I'd like to do the same to git-mergetool.sh too.\nUntil now I've stuck to the existing style.\nMy editor is setup to display tabs visually which makes it easy\nfor me to emulate existing code but not everyone does that.\n\nAny objections to a patch that replaces the mixed 4-space+tab\nindents with pure tabs?\n\nIt would make the git-mergetool consistent with\ngit-mergetool--lib, git-difftool--helper, and their tests.\n\nI don't know if pure-tabs is the preferred style for *.sh\nscripts.  It's not explicitly mentioned in CodingGuidelines'\nshell script section.  Updating all of the *.sh scripts, though,\nseems like code churn so I wouldn't recommend that unless we\nwere going to be changing the scripts anyways.\n\n-- \n\n\tDavid\n"},{"id":"148957","messageId":"20100825075650.GB18308@hashpling.org","threadId":"24844","inReplyTo":"20100825074034.GA4058@gmail.com","subject":"Re: [PATCH v2] t7610 (mergetool): more nitpicks","fromName":"Charles Bailey","fromEmail":"charles@hashpling.org","sentAt":"2010-08-25T07:56:50Z","receivedAt":"2010-08-25T07:56:50Z","isPatch":true,"sender":{"key":"charles@hashpling.org","avatar":"https://avatars.githubusercontent.com/u/1668475?v=4"},"body":"On Wed, Aug 25, 2010 at 12:40:38AM -0700, David Aguilar wrote:\n> On Tue, Aug 24, 2010 at 07:25:52PM -0500, Jonathan Nieder wrote:\n> >  - use tabs to indent\n> > [...]\n> \n> Cool.  I'd like to do the same to git-mergetool.sh too.\n> Until now I've stuck to the existing style.\n> My editor is setup to display tabs visually which makes it easy\n> for me to emulate existing code but not everyone does that.\n> \n> Any objections to a patch that replaces the mixed 4-space+tab\n> indents with pure tabs?\n\nJust the same objection as the last time:\n\nhttp://thread.gmane.org/gmane.comp.version-control.git/115069/focus=115192\n\nWe've already tidyied up mergetool to be consistent, I don't see what\ntouching 90% of the lines achieves other than getting yourself\n'blamed' for everything in mergetool.\n\nCharles.\n"},{"id":"149057","messageId":"A5048FBD-FF49-4635-812F-9FF36C6BA01D@gmail.com","threadId":"24844","inReplyTo":"20100825075650.GB18308@hashpling.org","subject":"Re: [PATCH v2] t7610 (mergetool): more nitpicks","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2010-08-26T08:38:21Z","receivedAt":"2010-08-26T08:38:21Z","isPatch":true,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"On Aug 25, 2010, at 12:56 AM, Charles Bailey <charles@hashpling.org>  \nwrote:\n\n> On Wed, Aug 25, 2010 at 12:40:38AM -0700, David Aguilar wrote:\n>> On Tue, Aug 24, 2010 at 07:25:52PM -0500, Jonathan Nieder wrote:\n>>> - use tabs to indent\n>>> [...]\n>>\n>> Cool.  I'd like to do the same to git-mergetool.sh too.\n>> Until now I've stuck to the existing style.\n>> My editor is setup to display tabs visually which makes it easy\n>> for me to emulate existing code but not everyone does that.\n>>\n>> Any objections to a patch that replaces the mixed 4-space+tab\n>> indents with pure tabs?\n>\n> Just the same objection as the last time:\n>\n> http://thread.gmane.org/gmane.comp.version-control.git/115069/focus=115192\n>\n> We've already tidyied up mergetool to be consistent, I don't see what\n> touching 90% of the lines achieves other than getting yourself\n> 'blamed' for everything in mergetool.\n>\n> Charles.\n\nToo true.\n\nInstead of that I should probably get around to factoring out the tool- \nspecific parts like we discussed in the past.\n\nThanks Charles,\n-- \n         David\n"}]}