1
+#!/bin/sh
2
+
3
+test_description='recursive merge diff3 style conflict markers'
4
+
5
+. ./test-lib.sh
6
+
7
+# Setup:
8
+# L1
9
+# \
10
+# ?
11
+# /
12
+# R1
13
+#
14
+# Where:
15
+# L1 and R1 both have a file named 'content' but have no common history
16
+#
17
+
18
+test_expect_success 'setup no merge base' '
19
+ test_create_repo no_merge_base &&
20
+ (
21
+ cd no_merge_base &&
22
+
23
+ git checkout -b L &&
24
+ test_commit A content A &&
25
+
26
+ git checkout --orphan R &&
27
+ test_commit B content B
28
+ )
29
+'
30
+
31
+test_expect_success 'check no merge base' '
32
+ (
33
+ cd no_merge_base &&
34
+
35
+ git checkout L^0 &&
36
+
37
+ test_must_fail git -c merge.conflictstyle=diff3 merge --allow-unrelated-histories -s recursive R^0 &&
38
+
39
+ grep "|||||| empty tree" content
40
+ )
41
+'
42
+
43
+# Setup:
44
+# L1
45
+# / \
46
+# master ?
47
+# \ /
48
+# R1
49
+#
50
+# Where:
51
+# L1 and R1 have modified the same file ('content') in conflicting ways
52
+#
53
+
54
+test_expect_success 'setup unique merge base' '
55
+ test_create_repo unique_merge_base &&
56
+ (
57
+ cd unique_merge_base &&
58
+
59
+ test_commit base content "1
60
+2
61
+3
62
+4
63
+5
64
+" &&
65
+
66
+ git branch L &&
67
+ git branch R &&
68
+
69
+ git checkout L &&
70
+ test_commit L content "1
71
+2
72
+3
73
+4
74
+5
75
+7" &&
76
+
77
+ git checkout R &&
78
+ git rm content &&
79
+ test_commit R renamed "1
80
+2
81
+3
82
+4
83
+5
84
+six"
85
+ )
86
+'
87
+
88
+test_expect_success 'check unique merge base' '
89
+ (
90
+ cd unique_merge_base &&
91
+
92
+ git checkout L^0 &&
93
+ MASTER=$(git rev-parse --short master) &&
94
+
95
+ test_must_fail git -c merge.conflictstyle=diff3 merge -s recursive R^0 &&
96
+
97
+ grep "|||||| $MASTER:content" renamed
98
+ )
99
+'
100
+
101
+# Setup:
102
+# L1---L2--L3
103
+# / \ / \
104
+# master X1 ?
105
+# \ / \ /
106
+# R1---R2--R3
107
+#
108
+# Where:
109
+# commits L1 and R1 have modified the same file in non-conflicting ways
110
+# X1 is an auto-generated merge-base used when merging L1 and R1
111
+# commits L2 and R2 are merges of R1 and L1 into L1 and R1, respectively
112
+# commits L3 and R3 both modify 'content' in conflicting ways
113
+#
114
+
115
+test_expect_success 'setup multiple merge bases' '
116
+ test_create_repo multiple_merge_bases &&
117
+ (
118
+ cd multiple_merge_bases &&
119
+
120
+ test_commit initial content "1
121
+2
122
+3
123
+4
124
+5" &&
125
+
126
+ git branch L &&
127
+ git branch R &&
128
+
129
+ # Create L1
130
+ git checkout L &&
131
+ test_commit L1 content "0
132
+1
133
+2
134
+3
135
+4
136
+5" &&
137
+
138
+ # Create R1
139
+ git checkout R &&
140
+ test_commit R1 content "1
141
+2
142
+3
143
+4
144
+5
145
+6" &&
146
+
147
+ # Create L2
148
+ git checkout L &&
149
+ git merge R1 &&
150
+
151
+ # Create R2
152
+ git checkout R &&
153
+ git merge L1 &&
154
+
155
+ # Create L3
156
+ git checkout L &&
157
+ test_commit L3 content "0
158
+1
159
+2
160
+3
161
+4
162
+5
163
+A" &&
164
+
165
+ # Create R3
166
+ git checkout R &&
167
+ git rm content &&
168
+ test_commit R3 renamed "0
169
+2
170
+3
171
+4
172
+5
173
+six"
174
+ )
175
+'
176
+
177
+test_expect_success 'check multiple merge bases' '
178
+ (
179
+ cd multiple_merge_bases &&
180
+
181
+ git checkout L^0 &&
182
+
183
+ test_must_fail git -c merge.conflictstyle=diff3 merge -s recursive R^0 &&
184
+
185
+ grep "|||||| merged common ancestors:content" renamed
186
+ )
187
+'
188
+
189
+test_done