Merge branch 'vn/diff-ihc-config'
[gitweb.git] / t / t7610-mergetool.sh
index 28b5f847a55142bd0b3a12fc67c7c37440d64a78..381b7df452e44622c46c8c3471f181b4568be10a 100755 (executable)
@@ -184,6 +184,7 @@ test_expect_success 'mergetool in subdir' '
 
 test_expect_success 'mergetool on file in parent dir' '
        test_when_finished "git reset --hard" &&
+       git checkout -b test$test_count branch1 &&
        git submodule update -N &&
        (
                cd subdir &&
@@ -215,8 +216,9 @@ test_expect_success 'mergetool skips autoresolved' '
        test "$output" = "No files need merging"
 '
 
-test_expect_success 'mergetool merges all from subdir' '
+test_expect_success 'mergetool merges all from subdir (rerere disabled)' '
        test_when_finished "git reset --hard" &&
+       git checkout -b test$test_count branch1 &&
        test_config rerere.enabled false &&
        (
                cd subdir &&
@@ -232,6 +234,25 @@ test_expect_success 'mergetool merges all from subdir' '
        )
 '
 
+test_expect_success 'mergetool merges all from subdir (rerere enabled)' '
+       test_when_finished "git reset --hard" &&
+       git checkout -b test$test_count branch1 &&
+       test_config rerere.enabled true &&
+       rm -rf .git/rr-cache &&
+       (
+               cd subdir &&
+               test_must_fail git merge master &&
+               ( yes "r" | git mergetool ../submod ) &&
+               ( yes "d" "d" | git mergetool --no-prompt ) &&
+               test "$(cat ../file1)" = "master updated" &&
+               test "$(cat ../file2)" = "master new" &&
+               test "$(cat file3)" = "master new sub" &&
+               ( cd .. && git submodule update -N ) &&
+               test "$(cat ../submod/bar)" = "master submodule" &&
+               git commit -m "branch2 resolved by mergetool from subdir"
+       )
+'
+
 test_expect_success 'mergetool skips resolved paths when rerere is active' '
        test_when_finished "git reset --hard" &&
        test_config rerere.enabled true &&
@@ -287,23 +308,24 @@ test_expect_success 'mergetool takes partial path' '
 '
 
 test_expect_success 'mergetool delete/delete conflict' '
-       test_when_finished "git reset --hard HEAD" &&
-       git checkout move-to-c &&
+       test_when_finished "git reset --hard" &&
+       git checkout -b test$test_count move-to-c &&
        test_must_fail git merge move-to-b &&
        echo d | git mergetool a/a/file.txt &&
        ! test -f a/a/file.txt &&
-       git reset --hard HEAD &&
+       git reset --hard &&
        test_must_fail git merge move-to-b &&
        echo m | git mergetool a/a/file.txt &&
        test -f b/b/file.txt &&
-       git reset --hard HEAD &&
+       git reset --hard &&
        test_must_fail git merge move-to-b &&
        ! echo a | git mergetool a/a/file.txt &&
        ! test -f a/a/file.txt
 '
 
 test_expect_success 'mergetool produces no errors when keepBackup is used' '
-       test_when_finished "git reset --hard HEAD" &&
+       test_when_finished "git reset --hard" &&
+       git checkout -b test$test_count move-to-c &&
        test_config mergetool.keepBackup true &&
        test_must_fail git merge move-to-b &&
        : >expect &&
@@ -313,7 +335,8 @@ test_expect_success 'mergetool produces no errors when keepBackup is used' '
 '
 
 test_expect_success 'mergetool honors tempfile config for deleted files' '
-       test_when_finished "git reset --hard HEAD" &&
+       test_when_finished "git reset --hard" &&
+       git checkout -b test$test_count move-to-c &&
        test_config mergetool.keepTemporaries false &&
        test_must_fail git merge move-to-b &&
        echo d | git mergetool a/a/file.txt &&
@@ -321,8 +344,9 @@ test_expect_success 'mergetool honors tempfile config for deleted files' '
 '
 
 test_expect_success 'mergetool keeps tempfiles when aborting delete/delete' '
-       test_when_finished "git reset --hard HEAD" &&
+       test_when_finished "git reset --hard" &&
        test_when_finished "git clean -fdx" &&
+       git checkout -b test$test_count move-to-c &&
        test_config mergetool.keepTemporaries true &&
        test_must_fail git merge move-to-b &&
        ! (echo a; echo n) | git mergetool a/a/file.txt &&
@@ -337,7 +361,7 @@ test_expect_success 'mergetool keeps tempfiles when aborting delete/delete' '
 '
 
 test_expect_success 'deleted vs modified submodule' '
-       test_when_finished "git reset --hard HEAD" &&
+       test_when_finished "git reset --hard" &&
        git checkout -b test$test_count branch1 &&
        git submodule update -N &&
        mv submod submod-movedaside &&
@@ -555,7 +579,7 @@ test_expect_success 'directory vs modified submodule' '
        test "$(cat submod/file16)" = "not a submodule" &&
        rm -rf submod.orig &&
 
-       git reset --hard >/dev/null 2>&1 &&
+       git reset --hard &&
        test_must_fail git merge master &&
        test -n "$(git ls-files -u)" &&
        test ! -e submod.orig &&
@@ -567,7 +591,8 @@ test_expect_success 'directory vs modified submodule' '
        ( cd submod && git clean -f && git reset --hard ) &&
        git submodule update -N &&
        test "$(cat submod/bar)" = "master submodule" &&
-       git reset --hard >/dev/null 2>&1 && rm -rf submod-movedaside &&
+       git reset --hard &&
+       rm -rf submod-movedaside &&
 
        git checkout -b test$test_count.c master &&
        git submodule update -N &&
@@ -577,7 +602,7 @@ test_expect_success 'directory vs modified submodule' '
        git submodule update -N &&
        test "$(cat submod/bar)" = "master submodule" &&
 
-       git reset --hard >/dev/null 2>&1 &&
+       git reset --hard &&
        git submodule update -N &&
        test_must_fail git merge test$test_count &&
        test -n "$(git ls-files -u)" &&
@@ -585,13 +610,13 @@ test_expect_success 'directory vs modified submodule' '
        ( yes "r" | git mergetool submod ) &&
        test "$(cat submod/file16)" = "not a submodule" &&
 
-       git reset --hard master >/dev/null 2>&1 &&
+       git reset --hard master &&
        ( cd submod && git clean -f && git reset --hard ) &&
        git submodule update -N
 '
 
 test_expect_success 'file with no base' '
-       test_when_finished "git reset --hard master >/dev/null 2>&1" &&
+       test_when_finished "git reset --hard" &&
        git checkout -b test$test_count branch1 &&
        test_must_fail git merge master &&
        git mergetool --no-prompt --tool mybase -- both &&
@@ -600,7 +625,7 @@ test_expect_success 'file with no base' '
 '
 
 test_expect_success 'custom commands override built-ins' '
-       test_when_finished "git reset --hard master >/dev/null 2>&1" &&
+       test_when_finished "git reset --hard" &&
        git checkout -b test$test_count branch1 &&
        test_config mergetool.defaults.cmd "cat \"\$REMOTE\" >\"\$MERGED\"" &&
        test_config mergetool.defaults.trustExitCode true &&
@@ -611,7 +636,7 @@ test_expect_success 'custom commands override built-ins' '
 '
 
 test_expect_success 'filenames seen by tools start with ./' '
-       test_when_finished "git reset --hard master >/dev/null 2>&1" &&
+       test_when_finished "git reset --hard" &&
        git checkout -b test$test_count branch1 &&
        test_config mergetool.writeToTemp false &&
        test_config mergetool.myecho.cmd "echo \"\$LOCAL\"" &&
@@ -628,20 +653,20 @@ test_lazy_prereq MKTEMP '
 '
 
 test_expect_success MKTEMP 'temporary filenames are used with mergetool.writeToTemp' '
-       test_when_finished "git reset --hard master >/dev/null 2>&1" &&
+       test_when_finished "git reset --hard" &&
        git checkout -b test$test_count branch1 &&
        test_config mergetool.writeToTemp true &&
        test_config mergetool.myecho.cmd "echo \"\$LOCAL\"" &&
        test_config mergetool.myecho.trustExitCode true &&
        test_must_fail git merge master &&
        git mergetool --no-prompt --tool myecho -- both >actual &&
-       test_must_fail grep ^\./both_LOCAL_ actual >/dev/null &&
+       ! grep ^\./both_LOCAL_ actual >/dev/null &&
        grep /both_LOCAL_ actual >/dev/null
 '
 
 test_expect_success 'diff.orderFile configuration is honored' '
-       test_when_finished "git reset --hard >/dev/null" &&
-       git checkout order-file-side2 &&
+       test_when_finished "git reset --hard" &&
+       git checkout -b test$test_count order-file-side2 &&
        test_config diff.orderFile order-file &&
        test_config mergetool.myecho.cmd "echo \"\$LOCAL\"" &&
        test_config mergetool.myecho.trustExitCode true &&
@@ -653,12 +678,18 @@ test_expect_success 'diff.orderFile configuration is honored' '
                b
                a
        EOF
+
+       # make sure "order-file" that is ambiguous between
+       # rev and path is understood correctly.
+       git branch order-file HEAD &&
+
        git mergetool --no-prompt --tool myecho >output &&
        git grep --no-index -h -A2 Merging: output >actual &&
        test_cmp expect actual
 '
 test_expect_success 'mergetool -Oorder-file is honored' '
-       test_when_finished "git reset --hard >/dev/null 2>&1" &&
+       test_when_finished "git reset --hard" &&
+       git checkout -b test$test_count order-file-side2 &&
        test_config diff.orderFile order-file &&
        test_config mergetool.myecho.cmd "echo \"\$LOCAL\"" &&
        test_config mergetool.myecho.trustExitCode true &&
@@ -673,7 +704,7 @@ test_expect_success 'mergetool -Oorder-file is honored' '
        git mergetool -O/dev/null --no-prompt --tool myecho >output &&
        git grep --no-index -h -A2 Merging: output >actual &&
        test_cmp expect actual &&
-       git reset --hard >/dev/null 2>&1 &&
+       git reset --hard &&
 
        git config --unset diff.orderFile &&
        test_must_fail git merge order-file-side1 &&