Merge branch 'cb/diff-fname-optim'
[gitweb.git] / t / t6200-fmt-merge-msg.sh
index 5553dff55a0a0319ec3d36b6259483077ecb1daa..9a168069217ef8d82173e563a04eaefe58d99f2a 100755 (executable)
@@ -129,6 +129,129 @@ 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 &&
+       git fetch . left
+'
+
+test_expect_success 'merge.log=3 limits shortlog length' '
+       cat >expected <<-EOF &&
+       Merge branch ${apos}left${apos}
+
+       * left: (5 commits)
+         Left #5
+         Left #4
+         Left #3
+         ...
+       EOF
+
+       git -c merge.log=3 fmt-merge-msg <.git/FETCH_HEAD >actual &&
+       test_cmp expected actual
+'
+
+test_expect_success 'merge.log=5 shows all 5 commits' '
+       cat >expected <<-EOF &&
+       Merge branch ${apos}left${apos}
+
+       * left:
+         Left #5
+         Left #4
+         Left #3
+         Common #2
+         Common #1
+       EOF
+
+       git -c merge.log=5 fmt-merge-msg <.git/FETCH_HEAD >actual &&
+       test_cmp expected actual
+'
+
+test_expect_success 'merge.log=0 disables shortlog' '
+       echo "Merge branch ${apos}left${apos}" >expected
+       git -c merge.log=0 fmt-merge-msg <.git/FETCH_HEAD >actual &&
+       test_cmp expected actual
+'
+
+test_expect_success '--log=3 limits shortlog length' '
+       cat >expected <<-EOF &&
+       Merge branch ${apos}left${apos}
+
+       * left: (5 commits)
+         Left #5
+         Left #4
+         Left #3
+         ...
+       EOF
+
+       git fmt-merge-msg --log=3 <.git/FETCH_HEAD >actual &&
+       test_cmp expected actual
+'
+
+test_expect_success '--log=5 shows all 5 commits' '
+       cat >expected <<-EOF &&
+       Merge branch ${apos}left${apos}
+
+       * left:
+         Left #5
+         Left #4
+         Left #3
+         Common #2
+         Common #1
+       EOF
+
+       git fmt-merge-msg --log=5 <.git/FETCH_HEAD >actual &&
+       test_cmp expected actual
+'
+
+test_expect_success '--no-log disables shortlog' '
+       echo "Merge branch ${apos}left${apos}" >expected &&
+       git fmt-merge-msg --no-log <.git/FETCH_HEAD >actual &&
+       test_cmp expected actual
+'
+
+test_expect_success '--log=0 disables shortlog' '
+       echo "Merge branch ${apos}left${apos}" >expected &&
+       git fmt-merge-msg --no-log <.git/FETCH_HEAD >actual &&
+       test_cmp expected actual
+'
+
+test_expect_success 'fmt-merge-msg -m' '
+       echo "Sync with left" >expected &&
+       cat >expected.log <<-EOF &&
+       Sync with left
+
+       * ${apos}left${apos} of $(pwd):
+         Left #5
+         Left #4
+         Left #3
+         Common #2
+         Common #1
+       EOF
+
+       test_might_fail git config --unset merge.log &&
+       test_might_fail git config --unset 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 &&
+       git fmt-merge-msg -m "Sync with left" \
+                                       <.git/FETCH_HEAD >actual.log-config &&
+       git fmt-merge-msg --no-log -m "Sync with left" \
+                                       <.git/FETCH_HEAD >actual.nolog &&
+
+       test_cmp expected actual &&
+       test_cmp expected.log actual.log &&
+       test_cmp expected.log actual.log-config &&
+       test_cmp expected actual.nolog
+'
+
 test_expect_success 'setup: expected shortlog for two branches' '
        cat >expected <<-EOF
        Merge branches ${apos}left${apos} and ${apos}right${apos}