Raw
1 #!/bin/sh
2 #
3 # Copyright (c) 2005 Fredrik Kuivinen
4 #
5
6 # See https://lore.kernel.org/git/Pine.LNX.4.44.0504271254120.4678-100000@wax.eds.org/ for a
7 # nice description of what this is about.
8
9
10 test_description='Test criss-cross merge'
11
12 . ./test-lib.sh
13
14 test_expect_success 'prepare repository' '
15 test_write_lines 1 2 3 4 5 6 7 8 9 >file &&
16 git add file &&
17 git commit -m "Initial commit" file &&
18
19 git branch A &&
20 git branch B &&
21 git checkout A &&
22
23 test_write_lines 1 2 3 4 5 6 7 "8 changed in B8, branch A" 9 >file &&
24 git commit -m "B8" file &&
25 git checkout B &&
26
27 test_write_lines 1 2 "3 changed in C3, branch B" 4 5 6 7 8 9 >file &&
28 git commit -m "C3" file &&
29 git branch C3 &&
30
31 git merge -m "pre E3 merge" A &&
32
33 test_write_lines 1 2 "3 changed in E3, branch B. New file size" 4 5 6 7 "8 changed in B8, branch A" 9 >file &&
34 git commit -m "E3" file &&
35
36 git checkout A &&
37 git merge -m "pre D8 merge" C3 &&
38 test_write_lines 1 2 "3 changed in C3, branch B" 4 5 6 7 "8 changed in D8, branch A. New file size 2" 9 >file &&
39
40 git commit -m D8 file
41 '
42
43 test_expect_success 'Criss-cross merge' '
44 git merge -m "final merge" B
45 '
46
47 test_expect_success 'Criss-cross merge result' '
48 cat <<-\EOF >file-expect &&
49 1
50 2
51 3 changed in E3, branch B. New file size
52 4
53 5
54 6
55 7
56 8 changed in D8, branch A. New file size 2
57 9
58 EOF
59
60 test_cmp file-expect file
61 '
62
63 test_expect_success 'Criss-cross merge fails (-s resolve)' '
64 git reset --hard A^ &&
65 test_must_fail git merge -s resolve -m "final merge" B
66 '
67
68 test_done