Skip to content

Commit bf72ac1

Browse files
pyokagangitster
authored andcommitted
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>
1 parent 3ef4446 commit bf72ac1

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

t/t4150-am.sh

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,19 @@ test_expect_success 'setup: messages' '
6767
6868
EOF
6969
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+
7083
signoff="Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>"
7184
'
7285

@@ -105,6 +118,20 @@ test_expect_success setup '
105118
git format-patch --stdout first | sed -e "1d"
106119
} > patch1-ws.eml &&
107120
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+
108135
sed -n -e "3,\$p" msg >file &&
109136
git add file &&
110137
test_tick &&
@@ -305,6 +332,27 @@ test_expect_success 'am with failing post-applypatch hook' '
305332
test_cmp head.expected head.actual
306333
'
307334

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+
308356
test_expect_success 'setup: new author and committer' '
309357
GIT_AUTHOR_NAME="Another Thor" &&
310358
GIT_AUTHOR_EMAIL="a.thor@example.com" &&

0 commit comments

Comments
 (0)