Code

Documentation: publicize KMail hints for sending patches inline
[git.git] / t / t7405-submodule-merge.sh
index 6ec559db0fd2c1a7ef560543816ac2b5cf784809..a8fb30b7921dd17f910d48e82fbb2374fcb45ac3 100755 (executable)
@@ -56,18 +56,18 @@ test_expect_success setup '
 
 # History setup
 #
-#      b
-#    /   \
-#   a     d
-#    \   /
-#      c
+#             b
+#           /   \
+#  init -- a     d
+#    \      \   /
+#     g       c
 #
 # a in the main repository records to sub-a in the submodule and
 # analogous b and c. d should be automatically found by merging c into
 # b in the main repository.
 test_expect_success 'setup for merge search' '
        mkdir merge-search &&
-       cd merge-search &&
+       (cd merge-search &&
        git init &&
        mkdir sub &&
        (cd sub &&
@@ -76,6 +76,8 @@ test_expect_success 'setup for merge search' '
         git add file-a &&
         git commit -m "sub-a" &&
         git branch sub-a) &&
+       git commit --allow-empty -m init &&
+       git branch init &&
        git add sub &&
        git commit -m "a" &&
        git branch a &&
@@ -102,7 +104,12 @@ test_expect_success 'setup for merge search' '
         git merge sub-c) &&
        git commit -a -m "d" &&
        git branch test b &&
-       cd ..
+
+       git checkout -b g init &&
+       (cd sub &&
+        git checkout -b sub-g sub-c) &&
+       git add sub &&
+       git commit -a -m "g")
 '
 
 test_expect_success 'merge with one side as a fast-forward of the other' '
@@ -126,7 +133,7 @@ test_expect_success 'merging should conflict for non fast-forward' '
 '
 
 test_expect_success 'merging should fail for ambiguous common parent' '
-       cd merge-search &&
+       (cd merge-search &&
        git checkout -b test-ambiguous b &&
        (cd sub &&
         git checkout -b ambiguous sub-b &&
@@ -136,8 +143,7 @@ test_expect_success 'merging should fail for ambiguous common parent' '
        test_must_fail git merge c 2> actual &&
        grep $(cat expect1) actual > /dev/null &&
        grep $(cat expect2) actual > /dev/null &&
-       git reset --hard &&
-       cd ..
+       git reset --hard)
 '
 
 # in a situation like this
@@ -158,7 +164,7 @@ test_expect_success 'merging should fail for ambiguous common parent' '
 # commits (sub-a) does not descend from the submodule merge-base (sub-b).
 #
 test_expect_success 'merging should fail for changes that are backwards' '
-       cd merge-search &&
+       (cd merge-search &&
        git checkout -b bb a &&
        (cd sub &&
         git checkout sub-b) &&
@@ -175,16 +181,51 @@ test_expect_success 'merging should fail for changes that are backwards' '
        git commit -a -m "f" &&
 
        git checkout -b test-backward e &&
-       test_must_fail git merge f &&
-       cd ..
+       test_must_fail git merge f)
 '
 
-test_expect_success 'merging with a modify/modify conflict between merge bases' '
 
+# Check that the conflicting submodule is detected when it is
+# in the common ancestor. status should be 'U00...00"
+test_expect_success 'git submodule status should display the merge conflict properly with merge base' '
+       (cd merge-search &&
+       cat >.gitmodules <<EOF &&
+[submodule "sub"]
+       path = sub
+       url = $TRASH_DIRECTORY/sub
+EOF
+       cat >expect <<EOF &&
+U0000000000000000000000000000000000000000 sub
+EOF
+       git submodule status > actual &&
+       test_cmp expect actual &&
+       git reset --hard)
+'
+
+# Check that the conflicting submodule is detected when it is
+# not in the common ancestor. status should be 'U00...00"
+test_expect_success 'git submodule status should display the merge conflict properly without merge-base' '
+       (cd merge-search &&
+       git checkout -b test-no-merge-base g &&
+       test_must_fail git merge b &&
+       cat >.gitmodules <<EOF &&
+[submodule "sub"]
+       path = sub
+       url = $TRASH_DIRECTORY/sub
+EOF
+       cat >expect <<EOF &&
+U0000000000000000000000000000000000000000 sub
+EOF
+       git submodule status > actual &&
+       test_cmp expect actual &&
+       git reset --hard)
+'
+
+
+test_expect_success 'merging with a modify/modify conflict between merge bases' '
        git reset --hard HEAD &&
        git checkout -b test2 c &&
        git merge d
-
 '
 
 test_done