1#!/bin/sh
2
3test_description='recursive merge corner cases'
4
5. ./test-lib.sh
6
7#
8# L1 L2
9# o---o
10# / \ / \
11# o X ?
12# \ / \ /
13# o---o
14# R1 R2
15#
16
17test_expect_success 'setup basic criss-cross + rename with no modifications' '
18 ten="0 1 2 3 4 5 6 7 8 9"
19 for i in $ten
20 do
21 echo line $i in a sample file
22 done >one &&
23 for i in $ten
24 do
25 echo line $i in another sample file
26 done >two &&
27 git add one two &&
28 test_tick && git commit -m initial &&
29
30 git branch L1 &&
31 git checkout -b R1 &&
32 git mv one three &&
33 test_tick && git commit -m R1 &&
34
35 git checkout L1 &&
36 git mv two three &&
37 test_tick && git commit -m L1 &&
38
39 git checkout L1^0 &&
40 test_tick && git merge -s ours R1 &&
41 git tag L2 &&
42
43 git checkout R1^0 &&
44 test_tick && git merge -s ours L1 &&
45 git tag R2
46'
47
48test_expect_success 'merge simple rename+criss-cross with no modifications' '
49 git reset --hard &&
50 git checkout L2^0 &&
51
52 test_must_fail git merge -s recursive R2^0 &&
53
54 test 5 = $(git ls-files -s | wc -l) &&
55 test 3 = $(git ls-files -u | wc -l) &&
56 test 0 = $(git ls-files -o | wc -l) &&
57
58 test $(git rev-parse :0:one) = $(git rev-parse L2:one) &&
59 test $(git rev-parse :0:two) = $(git rev-parse R2:two) &&
60 test $(git rev-parse :2:three) = $(git rev-parse L2:three) &&
61 test $(git rev-parse :3:three) = $(git rev-parse R2:three) &&
62
63 cp two merged &&
64 >empty &&
65 test_must_fail git merge-file \
66 -L "Temporary merge branch 2" \
67 -L "" \
68 -L "Temporary merge branch 1" \
69 merged empty one &&
70 test $(git rev-parse :1:three) = $(git hash-object merged)
71'
72
73test_done