Raw
1 #!/bin/sh
2
3 test_description='git merge and other operations that rely on merge
4
5 Testing the influence of the diff algorithm on the merge output.'
6
7 . ./test-lib.sh
8
9 test_expect_success 'setup' '
10 cp "$TEST_DIRECTORY"/t7615/base.c file.c &&
11 git add file.c &&
12 git commit -m c0 &&
13 git tag c0 &&
14 cp "$TEST_DIRECTORY"/t7615/ours.c file.c &&
15 git add file.c &&
16 git commit -m c1 &&
17 git tag c1 &&
18 git reset --hard c0 &&
19 cp "$TEST_DIRECTORY"/t7615/theirs.c file.c &&
20 git add file.c &&
21 git commit -m c2 &&
22 git tag c2
23 '
24
25 test_expect_success 'merge c2 to c1 with recursive merge strategy fails with the current default myers diff algorithm' '
26 git reset --hard c1 &&
27 test_must_fail git merge -s recursive -Xdiff-algorithm=myers c2
28 '
29
30 test_expect_success 'merge c2 to c1 with recursive merge strategy succeeds with -Xdiff-algorithm=histogram' '
31 git reset --hard c1 &&
32 git merge --strategy recursive -Xdiff-algorithm=histogram c2
33 '
34
35 test_expect_success 'merge c2 to c1 with recursive merge strategy succeeds with diff.algorithm = histogram' '
36 git reset --hard c1 &&
37 git config diff.algorithm histogram &&
38 git merge --strategy recursive c2
39 '
40
41 test_expect_success 'cherry-pick c2 to c1 with recursive merge strategy fails with the current default myers diff algorithm' '
42 git reset --hard c1 &&
43 test_must_fail git cherry-pick -s recursive -Xdiff-algorithm=myers c2
44 '
45
46 test_expect_success 'cherry-pick c2 to c1 with recursive merge strategy succeeds with -Xdiff-algorithm=histogram' '
47 git reset --hard c1 &&
48 git cherry-pick --strategy recursive -Xdiff-algorithm=histogram c2
49 '
50
51 test_expect_success 'cherry-pick c2 to c1 with recursive merge strategy succeeds with diff.algorithm = histogram' '
52 git reset --hard c1 &&
53 git config diff.algorithm histogram &&
54 git cherry-pick --strategy recursive c2
55 '
56
57 test_done