The second batch
[git] / t / t6401-merge-criss-cross.sh
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 . ./test-lib.sh
12
13 test_expect_success 'prepare repository' '
14         test_write_lines 1 2 3 4 5 6 7 8 9 >file &&
15         git add file &&
16         git commit -m "Initial commit" file &&
17
18         git branch A &&
19         git branch B &&
20         git checkout A &&
21
22         test_write_lines 1 2 3 4 5 6 7 "8 changed in B8, branch A" 9 >file &&
23         git commit -m "B8" file &&
24         git checkout B &&
25
26         test_write_lines 1 2 "3 changed in C3, branch B" 4 5 6 7 8 9 >file &&
27         git commit -m "C3" file &&
28         git branch C3 &&
29
30         git merge -m "pre E3 merge" A &&
31
32         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 &&
33         git commit -m "E3" file &&
34
35         git checkout A &&
36         git merge -m "pre D8 merge" C3 &&
37         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 &&
38
39         git commit -m D8 file
40 '
41
42 test_expect_success 'Criss-cross merge' '
43         git merge -m "final merge" B
44 '
45
46 test_expect_success 'Criss-cross merge result' '
47         cat <<-\EOF >file-expect &&
48         1
49         2
50         3 changed in E3, branch B. New file size
51         4
52         5
53         6
54         7
55         8 changed in D8, branch A. New file size 2
56         9
57         EOF
58
59         test_cmp file-expect file
60 '
61
62 test_expect_success 'Criss-cross merge fails (-s resolve)' '
63         git reset --hard A^ &&
64         test_must_fail git merge -s resolve -m "final merge" B
65 '
66
67 test_done