Skip to content

Commit 72251b7

Browse files
bradkinggitster
authored andcommitted
submodule: Demonstrate known breakage during recursive merge
Since commit 68d03e4 (Implement automatic fast-forward merge for submodules, 2010-07-07) we try to suggest submodule commits that resolve a conflict. Consider a true recursive merge case b---bc / \ / o X \ / \ c---cb in which the two heads themselves (bc,cb) had resolved a submodule conflict (i.e. reference different commits than their parents). The submodule merge search runs during the temporary merge of the two merge bases (b,c) and prints out a suggestion that is not meaningful to the user. Then during the main merge the submodule merge search runs again but dies with the message fatal: --ancestry-path given but there are no bottom commits while trying to enumerate candidates. Demonstrate this known breakage with a new test in t7405-submodule-merge covering the case. Signed-off-by: Brad King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 34c4461 commit 72251b7

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

t/t7405-submodule-merge.sh

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,4 +228,55 @@ test_expect_success 'merging with a modify/modify conflict between merge bases'
228228
git merge d
229229
'
230230

231+
# canonical criss-cross history in top and submodule
232+
test_expect_success 'setup for recursive merge with submodule' '
233+
mkdir merge-recursive &&
234+
(cd merge-recursive &&
235+
git init &&
236+
mkdir sub &&
237+
(cd sub &&
238+
git init &&
239+
test_commit a &&
240+
git checkout -b sub-b master &&
241+
test_commit b &&
242+
git checkout -b sub-c master &&
243+
test_commit c &&
244+
git checkout -b sub-bc sub-b &&
245+
git merge sub-c &&
246+
git checkout -b sub-cb sub-c &&
247+
git merge sub-b &&
248+
git checkout master) &&
249+
git add sub &&
250+
git commit -m a &&
251+
git checkout -b top-b master &&
252+
(cd sub && git checkout sub-b) &&
253+
git add sub &&
254+
git commit -m b &&
255+
git checkout -b top-c master &&
256+
(cd sub && git checkout sub-c) &&
257+
git add sub &&
258+
git commit -m c &&
259+
git checkout -b top-bc top-b &&
260+
git merge -s ours --no-commit top-c &&
261+
(cd sub && git checkout sub-bc) &&
262+
git add sub &&
263+
git commit -m bc &&
264+
git checkout -b top-cb top-c &&
265+
git merge -s ours --no-commit top-b &&
266+
(cd sub && git checkout sub-cb) &&
267+
git add sub &&
268+
git commit -m cb)
269+
'
270+
271+
# merge should leave submodule unmerged in index
272+
test_expect_failure 'recursive merge with submodule' '
273+
(cd merge-recursive &&
274+
test_must_fail git merge top-bc &&
275+
echo "160000 $(git rev-parse top-cb:sub) 2 sub" > expect2 &&
276+
echo "160000 $(git rev-parse top-bc:sub) 3 sub" > expect3 &&
277+
git ls-files -u > actual &&
278+
grep "$(cat expect2)" actual > /dev/null &&
279+
grep "$(cat expect3)" actual > /dev/null)
280+
'
281+
231282
test_done

0 commit comments

Comments
 (0)