t4150: tests for am --[no-]scissors
authorPaul Tan <pyokagan@gmail.com>
Sun, 19 Jul 2015 15:49:16 +0000 (23:49 +0800)
committerJunio C Hamano <gitster@pobox.com>
Mon, 20 Jul 2015 17:52:43 +0000 (10:52 -0700)
Since 017678b (am/mailinfo: Disable scissors processing by default,
2009-08-26), git-am supported the --[no-]scissors option, passing it to
git-mailinfo.

Add tests to ensure that git-am will pass the --scissors option to
git-mailinfo, and that --no-scissors will override the configuration
setting of mailinfo.scissors.

Reviewed-by: Stefan Beller <sbeller@google.com>
Reviewed-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Paul Tan <pyokagan@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t4150-am.sh
index 749424042ce88db598b3357fcb4ef7ba13733938..67fbf0e1c94ed247decf6aaa91f963dae7f316a2 100755 (executable)
@@ -67,6 +67,19 @@ test_expect_success 'setup: messages' '
 
        EOF
 
+       cat >scissors-msg <<-\EOF &&
+       Test git-am with scissors line
+
+       This line should be included in the commit message.
+       EOF
+
+       cat - scissors-msg >no-scissors-msg <<-\EOF &&
+       This line should not be included in the commit message with --scissors enabled.
+
+        - - >8 - - remove everything above this line - - >8 - -
+
+       EOF
+
        signoff="Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>"
 '
 
@@ -105,6 +118,20 @@ test_expect_success setup '
                git format-patch --stdout first | sed -e "1d"
        } > patch1-ws.eml &&
 
+       echo scissors-file >scissors-file &&
+       git add scissors-file &&
+       git commit -F scissors-msg &&
+       git tag scissors &&
+       git format-patch --stdout scissors^ >scissors-patch.eml &&
+       git reset --hard HEAD^ &&
+
+       echo no-scissors-file >no-scissors-file &&
+       git add no-scissors-file &&
+       git commit -F no-scissors-msg &&
+       git tag no-scissors &&
+       git format-patch --stdout no-scissors^ >no-scissors-patch.eml &&
+       git reset --hard HEAD^ &&
+
        sed -n -e "3,\$p" msg >file &&
        git add file &&
        test_tick &&
@@ -305,6 +332,27 @@ test_expect_success 'am with failing post-applypatch hook' '
        test_cmp head.expected head.actual
 '
 
+test_expect_success 'am --scissors cuts the message at the scissors line' '
+       rm -fr .git/rebase-apply &&
+       git reset --hard &&
+       git checkout second &&
+       git am --scissors scissors-patch.eml &&
+       test_path_is_missing .git/rebase-apply &&
+       git diff --exit-code scissors &&
+       test_cmp_rev scissors HEAD
+'
+
+test_expect_success 'am --no-scissors overrides mailinfo.scissors' '
+       rm -fr .git/rebase-apply &&
+       git reset --hard &&
+       git checkout second &&
+       test_config mailinfo.scissors true &&
+       git am --no-scissors no-scissors-patch.eml &&
+       test_path_is_missing .git/rebase-apply &&
+       git diff --exit-code no-scissors &&
+       test_cmp_rev no-scissors HEAD
+'
+
 test_expect_success 'setup: new author and committer' '
        GIT_AUTHOR_NAME="Another Thor" &&
        GIT_AUTHOR_EMAIL="a.thor@example.com" &&