Skip to content

Commit 47349a8

Browse files
jrngitster
authored andcommitted
tests: document format of conflicts from checkout -m
We are about to change the format of the conflict hunks that ‘checkout --merge’ writes. Add tests checking the current behavior first. Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 0d0925c commit 47349a8

File tree

1 file changed

+61
-4
lines changed

1 file changed

+61
-4
lines changed

t/t7201-co.sh

Lines changed: 61 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@ Test switching across them.
1111
! [master] Initial A one, A two
1212
* [renamer] Renamer R one->uno, M two
1313
! [side] Side M one, D two, A three
14-
---
15-
+ [side] Side M one, D two, A three
16-
* [renamer] Renamer R one->uno, M two
17-
+*+ [master] Initial A one, A two
14+
! [simple] Simple D one, M two
15+
----
16+
+ [simple] Simple D one, M two
17+
+ [side] Side M one, D two, A three
18+
* [renamer] Renamer R one->uno, M two
19+
+*++ [master] Initial A one, A two
1820
1921
'
2022

@@ -52,6 +54,11 @@ test_expect_success setup '
5254
git update-index --add --remove one two three &&
5355
git commit -m "Side M one, D two, A three" &&
5456
57+
git checkout -b simple master &&
58+
rm -f one &&
59+
fill a c e > two &&
60+
git commit -a -m "Simple D one, M two" &&
61+
5562
git checkout master
5663
'
5764

@@ -166,6 +173,56 @@ test_expect_success 'checkout -m with merge conflict' '
166173
! test -s current
167174
'
168175

176+
test_expect_success 'format of merge conflict from checkout -m' '
177+
178+
git checkout -f master && git clean -f &&
179+
180+
fill b d > two &&
181+
git checkout -m simple &&
182+
183+
git ls-files >current &&
184+
fill same two two two >expect &&
185+
test_cmp current expect &&
186+
187+
cat <<-EOF >expect &&
188+
<<<<<<< simple
189+
a
190+
c
191+
e
192+
=======
193+
b
194+
d
195+
>>>>>>> local
196+
EOF
197+
test_cmp two expect
198+
'
199+
200+
test_expect_success 'checkout --merge --conflict=diff3 <branch>' '
201+
202+
git checkout -f master && git reset --hard && git clean -f &&
203+
204+
fill b d > two &&
205+
git checkout --merge --conflict=diff3 simple &&
206+
207+
cat <<-EOF >expect &&
208+
<<<<<<< simple
209+
a
210+
c
211+
e
212+
|||||||
213+
a
214+
b
215+
c
216+
d
217+
e
218+
=======
219+
b
220+
d
221+
>>>>>>> local
222+
EOF
223+
test_cmp two expect
224+
'
225+
169226
test_expect_success 'checkout to detach HEAD (with advice declined)' '
170227
171228
git config advice.detachedHead false &&

0 commit comments

Comments
 (0)