cherry-pick: make sure all input objects are commits
[gitweb.git] / t / t6200-fmt-merge-msg.sh
index 9b50f54cc2d1cfb790b0fb68f71b9c1719061b7f..f73eceabfbcd0a763b8908a8d829894a5e36055b 100755 (executable)
@@ -102,8 +102,8 @@ test_expect_success '[merge] summary/log configuration' '
        cat >expected <<-EOF &&
        Merge branch ${apos}left${apos}
 
-       By Another Author (3) and A U Thor (2)
-       via Another Committer
+       By Another Author (3) and A U Thor (2)
+       # Via Another Committer
        * left:
          Left #5
          Left #4
@@ -112,8 +112,8 @@ test_expect_success '[merge] summary/log configuration' '
          Common #1
        EOF
 
-       git config merge.log true &&
-       test_might_fail git config --unset-all merge.summary &&
+       test_config merge.log true &&
+       test_unconfig merge.summary &&
 
        git checkout master &&
        test_tick &&
@@ -121,8 +121,8 @@ test_expect_success '[merge] summary/log configuration' '
 
        git fmt-merge-msg <.git/FETCH_HEAD >actual1 &&
 
-       test_might_fail git config --unset-all merge.log &&
-       git config merge.summary true &&
+       test_unconfig merge.log &&
+       test_config merge.summary true &&
 
        git checkout master &&
        test_tick &&
@@ -134,11 +134,6 @@ test_expect_success '[merge] summary/log configuration' '
        test_cmp expected actual2
 '
 
-test_expect_success 'setup: clear [merge] configuration' '
-       test_might_fail git config --unset-all merge.log &&
-       test_might_fail git config --unset-all merge.summary
-'
-
 test_expect_success 'setup FETCH_HEAD' '
        git checkout master &&
        test_tick &&
@@ -149,8 +144,8 @@ test_expect_success 'merge.log=3 limits shortlog length' '
        cat >expected <<-EOF &&
        Merge branch ${apos}left${apos}
 
-       By Another Author (3) and A U Thor (2)
-       via Another Committer
+       By Another Author (3) and A U Thor (2)
+       # Via Another Committer
        * left: (5 commits)
          Left #5
          Left #4
@@ -166,8 +161,8 @@ test_expect_success 'merge.log=5 shows all 5 commits' '
        cat >expected <<-EOF &&
        Merge branch ${apos}left${apos}
 
-       By Another Author (3) and A U Thor (2)
-       via Another Committer
+       By Another Author (3) and A U Thor (2)
+       # Via Another Committer
        * left:
          Left #5
          Left #4
@@ -190,8 +185,8 @@ test_expect_success '--log=3 limits shortlog length' '
        cat >expected <<-EOF &&
        Merge branch ${apos}left${apos}
 
-       By Another Author (3) and A U Thor (2)
-       via Another Committer
+       By Another Author (3) and A U Thor (2)
+       # Via Another Committer
        * left: (5 commits)
          Left #5
          Left #4
@@ -207,8 +202,8 @@ test_expect_success '--log=5 shows all 5 commits' '
        cat >expected <<-EOF &&
        Merge branch ${apos}left${apos}
 
-       By Another Author (3) and A U Thor (2)
-       via Another Committer
+       By Another Author (3) and A U Thor (2)
+       # Via Another Committer
        * left:
          Left #5
          Left #4
@@ -238,8 +233,8 @@ test_expect_success 'fmt-merge-msg -m' '
        cat >expected.log <<-EOF &&
        Sync with left
 
-       By Another Author (3) and A U Thor (2)
-       via Another Committer
+       By Another Author (3) and A U Thor (2)
+       # Via Another Committer
        * ${apos}left${apos} of $(pwd):
          Left #5
          Left #4
@@ -248,14 +243,14 @@ test_expect_success 'fmt-merge-msg -m' '
          Common #1
        EOF
 
-       test_might_fail git config --unset merge.log &&
-       test_might_fail git config --unset merge.summary &&
+       test_unconfig merge.log &&
+       test_unconfig merge.summary &&
        git checkout master &&
        git fetch "$(pwd)" left &&
        git fmt-merge-msg -m "Sync with left" <.git/FETCH_HEAD >actual &&
        git fmt-merge-msg --log -m "Sync with left" \
                                        <.git/FETCH_HEAD >actual.log &&
-       git config merge.log true &&
+       test_config merge.log true &&
        git fmt-merge-msg -m "Sync with left" \
                                        <.git/FETCH_HEAD >actual.log-config &&
        git fmt-merge-msg --no-log -m "Sync with left" \
@@ -271,8 +266,8 @@ test_expect_success 'setup: expected shortlog for two branches' '
        cat >expected <<-EOF
        Merge branches ${apos}left${apos} and ${apos}right${apos}
 
-       By Another Author (3) and A U Thor (2)
-       via Another Committer
+       By Another Author (3) and A U Thor (2)
+       # Via Another Committer
        * left:
          Left #5
          Left #4
@@ -290,29 +285,29 @@ test_expect_success 'setup: expected shortlog for two branches' '
 '
 
 test_expect_success 'shortlog for two branches' '
-       git config merge.log true &&
-       test_might_fail git config --unset-all merge.summary &&
+       test_config merge.log true &&
+       test_unconfig merge.summary &&
        git checkout master &&
        test_tick &&
        git fetch . left right &&
        git fmt-merge-msg <.git/FETCH_HEAD >actual1 &&
 
