t4150: tests for am --[no-]scissors

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>

Paul Tan committed Jul 19, 2015 at 23:49 UTC bf72ac17d7c9441fd30f9a9764b399c74142204b
1 file changed +48
t/t4150-am.sh
+48
@@ -67,6 +67,19 @@ test_expect_success 'setup: messages' '
67
68 EOF
69
70 + cat >scissors-msg <<-\EOF &&
71 + Test git-am with scissors line
72 +
73 + This line should be included in the commit message.
74 + EOF
75 +
76 + cat - scissors-msg >no-scissors-msg <<-\EOF &&
77 + This line should not be included in the commit message with --scissors enabled.
78 +
79 + - - >8 - - remove everything above this line - - >8 - -
80 +
81 + EOF
82 +
83 signoff="Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>"
84 '
85
@@ -105,6 +118,20 @@ test_expect_success setup '
118 git format-patch --stdout first | sed -e "1d"
119 } > patch1-ws.eml &&
120
121 + echo scissors-file >scissors-file &&
122 + git add scissors-file &&
123 + git commit -F scissors-msg &&
124 + git tag scissors &&
125 + git format-patch --stdout scissors^ >scissors-patch.eml &&
126 + git reset --hard HEAD^ &&
127 +
128 + echo no-scissors-file >no-scissors-file &&
129 + git add no-scissors-file &&
130 + git commit -F no-scissors-msg &&
131 + git tag no-scissors &&
132 + git format-patch --stdout no-scissors^ >no-scissors-patch.eml &&
133 + git reset --hard HEAD^ &&
134 +
135 sed -n -e "3,\$p" msg >file &&
136 git add file &&
137 test_tick &&
@@ -305,6 +332,27 @@ test_expect_success 'am with failing post-applypatch hook' '
332 test_cmp head.expected head.actual
333 '
334
335 +test_expect_success 'am --scissors cuts the message at the scissors line' '
336 + rm -fr .git/rebase-apply &&
337 + git reset --hard &&
338 + git checkout second &&
339 + git am --scissors scissors-patch.eml &&
340 + test_path_is_missing .git/rebase-apply &&
341 + git diff --exit-code scissors &&
342 + test_cmp_rev scissors HEAD
343 +'
344 +
345 +test_expect_success 'am --no-scissors overrides mailinfo.scissors' '
346 + rm -fr .git/rebase-apply &&
347 + git reset --hard &&
348 + git checkout second &&
349 + test_config mailinfo.scissors true &&
350 + git am --no-scissors no-scissors-patch.eml &&
351 + test_path_is_missing .git/rebase-apply &&
352 + git diff --exit-code no-scissors &&
353 + test_cmp_rev no-scissors HEAD
354 +'
355 +
356 test_expect_success 'setup: new author and committer' '
357 GIT_AUTHOR_NAME="Another Thor" &&
358 GIT_AUTHOR_EMAIL="a.thor@example.com" &&