3 test_description
='"git merge" top-level frontend'
8 git checkout
-B master two
&&
9 git branch
-f left three
&&
10 git branch
-f right four
13 test_expect_success setup
'
22 git checkout --orphan newroot &&
29 test_expect_success
'merge an octopus into void' '
31 git checkout --orphan test &&
33 test_must_fail git merge left right &&
34 test_must_fail git rev-parse --verify HEAD &&
36 test_must_fail git rev-parse HEAD
39 test_expect_success
'merge an octopus, fast-forward (ff)' '
41 git reset --hard one &&
42 git merge left right &&
43 # one is ancestor of three (left) and four (right)
44 test_must_fail git rev-parse --verify HEAD^3 &&
45 git rev-parse HEAD^1 HEAD^2 | sort >actual &&
46 git rev-parse three four | sort >expect &&
47 test_cmp expect actual
50 test_expect_success
'merge octopus, non-fast-forward (ff)' '
52 git reset --hard one &&
53 git merge --no-ff left right &&
54 # one is ancestor of three (left) and four (right)
55 test_must_fail git rev-parse --verify HEAD^4 &&
56 git rev-parse HEAD^1 HEAD^2 HEAD^3 | sort >actual &&
57 git rev-parse one three four | sort >expect &&
58 test_cmp expect actual
61 test_expect_success
'merge octopus, fast-forward (does not ff)' '
63 git merge left right &&
64 # two (master) is not an ancestor of three (left) and four (right)
65 test_must_fail git rev-parse --verify HEAD^4 &&
66 git rev-parse HEAD^1 HEAD^2 HEAD^3 | sort >actual &&
67 git rev-parse two three four | sort >expect &&
68 test_cmp expect actual
71 test_expect_success
'merge octopus, non-fast-forward' '
73 git merge --no-ff left right &&
74 test_must_fail git rev-parse --verify HEAD^4 &&
75 git rev-parse HEAD^1 HEAD^2 HEAD^3 | sort >actual &&
76 git rev-parse two three four | sort >expect &&
77 test_cmp expect actual
80 # The same set with FETCH_HEAD
82 test_expect_success
'merge FETCH_HEAD octopus into void' '
84 git checkout --orphan test &&
86 git fetch . left right &&
87 test_must_fail git merge FETCH_HEAD &&
88 test_must_fail git rev-parse --verify HEAD &&
90 test_must_fail git rev-parse HEAD
93 test_expect_success
'merge FETCH_HEAD octopus fast-forward (ff)' '
95 git reset --hard one &&
96 git fetch . left right &&
97 git merge FETCH_HEAD &&
98 # one is ancestor of three (left) and four (right)
99 test_must_fail git rev-parse --verify HEAD^3 &&
100 git rev-parse HEAD^1 HEAD^2 | sort >actual &&
101 git rev-parse three four | sort >expect &&
102 test_cmp expect actual
105 test_expect_success
'merge FETCH_HEAD octopus non-fast-forward (ff)' '
107 git reset --hard one &&
108 git fetch . left right &&
109 git merge --no-ff FETCH_HEAD &&
110 # one is ancestor of three (left) and four (right)
111 test_must_fail git rev-parse --verify HEAD^4 &&
112 git rev-parse HEAD^1 HEAD^2 HEAD^3 | sort >actual &&
113 git rev-parse one three four | sort >expect &&
114 test_cmp expect actual
117 test_expect_success
'merge FETCH_HEAD octopus fast-forward (does not ff)' '
119 git fetch . left right &&
120 git merge FETCH_HEAD &&
121 # two (master) is not an ancestor of three (left) and four (right)
122 test_must_fail git rev-parse --verify HEAD^4 &&
123 git rev-parse HEAD^1 HEAD^2 HEAD^3 | sort >actual &&
124 git rev-parse two three four | sort >expect &&
125 test_cmp expect actual
128 test_expect_success
'merge FETCH_HEAD octopus non-fast-forward' '
130 git fetch . left right &&
131 git merge --no-ff FETCH_HEAD &&
132 test_must_fail git rev-parse --verify HEAD^4 &&
133 git rev-parse HEAD^1 HEAD^2 HEAD^3 | sort >actual &&
134 git rev-parse two three four | sort >expect &&
135 test_cmp expect actual
139 test_expect_success
'refuse two-project merge by default' '
141 git reset --hard four &&
142 test_must_fail git merge five
145 test_expect_success
'two-project merge with --allow-unrelated-histories' '
147 git reset --hard four &&
148 git merge --allow-unrelated-histories five &&
149 git diff --exit-code five