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' '
21 GIT_TEST_COMMIT_GRAPH=0 &&
22 export GIT_TEST_COMMIT_GRAPH &&
25 GIT_AUTHOR_DATE="2006-12-12 23:00:00" git commit -m 1 a1 &&
27 git checkout -b A main &&
29 GIT_AUTHOR_DATE="2006-12-12 23:00:01" git commit -m A a1 &&
31 git checkout -b B main &&
33 GIT_AUTHOR_DATE="2006-12-12 23:00:02" git commit -m B a1 &&
35 git checkout -b D A &&
36 git rev-parse B >.git/MERGE_HEAD &&
38 git update-index a1 &&
39 GIT_AUTHOR_DATE="2006-12-12 23:00:03" git commit -m D &&
41 git symbolic-ref HEAD refs/heads/other &&
43 GIT_AUTHOR_DATE="2006-12-12 23:00:04" git commit -m 2 a1 &&
47 GIT_AUTHOR_DATE="2006-12-12 23:00:05" git commit -m C a1 &&
49 git checkout -b E C &&
50 git rev-parse B >.git/MERGE_HEAD &&
52 git update-index a1 &&
53 GIT_AUTHOR_DATE="2006-12-12 23:00:06" git commit -m E &&
55 git checkout -b G E &&
56 git rev-parse A >.git/MERGE_HEAD &&
58 git update-index a1 &&
59 GIT_AUTHOR_DATE="2006-12-12 23:00:07" git commit -m G &&
61 git checkout -b F D &&
62 git rev-parse C >.git/MERGE_HEAD &&
64 git update-index a1 &&
65 GIT_AUTHOR_DATE="2006-12-12 23:00:08" git commit -m F &&
68 idxstage1 sha1:ec3fe2a791706733f2d8fa7ad45d9a9672031f5e
69 idxstage1 sha256:b3c8488929903aaebdeb22270cb6d36e5b8724b01ae0d4da24632f158c99676f
73 test_expect_success
'combined merge conflicts' '
74 test_must_fail git merge -m final G
77 test_expect_success
'result contains a conflict' '
78 cat >expect <<-\EOF &&
89 test_expect_success
'virtual trees were processed' '
90 # TODO: fragile test, relies on ambigious merge-base resolution
91 git ls-files --stage >out &&
94 100644 $(test_oid idxstage1) 1 a1
95 100644 $(git rev-parse F:a1) 2 a1
96 100644 $(git rev-parse G:a1) 3 a1
102 test_expect_success
'refuse to merge binary files' '
104 printf "\0" >binary-file &&
105 git add binary-file &&
106 git commit -m binary &&
108 printf "\0\0" >binary-file &&
109 git add binary-file &&
110 git commit -m binary2 &&
111 test_must_fail git merge F >merge.out 2>merge.err &&
112 grep "Cannot merge binary files: binary-file (HEAD vs. F)" merge.err
115 test_expect_success
'mark rename/delete as unmerged' '
118 git checkout -b delete &&
121 git commit -m delete &&
122 git checkout -b rename HEAD^ &&
125 git commit -m rename &&
126 test_must_fail git merge delete &&
127 if test "$GIT_TEST_MERGE_ALGORITHM" = ort
129 test 2 = $(git ls-files --unmerged | wc -l)
131 test 1 = $(git ls-files --unmerged | wc -l)
133 git rev-parse --verify :2:a2 &&
134 test_must_fail git rev-parse --verify :3:a2 &&
135 git checkout -f delete &&
136 test_must_fail git merge rename &&
137 if test "$GIT_TEST_MERGE_ALGORITHM" = ort
139 test 2 = $(git ls-files --unmerged | wc -l)
141 test 1 = $(git ls-files --unmerged | wc -l)
143 test_must_fail git rev-parse --verify :2:a2 &&
144 git rev-parse --verify :3:a2