3 test_description
='Test merge without common ancestors'
4 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
=main
5 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
7 TEST_PASSES_SANITIZE_LEAK
=true
10 # This scenario is based on a real-world repository of Shawn Pearce.
18 GIT_COMMITTER_DATE
="2006-12-12 23:28:00 +0100"
19 export GIT_COMMITTER_DATE
21 test_expect_success
'setup tests' '
22 GIT_TEST_COMMIT_GRAPH=0 &&
23 export GIT_TEST_COMMIT_GRAPH &&
26 GIT_AUTHOR_DATE="2006-12-12 23:00:00" git commit -m 1 a1 &&
28 git checkout -b A main &&
30 GIT_AUTHOR_DATE="2006-12-12 23:00:01" git commit -m A a1 &&
32 git checkout -b B main &&
34 GIT_AUTHOR_DATE="2006-12-12 23:00:02" git commit -m B a1 &&
36 git checkout -b D A &&
37 git rev-parse B >.git/MERGE_HEAD &&
39 git update-index a1 &&
40 GIT_AUTHOR_DATE="2006-12-12 23:00:03" git commit -m D &&
42 git symbolic-ref HEAD refs/heads/other &&
44 GIT_AUTHOR_DATE="2006-12-12 23:00:04" git commit -m 2 a1 &&
48 GIT_AUTHOR_DATE="2006-12-12 23:00:05" git commit -m C a1 &&
50 git checkout -b E C &&
51 git rev-parse B >.git/MERGE_HEAD &&
53 git update-index a1 &&
54 GIT_AUTHOR_DATE="2006-12-12 23:00:06" git commit -m E &&
56 git checkout -b G E &&
57 git rev-parse A >.git/MERGE_HEAD &&
59 git update-index a1 &&
60 GIT_AUTHOR_DATE="2006-12-12 23:00:07" git commit -m G &&
62 git checkout -b F D &&
63 git rev-parse C >.git/MERGE_HEAD &&
65 git update-index a1 &&
66 GIT_AUTHOR_DATE="2006-12-12 23:00:08" git commit -m F &&
69 idxstage1 sha1:ec3fe2a791706733f2d8fa7ad45d9a9672031f5e
70 idxstage1 sha256:b3c8488929903aaebdeb22270cb6d36e5b8724b01ae0d4da24632f158c99676f
74 test_expect_success
'combined merge conflicts' '
75 test_must_fail git merge -m final G
78 test_expect_success
'result contains a conflict' '
79 cat >expect <<-\EOF &&
90 test_expect_success
'virtual trees were processed' '
91 # TODO: fragile test, relies on ambiguous merge-base resolution
92 git ls-files --stage >out &&
95 100644 $(test_oid idxstage1) 1 a1
96 100644 $(git rev-parse F:a1) 2 a1
97 100644 $(git rev-parse G:a1) 3 a1
103 test_expect_success
'refuse to merge binary files' '
105 printf "\0" >binary-file &&
106 git add binary-file &&
107 git commit -m binary &&
109 printf "\0\0" >binary-file &&
110 git add binary-file &&
111 git commit -m binary2 &&
112 if test "$GIT_TEST_MERGE_ALGORITHM" = ort
114 test_must_fail git merge F >merge_output
116 test_must_fail git merge F 2>merge_output
118 grep "Cannot merge binary files: binary-file (HEAD vs. F)" merge_output
121 test_expect_success
'mark rename/delete as unmerged' '
124 git checkout -b delete &&
127 git commit -m delete &&
128 git checkout -b rename HEAD^ &&
131 git commit -m rename &&
132 test_must_fail git merge delete &&
133 if test "$GIT_TEST_MERGE_ALGORITHM" = ort
135 test 2 = $(git ls-files --unmerged | wc -l)
137 test 1 = $(git ls-files --unmerged | wc -l)
139 git rev-parse --verify :2:a2 &&
140 test_must_fail git rev-parse --verify :3:a2 &&
141 git checkout -f delete &&
142 test_must_fail git merge rename &&
143 if test "$GIT_TEST_MERGE_ALGORITHM" = ort
145 test 2 = $(git ls-files --unmerged | wc -l)
147 test 1 = $(git ls-files --unmerged | wc -l)
149 test_must_fail git rev-parse --verify :2:a2 &&
150 git rev-parse --verify :3:a2