Git 2.19-rc1
[git/git.git] / t / t6024-recursive-merge.sh
CommitLineData
c93be3b5
JH
1#!/bin/sh
2
3test_description='Test merge without common ancestors'
4. ./test-lib.sh
5
6# This scenario is based on a real-world repository of Shawn Pearce.
7
8# 1 - A - D - F
9# \ X /
10# B X
11# X \
12# 2 - C - E - G
13
7d2ba122
EW
14GIT_COMMITTER_DATE="2006-12-12 23:28:00 +0100"
15export GIT_COMMITTER_DATE
16
17test_expect_success "setup tests" '
18echo 1 > a1 &&
19git add a1 &&
20GIT_AUTHOR_DATE="2006-12-12 23:00:00" git commit -m 1 a1 &&
21
22git checkout -b A master &&
23echo A > a1 &&
24GIT_AUTHOR_DATE="2006-12-12 23:00:01" git commit -m A a1 &&
25
26git checkout -b B master &&
27echo B > a1 &&
28GIT_AUTHOR_DATE="2006-12-12 23:00:02" git commit -m B a1 &&
29
30git checkout -b D A &&
5be60078 31git rev-parse B > .git/MERGE_HEAD &&
7d2ba122
EW
32echo D > a1 &&
33git update-index a1 &&
34GIT_AUTHOR_DATE="2006-12-12 23:00:03" git commit -m D &&
35
36git symbolic-ref HEAD refs/heads/other &&
37echo 2 > a1 &&
38GIT_AUTHOR_DATE="2006-12-12 23:00:04" git commit -m 2 a1 &&
39
40git checkout -b C &&
41echo C > a1 &&
42GIT_AUTHOR_DATE="2006-12-12 23:00:05" git commit -m C a1 &&
43
44git checkout -b E C &&
5be60078 45git rev-parse B > .git/MERGE_HEAD &&
7d2ba122
EW
46echo E > a1 &&
47git update-index a1 &&
48GIT_AUTHOR_DATE="2006-12-12 23:00:06" git commit -m E &&
49
50git checkout -b G E &&
5be60078 51git rev-parse A > .git/MERGE_HEAD &&
7d2ba122
EW
52echo G > a1 &&
53git update-index a1 &&
54GIT_AUTHOR_DATE="2006-12-12 23:00:07" git commit -m G &&
55
56git checkout -b F D &&
5be60078 57git rev-parse C > .git/MERGE_HEAD &&
7d2ba122
EW
58echo F > a1 &&
59git update-index a1 &&
c93be3b5 60GIT_AUTHOR_DATE="2006-12-12 23:00:08" git commit -m F
7d2ba122 61'
c93be3b5 62
d492b31c
SB
63test_expect_success "combined merge conflicts" "
64 test_must_fail git merge -m final G
65"
c93be3b5 66
f953831e 67cat > expect << EOF
606475f3 68<<<<<<< HEAD
f953831e
JS
69F
70=======
71G
606475f3 72>>>>>>> G
f953831e
JS
73EOF
74
3af82863 75test_expect_success "result contains a conflict" "test_cmp expect a1"
f953831e 76
c93be3b5
JH
77git ls-files --stage > out
78cat > expect << EOF
d694a179 79100644 ec3fe2a791706733f2d8fa7ad45d9a9672031f5e 1 a1
c93be3b5
JH
80100644 cf84443e49e1b366fac938711ddf4be2d4d1d9e9 2 a1
81100644 fd7923529855d0b274795ae3349c5e0438333979 3 a1
82EOF
83
3af82863 84test_expect_success "virtual trees were processed" "test_cmp expect out"
c93be3b5 85
9f30855d 86test_expect_success 'refuse to merge binary files' '
c3b088d9 87 git reset --hard &&
9f30855d
JS
88 printf "\0" > binary-file &&
89 git add binary-file &&
90 git commit -m binary &&
91 git checkout G &&
92 printf "\0\0" > binary-file &&
93 git add binary-file &&
94 git commit -m binary2 &&
d492b31c 95 test_must_fail git merge F > merge.out 2> merge.err &&
606475f3 96 grep "Cannot merge binary files: binary-file (HEAD vs. F)" merge.err
9f30855d
JS
97'
98
36e3b5ea
JS
99test_expect_success 'mark rename/delete as unmerged' '
100
101 git reset --hard &&
102 git checkout -b delete &&
103 git rm a1 &&
104 test_tick &&
105 git commit -m delete &&
106 git checkout -b rename HEAD^ &&
a48fcd83 107 git mv a1 a2 &&
36e3b5ea
JS
108 test_tick &&
109 git commit -m rename &&
110 test_must_fail git merge delete &&
111 test 1 = $(git ls-files --unmerged | wc -l) &&
112 git rev-parse --verify :2:a2 &&
113 test_must_fail git rev-parse --verify :3:a2 &&
114 git checkout -f delete &&
115 test_must_fail git merge rename &&
116 test 1 = $(git ls-files --unmerged | wc -l) &&
117 test_must_fail git rev-parse --verify :2:a2 &&
118 git rev-parse --verify :3:a2
119
120'
121
c93be3b5 122test_done