3 test_description
='Test merge without common ancestors'
4 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
=main
5 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
9 # This scenario is based on a real-world repository of Shawn Pearce.
17 GIT_COMMITTER_DATE
="2006-12-12 23:28:00 +0100"
18 export GIT_COMMITTER_DATE
20 test_expect_success
'setup tests' '
23 GIT_AUTHOR_DATE="2006-12-12 23:00:00" git commit -m 1 a1 &&
25 git checkout -b A main &&
27 GIT_AUTHOR_DATE="2006-12-12 23:00:01" git commit -m A a1 &&
29 git checkout -b B main &&
31 GIT_AUTHOR_DATE="2006-12-12 23:00:02" git commit -m B a1 &&
33 git checkout -b D A &&
34 git rev-parse B >.git/MERGE_HEAD &&
36 git update-index a1 &&
37 GIT_AUTHOR_DATE="2006-12-12 23:00:03" git commit -m D &&
39 git symbolic-ref HEAD refs/heads/other &&
41 GIT_AUTHOR_DATE="2006-12-12 23:00:04" git commit -m 2 a1 &&
45 GIT_AUTHOR_DATE="2006-12-12 23:00:05" git commit -m C a1 &&
47 git checkout -b E C &&
48 git rev-parse B >.git/MERGE_HEAD &&
50 git update-index a1 &&
51 GIT_AUTHOR_DATE="2006-12-12 23:00:06" git commit -m E &&
53 git checkout -b G E &&
54 git rev-parse A >.git/MERGE_HEAD &&
56 git update-index a1 &&
57 GIT_AUTHOR_DATE="2006-12-12 23:00:07" git commit -m G &&
59 git checkout -b F D &&
60 git rev-parse C >.git/MERGE_HEAD &&
62 git update-index a1 &&
63 GIT_AUTHOR_DATE="2006-12-12 23:00:08" git commit -m F &&
66 idxstage1 sha1:ec3fe2a791706733f2d8fa7ad45d9a9672031f5e
67 idxstage1 sha256:b3c8488929903aaebdeb22270cb6d36e5b8724b01ae0d4da24632f158c99676f
71 test_expect_success
'combined merge conflicts' '
72 test_must_fail env GIT_TEST_COMMIT_GRAPH=0 git merge -m final G
75 test_expect_success
'result contains a conflict' '
76 cat >expect <<-\EOF &&
87 test_expect_success
'virtual trees were processed' '
88 git ls-files --stage >out &&
91 100644 $(test_oid idxstage1) 1 a1
92 100644 $(git rev-parse F:a1) 2 a1
93 100644 $(git rev-parse G:a1) 3 a1
99 test_expect_success
'refuse to merge binary files' '
101 printf "\0" >binary-file &&
102 git add binary-file &&
103 git commit -m binary &&
105 printf "\0\0" >binary-file &&
106 git add binary-file &&
107 git commit -m binary2 &&
108 test_must_fail git merge F >merge.out 2>merge.err &&
109 grep "Cannot merge binary files: binary-file (HEAD vs. F)" merge.err
112 test_expect_success
'mark rename/delete as unmerged' '
115 git checkout -b delete &&
118 git commit -m delete &&
119 git checkout -b rename HEAD^ &&
122 git commit -m rename &&
123 test_must_fail git merge delete &&
124 if test "$GIT_TEST_MERGE_ALGORITHM" = ort
126 test 2 = $(git ls-files --unmerged | wc -l)
128 test 1 = $(git ls-files --unmerged | wc -l)
130 git rev-parse --verify :2:a2 &&
131 test_must_fail git rev-parse --verify :3:a2 &&
132 git checkout -f delete &&
133 test_must_fail git merge rename &&
134 if test "$GIT_TEST_MERGE_ALGORITHM" = ort
136 test 2 = $(git ls-files --unmerged | wc -l)
138 test 1 = $(git ls-files --unmerged | wc -l)
140 test_must_fail git rev-parse --verify :2:a2 &&
141 git rev-parse --verify :3:a2