]> git.ipfire.org Git - thirdparty/git.git/blame - t/t6427-diff3-conflict-markers.sh
Doc: no midx and partial clone relation
[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
5902f5f4 5GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
334afbc7
JS
6export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
7
743474cb
EN
8. ./test-lib.sh
9
10# Setup:
11# L1
12# \
13# ?
14# /
15# R1
16#
17# Where:
18# L1 and R1 both have a file named 'content' but have no common history
19#
20
21test_expect_success 'setup no merge base' '
22 test_create_repo no_merge_base &&
23 (
24 cd no_merge_base &&
25
26 git checkout -b L &&
27 test_commit A content A &&
28
29 git checkout --orphan R &&
30 test_commit B content B
31 )
32'
33
34test_expect_success 'check no merge base' '
35 (
36 cd no_merge_base &&
37
38 git checkout L^0 &&
39
40 test_must_fail git -c merge.conflictstyle=diff3 merge --allow-unrelated-histories -s recursive R^0 &&
41
42 grep "|||||| empty tree" content
43 )
44'
45
46# Setup:
47# L1
48# / \
5902f5f4 49# main ?
743474cb
EN
50# \ /
51# R1
52#
53# Where:
54# L1 and R1 have modified the same file ('content') in conflicting ways
55#
56
57test_expect_success 'setup unique merge base' '
58 test_create_repo unique_merge_base &&
59 (
60 cd unique_merge_base &&
61
62 test_commit base content "1
632
643
654
665
67" &&
68
69 git branch L &&
70 git branch R &&
71
72 git checkout L &&
73 test_commit L content "1
742
753
764
775
787" &&
79
80 git checkout R &&
81 git rm content &&
82 test_commit R renamed "1
832
843
854
865
87six"
88 )
89'
90
91test_expect_success 'check unique merge base' '
92 (
93 cd unique_merge_base &&
94
95 git checkout L^0 &&
5902f5f4 96 MAIN=$(git rev-parse --short main) &&
743474cb
EN
97
98 test_must_fail git -c merge.conflictstyle=diff3 merge -s recursive R^0 &&
99
5902f5f4 100 grep "|||||| $MAIN:content" renamed
743474cb
EN
101 )
102'
103
104# Setup:
105# L1---L2--L3
106# / \ / \
5902f5f4 107# main X1 ?
743474cb
EN
108# \ / \ /
109# R1---R2--R3
110#
111# Where:
112# commits L1 and R1 have modified the same file in non-conflicting ways
113# X1 is an auto-generated merge-base used when merging L1 and R1
114# commits L2 and R2 are merges of R1 and L1 into L1 and R1, respectively
115# commits L3 and R3 both modify 'content' in conflicting ways
116#
117
118test_expect_success 'setup multiple merge bases' '
119 test_create_repo multiple_merge_bases &&
120 (
121 cd multiple_merge_bases &&
122
123 test_commit initial content "1
1242
1253
1264
1275" &&
128
129 git branch L &&
130 git branch R &&
131
132 # Create L1
133 git checkout L &&
134 test_commit L1 content "0
1351
1362
1373
1384
1395" &&
140
141 # Create R1
142 git checkout R &&
143 test_commit R1 content "1
1442
1453
1464
1475
1486" &&
149
150 # Create L2
151 git checkout L &&
152 git merge R1 &&
153
154 # Create R2
155 git checkout R &&
156 git merge L1 &&
157
158 # Create L3
159 git checkout L &&
160 test_commit L3 content "0
1611
1622
1633
1644
1655
166A" &&
167
168 # Create R3
169 git checkout R &&
170 git rm content &&
171 test_commit R3 renamed "0
1722
1733
1744
1755
176six"
177 )
178'
179
180test_expect_success 'check multiple merge bases' '
181 (
182 cd multiple_merge_bases &&
183
184 git checkout L^0 &&
185
186 test_must_fail git -c merge.conflictstyle=diff3 merge -s recursive R^0 &&
187
188 grep "|||||| merged common ancestors:content" renamed
189 )
190'
191
76340c81 192test_expect_success 'rebase --merge describes parent of commit being picked' '
8e4ec337
EN
193 test_create_repo rebase &&
194 (
195 cd rebase &&
196 test_commit base file &&
5902f5f4 197 test_commit main file &&
8e4ec337
EN
198 git checkout -b side HEAD^ &&
199 test_commit side file &&
5902f5f4 200 test_must_fail git -c merge.conflictstyle=diff3 rebase --merge main &&
76340c81
EN
201 grep "||||||| parent of" file
202 )
203'
204
10cdb9f3 205test_expect_success 'rebase --apply describes fake ancestor base' '
76340c81
EN
206 (
207 cd rebase &&
208 git rebase --abort &&
5902f5f4 209 test_must_fail git -c merge.conflictstyle=diff3 rebase --apply main &&
8e4ec337
EN
210 grep "||||||| constructed merge base" file
211 )
212'
213
743474cb 214test_done