]> git.ipfire.org Git - thirdparty/git.git/blobdiff - t/t4108-apply-threeway.sh
Merge branch 'js/update-index-ignore-removal-for-skip-worktree'
[thirdparty/git.git] / t / t4108-apply-threeway.sh
index b109ecbd9fc76eb505d089f2b62bbb7d496eb0c1..d7349ced6be0aa1d717dbd0c312a65c8314235b3 100755 (executable)
@@ -4,11 +4,12 @@ test_description='git apply --3way'
 
 . ./test-lib.sh
 
-sanitize_conflicted_diff () {
+print_sanitized_conflicted_diff () {
+       git diff HEAD >diff.raw &&
        sed -e '
                /^index /d
-               s/^\(+[<>][<>][<>][<>]*\) .*/\1/
-       '
+               s/^\(+[<>|][<>|][<>|][<>|]*\) .*/\1/
+       ' diff.raw
 }
 
 test_expect_success setup '
@@ -45,7 +46,7 @@ test_expect_success 'apply without --3way' '
        git diff-index --exit-code --cached HEAD
 '
 
-test_expect_success 'apply with --3way' '
+test_apply_with_3way () {
        # Merging side should be similar to applying this patch
        git diff ...side >P.diff &&
 
@@ -54,22 +55,31 @@ test_expect_success 'apply with --3way' '
        git checkout master^0 &&
        test_must_fail git merge --no-commit side &&
        git ls-files -s >expect.ls &&
-       git diff HEAD | sanitize_conflicted_diff >expect.diff &&
+       print_sanitized_conflicted_diff >expect.diff &&
 
        # should fail to apply
        git reset --hard &&
        git checkout master^0 &&
        test_must_fail git apply --index --3way P.diff &&
        git ls-files -s >actual.ls &&
-       git diff HEAD | sanitize_conflicted_diff >actual.diff &&
+       print_sanitized_conflicted_diff >actual.diff &&
 
        # The result should resemble the corresponding merge
        test_cmp expect.ls actual.ls &&
        test_cmp expect.diff actual.diff
+}
+
+test_expect_success 'apply with --3way' '
+       test_apply_with_3way
+'
+
+test_expect_success 'apply with --3way with merge.conflictStyle = diff3' '
+       test_config merge.conflictStyle diff3 &&
+       test_apply_with_3way
 '
 
 test_expect_success 'apply with --3way with rerere enabled' '
-       git config rerere.enabled true &&
+       test_config rerere.enabled true &&
 
        # Merging side should be similar to applying this patch
        git diff ...side >P.diff &&
@@ -114,7 +124,7 @@ test_expect_success 'apply -3 with add/add conflict setup' '
        git checkout adder^0 &&
        test_must_fail git merge --no-commit another &&
        git ls-files -s >expect.ls &&
-       git diff HEAD | sanitize_conflicted_diff >expect.diff
+       print_sanitized_conflicted_diff >expect.diff
 '
 
 test_expect_success 'apply -3 with add/add conflict' '
@@ -124,7 +134,7 @@ test_expect_success 'apply -3 with add/add conflict' '
        test_must_fail git apply --index --3way P.diff &&
        # ... and leave conflicts in the index and in the working tree
        git ls-files -s >actual.ls &&
-       git diff HEAD | sanitize_conflicted_diff >actual.diff &&
+       print_sanitized_conflicted_diff >actual.diff &&
 
        # The result should resemble the corresponding merge
        test_cmp expect.ls actual.ls &&