]> git.ipfire.org Git - thirdparty/git.git/blame - t/t6024-recursive-merge.sh
Merge branch 'ps/ref-transaction-hook'
[thirdparty/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
270de6ac
EN
17test_expect_success 'setup tests' '
18 echo 1 >a1 &&
19 git add a1 &&
20 GIT_AUTHOR_DATE="2006-12-12 23:00:00" git commit -m 1 a1 &&
21
22 git checkout -b A master &&
23 echo A >a1 &&
24 GIT_AUTHOR_DATE="2006-12-12 23:00:01" git commit -m A a1 &&
25
26 git checkout -b B master &&
27 echo B >a1 &&
28 GIT_AUTHOR_DATE="2006-12-12 23:00:02" git commit -m B a1 &&
29
30 git checkout -b D A &&
31 git rev-parse B >.git/MERGE_HEAD &&
32 echo D >a1 &&
33 git update-index a1 &&
34 GIT_AUTHOR_DATE="2006-12-12 23:00:03" git commit -m D &&
35
36 git symbolic-ref HEAD refs/heads/other &&
37 echo 2 >a1 &&
38 GIT_AUTHOR_DATE="2006-12-12 23:00:04" git commit -m 2 a1 &&
39
40 git checkout -b C &&
41 echo C >a1 &&
42 GIT_AUTHOR_DATE="2006-12-12 23:00:05" git commit -m C a1 &&
43
44 git checkout -b E C &&
45 git rev-parse B >.git/MERGE_HEAD &&
46 echo E >a1 &&
47 git update-index a1 &&
48 GIT_AUTHOR_DATE="2006-12-12 23:00:06" git commit -m E &&
49
50 git checkout -b G E &&
51 git rev-parse A >.git/MERGE_HEAD &&
52 echo G >a1 &&
53 git update-index a1 &&
54 GIT_AUTHOR_DATE="2006-12-12 23:00:07" git commit -m G &&
55
56 git checkout -b F D &&
57 git rev-parse C >.git/MERGE_HEAD &&
58 echo F >a1 &&
59 git update-index a1 &&
f3037657 60 GIT_AUTHOR_DATE="2006-12-12 23:00:08" git commit -m F &&
61
62 test_oid_cache <<-EOF
63 idxstage1 sha1:ec3fe2a791706733f2d8fa7ad45d9a9672031f5e
64 idxstage1 sha256:b3c8488929903aaebdeb22270cb6d36e5b8724b01ae0d4da24632f158c99676f
65 EOF
7d2ba122 66'
c93be3b5 67
859fdc0c
DS
68test_expect_success 'combined merge conflicts' '
69 test_must_fail env GIT_TEST_COMMIT_GRAPH=0 git merge -m final G
70'
c93be3b5 71
270de6ac
EN
72test_expect_success 'result contains a conflict' '
73 cat >expect <<-\EOF &&
74 <<<<<<< HEAD
75 F
76 =======
77 G
78 >>>>>>> G
79 EOF
f953831e 80
270de6ac
EN
81 test_cmp expect a1
82'
83
84test_expect_success 'virtual trees were processed' '
85 git ls-files --stage >out &&
f953831e 86
f3037657 87 cat >expect <<-EOF &&
88 100644 $(test_oid idxstage1) 1 a1
89 100644 $(git rev-parse F:a1) 2 a1
90 100644 $(git rev-parse G:a1) 3 a1
270de6ac 91 EOF
c93be3b5 92
270de6ac
EN
93 test_cmp expect out
94'
c93be3b5 95
9f30855d 96test_expect_success 'refuse to merge binary files' '
c3b088d9 97 git reset --hard &&
270de6ac 98 printf "\0" >binary-file &&
9f30855d
JS
99 git add binary-file &&
100 git commit -m binary &&
101 git checkout G &&
270de6ac 102 printf "\0\0" >binary-file &&
9f30855d
JS
103 git add binary-file &&
104 git commit -m binary2 &&
270de6ac 105 test_must_fail git merge F >merge.out 2>merge.err &&
606475f3 106 grep "Cannot merge binary files: binary-file (HEAD vs. F)" merge.err
9f30855d
JS
107'
108
36e3b5ea
JS
109test_expect_success 'mark rename/delete as unmerged' '
110
111 git reset --hard &&
112 git checkout -b delete &&
113 git rm a1 &&
114 test_tick &&
115 git commit -m delete &&
116 git checkout -b rename HEAD^ &&
a48fcd83 117 git mv a1 a2 &&
36e3b5ea
JS
118 test_tick &&
119 git commit -m rename &&
120 test_must_fail git merge delete &&
121 test 1 = $(git ls-files --unmerged | wc -l) &&
122 git rev-parse --verify :2:a2 &&
123 test_must_fail git rev-parse --verify :3:a2 &&
124 git checkout -f delete &&
125 test_must_fail git merge rename &&
126 test 1 = $(git ls-files --unmerged | wc -l) &&
127 test_must_fail git rev-parse --verify :2:a2 &&
128 git rev-parse --verify :3:a2
36e3b5ea
JS
129'
130
c93be3b5 131test_done