-       test_might_fail git config --unset-all merge.log &&
-       git config merge.summary true &&
+       test_unconfig merge.log &&
+       test_config merge.summary true &&
        git checkout master &&
        test_tick &&
        git fetch . left right &&
        git fmt-merge-msg <.git/FETCH_HEAD >actual2 &&
 
-       git config merge.log yes &&
-       test_might_fail git config --unset-all merge.summary &&
+       test_config merge.log yes &&
+       test_unconfig merge.summary &&
        git checkout master &&
        test_tick &&
        git fetch . left right &&
        git fmt-merge-msg <.git/FETCH_HEAD >actual3 &&
 
-       test_might_fail git config --unset-all merge.log &&
-       git config merge.summary yes &&
+       test_unconfig merge.log &&
+       test_config merge.summary yes &&
        git checkout master &&
        test_tick &&
        git fetch . left right &&
@@ -325,8 +320,8 @@ test_expect_success 'shortlog for two branches' '
 '
 
 test_expect_success 'merge-msg -F' '
-       test_might_fail git config --unset-all merge.log &&
-       git config merge.summary yes &&
+       test_unconfig merge.log &&
+       test_config merge.summary yes &&
        git checkout master &&
        test_tick &&
        git fetch . left right &&
@@ -335,8 +330,8 @@ test_expect_success 'merge-msg -F' '
 '
 
 test_expect_success 'merge-msg -F in subdirectory' '
-       test_might_fail git config --unset-all merge.log &&
-       git config merge.summary yes &&
+       test_unconfig merge.log &&
+       test_config merge.summary yes &&
        git checkout master &&
        test_tick &&
        git fetch . left right &&
@@ -350,8 +345,8 @@ test_expect_success 'merge-msg -F in subdirectory' '
 '
 
 test_expect_success 'merge-msg with nothing to merge' '
-       test_might_fail git config --unset-all merge.log &&
-       git config merge.summary yes &&
+       test_unconfig merge.log &&
+       test_config merge.summary yes &&
 
        >empty &&
 
@@ -376,8 +371,8 @@ test_expect_success 'merge-msg tag' '
          Common #1
        EOF
 
-       test_might_fail git config --unset-all merge.log &&
-       git config merge.summary yes &&
+       test_unconfig merge.log &&
+       test_config merge.summary yes &&
 
        git checkout master &&
        test_tick &&
@@ -396,8 +391,8 @@ test_expect_success 'merge-msg two tags' '
          Common #2
          Common #1
 
-       By Another Author (3) and A U Thor (2)
-       via Another Committer
+       By Another Author (3) and A U Thor (2)
+       # Via Another Committer
        * tag ${apos}tag-l5${apos}:
          Left #5
          Left #4
@@ -406,8 +401,8 @@ test_expect_success 'merge-msg two tags' '
          Common #1
        EOF
 
-       test_might_fail git config --unset-all merge.log &&
-       git config merge.summary yes &&
+       test_unconfig merge.log &&
+       test_config merge.summary yes &&
 
        git checkout master &&
        test_tick &&
@@ -426,8 +421,8 @@ test_expect_success 'merge-msg tag and branch' '
          Common #2
          Common #1
 
-       By Another Author (3) and A U Thor (2)
-       via Another Committer
+       By Another Author (3) and A U Thor (2)
+       # Via Another Committer
        * left:
          Left #5
          Left #4
@@ -436,8 +431,8 @@ test_expect_success 'merge-msg tag and branch' '
          Common #1
        EOF
 
-       test_might_fail git config --unset-all merge.log &&
-       git config merge.summary yes &&
+       test_unconfig merge.log &&
+       test_config merge.summary yes &&
 
        git checkout master &&
        test_tick &&
@@ -464,6 +459,8 @@ test_expect_success 'merge-msg lots of commits' '
                echo "  ..."
        } >expected &&
 
+       test_config merge.summary yes &&
+
        git checkout master &&
        test_tick &&
        git fetch . long &&
@@ -472,4 +469,43 @@ test_expect_success 'merge-msg lots of commits' '
        test_cmp expected actual
 '
 
+test_expect_success 'merge-msg with "merging" an annotated tag' '
+       test_config merge.log true &&
+
+       git checkout master^0 &&
+       git commit --allow-empty -m "One step ahead" &&
+       git tag -a -m "An annotated one" annote HEAD &&
+
+       git checkout master &&
+       git fetch . annote &&
+
+       git fmt-merge-msg <.git/FETCH_HEAD >actual &&
+       {
+               cat <<-\EOF
+               Merge tag '\''annote'\''
+
+               An annotated one
+
+               * tag '\''annote'\'':
+                 One step ahead
+               EOF
+       } >expected &&
+       test_cmp expected actual &&
+
+       test_when_finished "git reset --hard" &&
+       annote=$(git rev-parse annote) &&
+       git merge --no-commit $annote &&
+       {
+               cat <<-EOF
+               Merge tag '\''$annote'\''
+
+               An annotated one
+
+               * tag '\''$annote'\'':
+                 One step ahead
+               EOF
+       } >expected &&
+       test_cmp expected .git/MERGE_MSG
+'
+
 test_done