]> git.ipfire.org Git - thirdparty/git.git/blame - t/t6427-diff3-conflict-markers.sh
Merge branch 'ea/blame-use-oideq'
[thirdparty/git.git] / t / t6427-diff3-conflict-markers.sh
CommitLineData
743474cb
EN
1#!/bin/sh
2
3test_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
18test_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
31test_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
54test_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
602
613
624
635
64" &&
65
66 git branch L &&
67 git branch R &&
68
69 git checkout L &&
70 test_commit L content "1
712
723
734
745
757" &&
76
77 git checkout R &&
78 git rm content &&
79 test_commit R renamed "1
802
813
824
835
84six"
85 )
86'
87
88test_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
115test_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
1212
1223
1234
1245" &&
125
126 git branch L &&
127 git branch R &&
128
129 # Create L1
130 git checkout L &&
131 test_commit L1 content "0
1321
1332
1343
1354
1365" &&
137
138 # Create R1
139 git checkout R &&
140 test_commit R1 content "1
1412
1423
1434
1445
1456" &&
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
1581
1592
1603
1614
1625
163A" &&
164
165 # Create R3
166 git checkout R &&
167 git rm content &&
168 test_commit R3 renamed "0
1692
1703
1714
1725
173six"
174 )
175'
176
177test_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
76340c81 189test_expect_success 'rebase --merge describes parent of commit being picked' '
8e4ec337
EN
190 test_create_repo rebase &&
191 (
192 cd rebase &&
193 test_commit base file &&
194 test_commit master file &&
195 git checkout -b side HEAD^ &&
196 test_commit side file &&
76340c81
EN
197 test_must_fail git -c merge.conflictstyle=diff3 rebase --merge master &&
198 grep "||||||| parent of" file
199 )
200'
201
10cdb9f3 202test_expect_success 'rebase --apply describes fake ancestor base' '
76340c81
EN
203 (
204 cd rebase &&
205 git rebase --abort &&
10cdb9f3 206 test_must_fail git -c merge.conflictstyle=diff3 rebase --apply master &&
8e4ec337
EN
207 grep "||||||| constructed merge base" file
208 )
209'
210
743474cb 211test_done