@@ -56,11 +56,11 @@ test_expect_success setup '
5656
5757# History setup
5858#
59- # b
60- # / \
61- # a d
62- # \ /
63- # c
59+ # b
60+ # / \
61+ # init -- a d
62+ # \ \ /
63+ # g c
6464#
6565# a in the main repository records to sub-a in the submodule and
6666# analogous b and c. d should be automatically found by merging c into
@@ -76,6 +76,8 @@ test_expect_success 'setup for merge search' '
7676 git add file-a &&
7777 git commit -m "sub-a" &&
7878 git branch sub-a) &&
79+ git commit --allow-empty -m init &&
80+ git branch init &&
7981 git add sub &&
8082 git commit -m "a" &&
8183 git branch a &&
@@ -101,7 +103,13 @@ test_expect_success 'setup for merge search' '
101103 git checkout -b sub-d sub-b &&
102104 git merge sub-c) &&
103105 git commit -a -m "d" &&
104- git branch test b)
106+ git branch test b &&
107+
108+ git checkout -b g init &&
109+ (cd sub &&
110+ git checkout -b sub-g sub-c) &&
111+ git add sub &&
112+ git commit -a -m "g")
105113'
106114
107115test_expect_success ' merge with one side as a fast-forward of the other' '
@@ -176,6 +184,44 @@ test_expect_success 'merging should fail for changes that are backwards' '
176184 test_must_fail git merge f)
177185'
178186
187+
188+ # Check that the conflicting submodule is detected when it is
189+ # in the common ancestor. status should be 'U00...00"
190+ test_expect_success ' git submodule status should display the merge conflict properly with merge base' '
191+ (cd merge-search &&
192+ cat >.gitmodules <<EOF &&
193+ [submodule "sub"]
194+ path = sub
195+ url = $TRASH_DIRECTORY/sub
196+ EOF
197+ cat >expect <<EOF &&
198+ U0000000000000000000000000000000000000000 sub
199+ EOF
200+ git submodule status > actual &&
201+ test_cmp expect actual &&
202+ git reset --hard)
203+ '
204+
205+ # Check that the conflicting submodule is detected when it is
206+ # not in the common ancestor. status should be 'U00...00"
207+ test_expect_success ' git submodule status should display the merge conflict properly without merge-base' '
208+ (cd merge-search &&
209+ git checkout -b test-no-merge-base g &&
210+ test_must_fail git merge b &&
211+ cat >.gitmodules <<EOF &&
212+ [submodule "sub"]
213+ path = sub
214+ url = $TRASH_DIRECTORY/sub
215+ EOF
216+ cat >expect <<EOF &&
217+ U0000000000000000000000000000000000000000 sub
218+ EOF
219+ git submodule status > actual &&
220+ test_cmp expect actual &&
221+ git reset --hard)
222+ '
223+
224+
179225test_expect_success ' merging with a modify/modify conflict between merge bases' '
180226 git reset --hard HEAD &&
181227 git checkout -b test2 c &&
0 commit comments