Merge branch 'jc/t9001-modernise'

* jc/t9001-modernise:
  t9001: style modernisation phase #5
  t9001: style modernisation phase #4
  t9001: style modernisation phase #3
  t9001: style modernisation phase #2
  t9001: style modernisation phase #1
This commit is contained in:
Junio C Hamano 2014-12-29 09:32:07 -08:00
commit 4395b21424

View File

@ -6,35 +6,37 @@ test_description='git send-email'
# May be altered later in the test # May be altered later in the test
PREREQ="PERL" PREREQ="PERL"
test_expect_success $PREREQ \ test_expect_success $PREREQ 'prepare reference tree' '
'prepare reference tree' \ echo "1A quick brown fox jumps over the" >file &&
'echo "1A quick brown fox jumps over the" >file && echo "lazy dog" >>file &&
echo "lazy dog" >>file && git add file &&
git add file && GIT_AUTHOR_NAME="A" git commit -a -m "Initial."
GIT_AUTHOR_NAME="A" git commit -a -m "Initial."' '
test_expect_success $PREREQ \ test_expect_success $PREREQ 'Setup helper tool' '
'Setup helper tool' \ write_script fake.sendmail <<-\EOF &&
'(echo "#!$SHELL_PATH" shift
echo shift output=1
echo output=1 while test -f commandline$output
echo "while test -f commandline\$output; do output=\$((\$output+1)); done" do
echo for a output=$(($output+1))
echo do done
echo " echo \"!\$a!\"" for a
echo "done >commandline\$output" do
echo "cat > msgtxt\$output" echo "!$a!"
) >fake.sendmail && done >commandline$output
chmod +x ./fake.sendmail && cat >"msgtxt$output"
git add fake.sendmail && EOF
GIT_AUTHOR_NAME="A" git commit -a -m "Second."' git add fake.sendmail &&
GIT_AUTHOR_NAME="A" git commit -a -m "Second."
'
clean_fake_sendmail() { clean_fake_sendmail () {
rm -f commandline* msgtxt* rm -f commandline* msgtxt*
} }
test_expect_success $PREREQ 'Extract patches' ' test_expect_success $PREREQ 'Extract patches' '
patches=`git format-patch -s --cc="One <one@example.com>" --cc=two@example.com -n HEAD^1` patches=`git format-patch -s --cc="One <one@example.com>" --cc=two@example.com -n HEAD^1`
' '
# Test no confirm early to ensure remaining tests will not hang # Test no confirm early to ensure remaining tests will not hang
@ -47,9 +49,9 @@ test_no_confirm () {
--to=nobody@example.com \ --to=nobody@example.com \
--smtp-server="$(pwd)/fake.sendmail" \ --smtp-server="$(pwd)/fake.sendmail" \
$@ \ $@ \
$patches > stdout && $patches >stdout &&
test_must_fail grep "Send this email" stdout && test_must_fail grep "Send this email" stdout &&
> no_confirm_okay >no_confirm_okay
} }
# Exit immediately to prevent hang if a no-confirm test fails # Exit immediately to prevent hang if a no-confirm test fails
@ -82,61 +84,61 @@ test_expect_success $PREREQ 'No confirm with sendemail.confirm=never' '
' '
test_expect_success $PREREQ 'Send patches' ' test_expect_success $PREREQ 'Send patches' '
git send-email --suppress-cc=sob --from="Example <nobody@example.com>" --to=nobody@example.com --smtp-server="$(pwd)/fake.sendmail" $patches 2>errors git send-email --suppress-cc=sob --from="Example <nobody@example.com>" --to=nobody@example.com --smtp-server="$(pwd)/fake.sendmail" $patches 2>errors
' '
test_expect_success $PREREQ 'setup expect' ' test_expect_success $PREREQ 'setup expect' '
cat >expected <<\EOF cat >expected <<-\EOF
!nobody@example.com! !nobody@example.com!
!author@example.com! !author@example.com!
!one@example.com! !one@example.com!
!two@example.com! !two@example.com!
EOF EOF
' '
test_expect_success $PREREQ \ test_expect_success $PREREQ 'Verify commandline' '
'Verify commandline' \ test_cmp expected commandline1
'test_cmp expected commandline1' '
test_expect_success $PREREQ 'Send patches with --envelope-sender' ' test_expect_success $PREREQ 'Send patches with --envelope-sender' '
clean_fake_sendmail && clean_fake_sendmail &&
git send-email --envelope-sender="Patch Contributor <patch@example.com>" --suppress-cc=sob --from="Example <nobody@example.com>" --to=nobody@example.com --smtp-server="$(pwd)/fake.sendmail" $patches 2>errors git send-email --envelope-sender="Patch Contributor <patch@example.com>" --suppress-cc=sob --from="Example <nobody@example.com>" --to=nobody@example.com --smtp-server="$(pwd)/fake.sendmail" $patches 2>errors
' '
test_expect_success $PREREQ 'setup expect' ' test_expect_success $PREREQ 'setup expect' '
cat >expected <<\EOF cat >expected <<-\EOF
!patch@example.com! !patch@example.com!
!-i! !-i!
!nobody@example.com! !nobody@example.com!
!author@example.com! !author@example.com!
!one@example.com! !one@example.com!
!two@example.com! !two@example.com!
EOF EOF
' '
test_expect_success $PREREQ \ test_expect_success $PREREQ 'Verify commandline' '
'Verify commandline' \ test_cmp expected commandline1
'test_cmp expected commandline1' '
test_expect_success $PREREQ 'Send patches with --envelope-sender=auto' ' test_expect_success $PREREQ 'Send patches with --envelope-sender=auto' '
clean_fake_sendmail && clean_fake_sendmail &&
git send-email --envelope-sender=auto --suppress-cc=sob --from="Example <nobody@example.com>" --to=nobody@example.com --smtp-server="$(pwd)/fake.sendmail" $patches 2>errors git send-email --envelope-sender=auto --suppress-cc=sob --from="Example <nobody@example.com>" --to=nobody@example.com --smtp-server="$(pwd)/fake.sendmail" $patches 2>errors
' '
test_expect_success $PREREQ 'setup expect' ' test_expect_success $PREREQ 'setup expect' '
cat >expected <<\EOF cat >expected <<-\EOF
!nobody@example.com! !nobody@example.com!
!-i! !-i!
!nobody@example.com! !nobody@example.com!
!author@example.com! !author@example.com!
!one@example.com! !one@example.com!
!two@example.com! !two@example.com!
EOF EOF
' '
test_expect_success $PREREQ \ test_expect_success $PREREQ 'Verify commandline' '
'Verify commandline' \ test_cmp expected commandline1
'test_cmp expected commandline1' '
test_expect_success $PREREQ 'setup expect' " test_expect_success $PREREQ 'setup expect' "
cat >expected-show-all-headers <<\EOF cat >expected-show-all-headers <<\EOF
@ -307,11 +309,9 @@ test_expect_success $PREREQ 'tocmd works' '
clean_fake_sendmail && clean_fake_sendmail &&
cp $patches tocmd.patch && cp $patches tocmd.patch &&
echo tocmd--tocmd@example.com >>tocmd.patch && echo tocmd--tocmd@example.com >>tocmd.patch &&
{ write_script tocmd-sed <<-\EOF &&
echo "#!$SHELL_PATH" sed -n -e "s/^tocmd--//p" "$1"
echo sed -n -e s/^tocmd--//p \"\$1\" EOF
} > tocmd-sed &&
chmod +x tocmd-sed &&
git send-email \ git send-email \
--from="Example <nobody@example.com>" \ --from="Example <nobody@example.com>" \
--to-cmd=./tocmd-sed \ --to-cmd=./tocmd-sed \
@ -325,11 +325,9 @@ test_expect_success $PREREQ 'cccmd works' '
clean_fake_sendmail && clean_fake_sendmail &&
cp $patches cccmd.patch && cp $patches cccmd.patch &&
echo "cccmd-- cccmd@example.com" >>cccmd.patch && echo "cccmd-- cccmd@example.com" >>cccmd.patch &&
{ write_script cccmd-sed <<-\EOF &&
echo "#!$SHELL_PATH" sed -n -e "s/^cccmd--//p" "$1"
echo sed -n -e s/^cccmd--//p \"\$1\" EOF
} > cccmd-sed &&
chmod +x cccmd-sed &&
git send-email \ git send-email \
--from="Example <nobody@example.com>" \ --from="Example <nobody@example.com>" \
--to=nobody@example.com \ --to=nobody@example.com \
@ -367,7 +365,7 @@ test_expect_success $PREREQ 'Author From: in message body' '
--to=nobody@example.com \ --to=nobody@example.com \
--smtp-server="$(pwd)/fake.sendmail" \ --smtp-server="$(pwd)/fake.sendmail" \
$patches && $patches &&
sed "1,/^\$/d" < msgtxt1 > msgbody1 && sed "1,/^\$/d" <msgtxt1 >msgbody1 &&
grep "From: A <author@example.com>" msgbody1 grep "From: A <author@example.com>" msgbody1
' '
@ -378,7 +376,7 @@ test_expect_success $PREREQ 'Author From: not in message body' '
--to=nobody@example.com \ --to=nobody@example.com \
--smtp-server="$(pwd)/fake.sendmail" \ --smtp-server="$(pwd)/fake.sendmail" \
$patches && $patches &&
sed "1,/^\$/d" < msgtxt1 > msgbody1 && sed "1,/^\$/d" <msgtxt1 >msgbody1 &&
! grep "From: A <author@example.com>" msgbody1 ! grep "From: A <author@example.com>" msgbody1
' '
@ -459,10 +457,9 @@ test_expect_success $PREREQ 'In-Reply-To with --chain-reply-to' '
' '
test_expect_success $PREREQ 'setup fake editor' ' test_expect_success $PREREQ 'setup fake editor' '
(echo "#!$SHELL_PATH" && write_script fake-editor <<-\EOF
echo "echo fake edit >>\"\$1\"" echo fake edit >>"$1"
) >fake-editor && EOF
chmod +x fake-editor
' '
test_set_editor "$(pwd)/fake-editor" test_set_editor "$(pwd)/fake-editor"
@ -598,8 +595,9 @@ EOF
" "
test_expect_success $PREREQ 'sendemail.cccmd' ' test_expect_success $PREREQ 'sendemail.cccmd' '
echo echo cc-cmd@example.com > cccmd && write_script cccmd <<-\EOF &&
chmod +x cccmd && echo cc-cmd@example.com
EOF
git config sendemail.cccmd ./cccmd && git config sendemail.cccmd ./cccmd &&
test_suppression cccmd test_suppression cccmd
' '
@ -792,7 +790,7 @@ test_confirm () {
--from="Example <nobody@example.com>" \ --from="Example <nobody@example.com>" \
--to=nobody@example.com \ --to=nobody@example.com \
--smtp-server="$(pwd)/fake.sendmail" \ --smtp-server="$(pwd)/fake.sendmail" \
$@ $patches > stdout && $@ $patches >stdout &&
grep "Send this email" stdout grep "Send this email" stdout
} }
@ -840,7 +838,7 @@ test_expect_success $PREREQ 'confirm detects EOF (inform assumes y)' '
--from="Example <nobody@example.com>" \ --from="Example <nobody@example.com>" \
--to=nobody@example.com \ --to=nobody@example.com \
--smtp-server="$(pwd)/fake.sendmail" \ --smtp-server="$(pwd)/fake.sendmail" \
outdir/*.patch < /dev/null outdir/*.patch </dev/null
ret="$?" ret="$?"
git config sendemail.confirm ${CONFIRM:-never} git config sendemail.confirm ${CONFIRM:-never}
test $ret = "0" test $ret = "0"
@ -855,7 +853,7 @@ test_expect_success $PREREQ 'confirm detects EOF (auto causes failure)' '
--from="Example <nobody@example.com>" \ --from="Example <nobody@example.com>" \
--to=nobody@example.com \ --to=nobody@example.com \
--smtp-server="$(pwd)/fake.sendmail" \ --smtp-server="$(pwd)/fake.sendmail" \
$patches < /dev/null $patches </dev/null
ret="$?" ret="$?"
git config sendemail.confirm ${CONFIRM:-never} git config sendemail.confirm ${CONFIRM:-never}
test $ret = "0" test $ret = "0"
@ -891,39 +889,39 @@ test_expect_success $PREREQ 'utf8 Cc is rfc2047 encoded' '
test_expect_success $PREREQ '--compose adds MIME for utf8 body' ' test_expect_success $PREREQ '--compose adds MIME for utf8 body' '
clean_fake_sendmail && clean_fake_sendmail &&
(echo "#!$SHELL_PATH" && write_script fake-editor-utf8 <<-\EOF &&
echo "echo utf8 body: àéìöú >>\"\$1\"" echo "utf8 body: àéìöú" >>"$1"
) >fake-editor-utf8 && EOF
chmod +x fake-editor-utf8 && GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \
GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \ git send-email \
git send-email \ --compose --subject foo \
--compose --subject foo \ --from="Example <nobody@example.com>" \
--from="Example <nobody@example.com>" \ --to=nobody@example.com \
--to=nobody@example.com \ --smtp-server="$(pwd)/fake.sendmail" \
--smtp-server="$(pwd)/fake.sendmail" \ $patches &&
$patches &&
grep "^utf8 body" msgtxt1 && grep "^utf8 body" msgtxt1 &&
grep "^Content-Type: text/plain; charset=UTF-8" msgtxt1 grep "^Content-Type: text/plain; charset=UTF-8" msgtxt1
' '
test_expect_success $PREREQ '--compose respects user mime type' ' test_expect_success $PREREQ '--compose respects user mime type' '
clean_fake_sendmail && clean_fake_sendmail &&
(echo "#!$SHELL_PATH" && write_script fake-editor-utf8-mime <<-\EOF &&
echo "(echo MIME-Version: 1.0" cat >"$1" <<-\EOM
echo " echo Content-Type: text/plain\\; charset=iso-8859-1" MIME-Version: 1.0
echo " echo Content-Transfer-Encoding: 8bit" Content-Type: text/plain; charset=iso-8859-1
echo " echo Subject: foo" Content-Transfer-Encoding: 8bit
echo " echo " Subject: foo
echo " echo utf8 body: àéìöú) >\"\$1\""
) >fake-editor-utf8-mime && utf8 body: àéìöú
chmod +x fake-editor-utf8-mime && EOM
GIT_EDITOR="\"$(pwd)/fake-editor-utf8-mime\"" \ EOF
git send-email \ GIT_EDITOR="\"$(pwd)/fake-editor-utf8-mime\"" \
--compose --subject foo \ git send-email \
--from="Example <nobody@example.com>" \ --compose --subject foo \
--to=nobody@example.com \ --from="Example <nobody@example.com>" \
--smtp-server="$(pwd)/fake.sendmail" \ --to=nobody@example.com \
$patches && --smtp-server="$(pwd)/fake.sendmail" \
$patches &&
grep "^utf8 body" msgtxt1 && grep "^utf8 body" msgtxt1 &&
grep "^Content-Type: text/plain; charset=iso-8859-1" msgtxt1 && grep "^Content-Type: text/plain; charset=iso-8859-1" msgtxt1 &&
! grep "^Content-Type: text/plain; charset=UTF-8" msgtxt1 ! grep "^Content-Type: text/plain; charset=UTF-8" msgtxt1
@ -931,13 +929,13 @@ test_expect_success $PREREQ '--compose respects user mime type' '
test_expect_success $PREREQ '--compose adds MIME for utf8 subject' ' test_expect_success $PREREQ '--compose adds MIME for utf8 subject' '
clean_fake_sendmail && clean_fake_sendmail &&
GIT_EDITOR="\"$(pwd)/fake-editor\"" \ GIT_EDITOR="\"$(pwd)/fake-editor\"" \
git send-email \ git send-email \
--compose --subject utf8-sübjëct \ --compose --subject utf8-sübjëct \
--from="Example <nobody@example.com>" \ --from="Example <nobody@example.com>" \
--to=nobody@example.com \ --to=nobody@example.com \
--smtp-server="$(pwd)/fake.sendmail" \ --smtp-server="$(pwd)/fake.sendmail" \
$patches && $patches &&
grep "^fake edit" msgtxt1 && grep "^fake edit" msgtxt1 &&
grep "^Subject: =?UTF-8?q?utf8-s=C3=BCbj=C3=ABct?=" msgtxt1 grep "^Subject: =?UTF-8?q?utf8-s=C3=BCbj=C3=ABct?=" msgtxt1
' '
@ -949,9 +947,9 @@ test_expect_success $PREREQ 'utf8 author is correctly passed on' '
git commit --amend --author "Füñný Nâmé <odd_?=mail@example.com>" && git commit --amend --author "Füñný Nâmé <odd_?=mail@example.com>" &&
git format-patch --stdout -1 >funny_name.patch && git format-patch --stdout -1 >funny_name.patch &&
git send-email --from="Example <nobody@example.com>" \ git send-email --from="Example <nobody@example.com>" \
--to=nobody@example.com \ --to=nobody@example.com \
--smtp-server="$(pwd)/fake.sendmail" \ --smtp-server="$(pwd)/fake.sendmail" \
funny_name.patch && funny_name.patch &&
grep "^From: Füñný Nâmé <odd_?=mail@example.com>" msgtxt1 grep "^From: Füñný Nâmé <odd_?=mail@example.com>" msgtxt1
' '
@ -962,9 +960,9 @@ test_expect_success $PREREQ 'utf8 sender is not duplicated' '
git commit --amend --author "Füñný Nâmé <odd_?=mail@example.com>" && git commit --amend --author "Füñný Nâmé <odd_?=mail@example.com>" &&
git format-patch --stdout -1 >funny_name.patch && git format-patch --stdout -1 >funny_name.patch &&
git send-email --from="Füñný Nâmé <odd_?=mail@example.com>" \ git send-email --from="Füñný Nâmé <odd_?=mail@example.com>" \
--to=nobody@example.com \ --to=nobody@example.com \
--smtp-server="$(pwd)/fake.sendmail" \ --smtp-server="$(pwd)/fake.sendmail" \
funny_name.patch && funny_name.patch &&
grep "^From: " msgtxt1 >msgfrom && grep "^From: " msgtxt1 >msgfrom &&
test_line_count = 1 msgfrom test_line_count = 1 msgfrom
' '
@ -972,35 +970,33 @@ test_expect_success $PREREQ 'utf8 sender is not duplicated' '
test_expect_success $PREREQ 'sendemail.composeencoding works' ' test_expect_success $PREREQ 'sendemail.composeencoding works' '
clean_fake_sendmail && clean_fake_sendmail &&
git config sendemail.composeencoding iso-8859-1 && git config sendemail.composeencoding iso-8859-1 &&
(echo "#!$SHELL_PATH" && write_script fake-editor-utf8 <<-\EOF &&
echo "echo utf8 body: àéìöú >>\"\$1\"" echo "utf8 body: àéìöú" >>"$1"
) >fake-editor-utf8 && EOF
chmod +x fake-editor-utf8 && GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \
GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \ git send-email \
git send-email \ --compose --subject foo \
--compose --subject foo \ --from="Example <nobody@example.com>" \
--from="Example <nobody@example.com>" \ --to=nobody@example.com \
--to=nobody@example.com \ --smtp-server="$(pwd)/fake.sendmail" \
--smtp-server="$(pwd)/fake.sendmail" \ $patches &&
$patches &&
grep "^utf8 body" msgtxt1 && grep "^utf8 body" msgtxt1 &&
grep "^Content-Type: text/plain; charset=iso-8859-1" msgtxt1 grep "^Content-Type: text/plain; charset=iso-8859-1" msgtxt1
' '
test_expect_success $PREREQ '--compose-encoding works' ' test_expect_success $PREREQ '--compose-encoding works' '
clean_fake_sendmail && clean_fake_sendmail &&
(echo "#!$SHELL_PATH" && write_script fake-editor-utf8 <<-\EOF &&
echo "echo utf8 body: àéìöú >>\"\$1\"" echo "utf8 body: àéìöú" >>"$1"
) >fake-editor-utf8 && EOF
chmod +x fake-editor-utf8 && GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \
GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \ git send-email \
git send-email \ --compose-encoding iso-8859-1 \
--compose-encoding iso-8859-1 \ --compose --subject foo \
--compose --subject foo \ --from="Example <nobody@example.com>" \
--from="Example <nobody@example.com>" \ --to=nobody@example.com \
--to=nobody@example.com \ --smtp-server="$(pwd)/fake.sendmail" \
--smtp-server="$(pwd)/fake.sendmail" \ $patches &&
$patches &&
grep "^utf8 body" msgtxt1 && grep "^utf8 body" msgtxt1 &&
grep "^Content-Type: text/plain; charset=iso-8859-1" msgtxt1 grep "^Content-Type: text/plain; charset=iso-8859-1" msgtxt1
' '
@ -1008,38 +1004,37 @@ test_expect_success $PREREQ '--compose-encoding works' '
test_expect_success $PREREQ '--compose-encoding overrides sendemail.composeencoding' ' test_expect_success $PREREQ '--compose-encoding overrides sendemail.composeencoding' '
clean_fake_sendmail && clean_fake_sendmail &&
git config sendemail.composeencoding iso-8859-1 && git config sendemail.composeencoding iso-8859-1 &&
(echo "#!$SHELL_PATH" && write_script fake-editor-utf8 <<-\EOF &&
echo "echo utf8 body: àéìöú >>\"\$1\"" echo "utf8 body: àéìöú" >>"$1"
) >fake-editor-utf8 && EOF
chmod +x fake-editor-utf8 && GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \
GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \ git send-email \
git send-email \ --compose-encoding iso-8859-2 \
--compose-encoding iso-8859-2 \ --compose --subject foo \
--compose --subject foo \ --from="Example <nobody@example.com>" \
--from="Example <nobody@example.com>" \ --to=nobody@example.com \
--to=nobody@example.com \ --smtp-server="$(pwd)/fake.sendmail" \
--smtp-server="$(pwd)/fake.sendmail" \ $patches &&
$patches &&
grep "^utf8 body" msgtxt1 && grep "^utf8 body" msgtxt1 &&
grep "^Content-Type: text/plain; charset=iso-8859-2" msgtxt1 grep "^Content-Type: text/plain; charset=iso-8859-2" msgtxt1
' '
test_expect_success $PREREQ '--compose-encoding adds correct MIME for subject' ' test_expect_success $PREREQ '--compose-encoding adds correct MIME for subject' '
clean_fake_sendmail && clean_fake_sendmail &&
GIT_EDITOR="\"$(pwd)/fake-editor\"" \ GIT_EDITOR="\"$(pwd)/fake-editor\"" \
git send-email \ git send-email \
--compose-encoding iso-8859-2 \ --compose-encoding iso-8859-2 \
--compose --subject utf8-sübjëct \ --compose --subject utf8-sübjëct \
--from="Example <nobody@example.com>" \ --from="Example <nobody@example.com>" \
--to=nobody@example.com \ --to=nobody@example.com \
--smtp-server="$(pwd)/fake.sendmail" \ --smtp-server="$(pwd)/fake.sendmail" \
$patches && $patches &&
grep "^fake edit" msgtxt1 && grep "^fake edit" msgtxt1 &&
grep "^Subject: =?iso-8859-2?q?utf8-s=C3=BCbj=C3=ABct?=" msgtxt1 grep "^Subject: =?iso-8859-2?q?utf8-s=C3=BCbj=C3=ABct?=" msgtxt1
' '
test_expect_success $PREREQ 'detects ambiguous reference/file conflict' ' test_expect_success $PREREQ 'detects ambiguous reference/file conflict' '
echo master > master && echo master >master &&
git add master && git add master &&
git commit -m"add master" && git commit -m"add master" &&
test_must_fail git send-email --dry-run master 2>errors && test_must_fail git send-email --dry-run master 2>errors &&
@ -1050,10 +1045,10 @@ test_expect_success $PREREQ 'feed two files' '
rm -fr outdir && rm -fr outdir &&
git format-patch -2 -o outdir && git format-patch -2 -o outdir &&
git send-email \ git send-email \
--dry-run \ --dry-run \
--from="Example <nobody@example.com>" \ --from="Example <nobody@example.com>" \
--to=nobody@example.com \ --to=nobody@example.com \
outdir/000?-*.patch 2>errors >out && outdir/000?-*.patch 2>errors >out &&
grep "^Subject: " out >subjects && grep "^Subject: " out >subjects &&
test "z$(sed -n -e 1p subjects)" = "zSubject: [PATCH 1/2] Second." && test "z$(sed -n -e 1p subjects)" = "zSubject: [PATCH 1/2] Second." &&
test "z$(sed -n -e 2p subjects)" = "zSubject: [PATCH 2/2] add master" test "z$(sed -n -e 2p subjects)" = "zSubject: [PATCH 2/2] add master"
@ -1197,7 +1192,7 @@ test_expect_success $PREREQ 'To headers from files reset each patch' '
' '
test_expect_success $PREREQ 'setup expect' ' test_expect_success $PREREQ 'setup expect' '
cat >email-using-8bit <<EOF cat >email-using-8bit <<\EOF
From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001 From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001
Message-Id: <bogus-message-id@example.com> Message-Id: <bogus-message-id@example.com>
From: author@example.com From: author@example.com
@ -1209,9 +1204,7 @@ EOF
' '
test_expect_success $PREREQ 'setup expect' ' test_expect_success $PREREQ 'setup expect' '
cat >expected <<EOF echo "Subject: subject goes here" >expected
Subject: subject goes here
EOF
' '
test_expect_success $PREREQ 'ASCII subject is not RFC2047 quoted' ' test_expect_success $PREREQ 'ASCII subject is not RFC2047 quoted' '
@ -1226,11 +1219,11 @@ test_expect_success $PREREQ 'ASCII subject is not RFC2047 quoted' '
' '
test_expect_success $PREREQ 'setup expect' ' test_expect_success $PREREQ 'setup expect' '
cat >content-type-decl <<EOF cat >content-type-decl <<-\EOF
MIME-Version: 1.0 MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8 Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit Content-Transfer-Encoding: 8bit
EOF EOF
' '
test_expect_success $PREREQ 'asks about and fixes 8bit encodings' ' test_expect_success $PREREQ 'asks about and fixes 8bit encodings' '
@ -1270,21 +1263,21 @@ test_expect_success $PREREQ '--8bit-encoding overrides sendemail.8bitEncoding' '
' '
test_expect_success $PREREQ 'setup expect' ' test_expect_success $PREREQ 'setup expect' '
cat >email-using-8bit <<EOF cat >email-using-8bit <<-\EOF
From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001 From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001
Message-Id: <bogus-message-id@example.com> Message-Id: <bogus-message-id@example.com>
From: author@example.com From: author@example.com
Date: Sat, 12 Jun 2010 15:53:58 +0200 Date: Sat, 12 Jun 2010 15:53:58 +0200
Subject: Dieser Betreff enthält auch einen Umlaut! Subject: Dieser Betreff enthält auch einen Umlaut!
Nothing to see here. Nothing to see here.
EOF EOF
' '
test_expect_success $PREREQ 'setup expect' ' test_expect_success $PREREQ 'setup expect' '
cat >expected <<EOF cat >expected <<-\EOF
Subject: =?UTF-8?q?Dieser=20Betreff=20enth=C3=A4lt=20auch=20einen=20Umlaut!?= Subject: =?UTF-8?q?Dieser=20Betreff=20enth=C3=A4lt=20auch=20einen=20Umlaut!?=
EOF EOF
' '
test_expect_success $PREREQ '--8bit-encoding also treats subject' ' test_expect_success $PREREQ '--8bit-encoding also treats subject' '
@ -1299,26 +1292,26 @@ test_expect_success $PREREQ '--8bit-encoding also treats subject' '
' '
test_expect_success $PREREQ 'setup expect' ' test_expect_success $PREREQ 'setup expect' '
cat >email-using-8bit <<EOF cat >email-using-8bit <<-\EOF
From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001 From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001
Message-Id: <bogus-message-id@example.com> Message-Id: <bogus-message-id@example.com>
From: A U Thor <author@example.com> From: A U Thor <author@example.com>
Date: Sat, 12 Jun 2010 15:53:58 +0200 Date: Sat, 12 Jun 2010 15:53:58 +0200
Content-Type: text/plain; charset=UTF-8 Content-Type: text/plain; charset=UTF-8
Subject: Nothing to see here. Subject: Nothing to see here.
Dieser Betreff enthält auch einen Umlaut! Dieser Betreff enthält auch einen Umlaut!
EOF EOF
' '
test_expect_success $PREREQ 'sendemail.transferencoding=7bit fails on 8bit data' ' test_expect_success $PREREQ 'sendemail.transferencoding=7bit fails on 8bit data' '
clean_fake_sendmail && clean_fake_sendmail &&
git config sendemail.transferEncoding 7bit && git config sendemail.transferEncoding 7bit &&
test_must_fail git send-email \ test_must_fail git send-email \
--transfer-encoding=7bit \ --transfer-encoding=7bit \
--smtp-server="$(pwd)/fake.sendmail" \ --smtp-server="$(pwd)/fake.sendmail" \
email-using-8bit \ email-using-8bit \
2>errors >out && 2>errors >out &&
grep "cannot send message as 7bit" errors && grep "cannot send message as 7bit" errors &&
test -z "$(ls msgtxt*)" test -z "$(ls msgtxt*)"
' '
@ -1327,10 +1320,10 @@ test_expect_success $PREREQ '--transfer-encoding overrides sendemail.transferEnc
clean_fake_sendmail && clean_fake_sendmail &&
git config sendemail.transferEncoding 8bit git config sendemail.transferEncoding 8bit
test_must_fail git send-email \ test_must_fail git send-email \
--transfer-encoding=7bit \ --transfer-encoding=7bit \
--smtp-server="$(pwd)/fake.sendmail" \ --smtp-server="$(pwd)/fake.sendmail" \
email-using-8bit \ email-using-8bit \
2>errors >out && 2>errors >out &&
grep "cannot send message as 7bit" errors && grep "cannot send message as 7bit" errors &&
test -z "$(ls msgtxt*)" test -z "$(ls msgtxt*)"
' '
@ -1338,77 +1331,77 @@ test_expect_success $PREREQ '--transfer-encoding overrides sendemail.transferEnc
test_expect_success $PREREQ 'sendemail.transferencoding=8bit' ' test_expect_success $PREREQ 'sendemail.transferencoding=8bit' '
clean_fake_sendmail && clean_fake_sendmail &&
git send-email \ git send-email \
--transfer-encoding=8bit \ --transfer-encoding=8bit \
--smtp-server="$(pwd)/fake.sendmail" \ --smtp-server="$(pwd)/fake.sendmail" \
email-using-8bit \ email-using-8bit \
2>errors >out && 2>errors >out &&
sed '1,/^$/d' msgtxt1 >actual && sed '1,/^$/d' msgtxt1 >actual &&
sed '1,/^$/d' email-using-8bit >expected && sed '1,/^$/d' email-using-8bit >expected &&
test_cmp expected actual test_cmp expected actual
' '
test_expect_success $PREREQ 'setup expect' ' test_expect_success $PREREQ 'setup expect' '
cat >expected <<EOF cat >expected <<-\EOF
Dieser Betreff enth=C3=A4lt auch einen Umlaut! Dieser Betreff enth=C3=A4lt auch einen Umlaut!
EOF EOF
' '
test_expect_success $PREREQ '8-bit and sendemail.transferencoding=quoted-printable' ' test_expect_success $PREREQ '8-bit and sendemail.transferencoding=quoted-printable' '
clean_fake_sendmail && clean_fake_sendmail &&
git send-email \ git send-email \
--transfer-encoding=quoted-printable \ --transfer-encoding=quoted-printable \
--smtp-server="$(pwd)/fake.sendmail" \ --smtp-server="$(pwd)/fake.sendmail" \
email-using-8bit \ email-using-8bit \
2>errors >out && 2>errors >out &&
sed '1,/^$/d' msgtxt1 >actual && sed '1,/^$/d' msgtxt1 >actual &&
test_cmp expected actual test_cmp expected actual
' '
test_expect_success $PREREQ 'setup expect' ' test_expect_success $PREREQ 'setup expect' '
cat >expected <<EOF cat >expected <<-\EOF
RGllc2VyIEJldHJlZmYgZW50aMOkbHQgYXVjaCBlaW5lbiBVbWxhdXQhCg== RGllc2VyIEJldHJlZmYgZW50aMOkbHQgYXVjaCBlaW5lbiBVbWxhdXQhCg==
EOF EOF
' '
test_expect_success $PREREQ '8-bit and sendemail.transferencoding=base64' ' test_expect_success $PREREQ '8-bit and sendemail.transferencoding=base64' '
clean_fake_sendmail && clean_fake_sendmail &&
git send-email \ git send-email \
--transfer-encoding=base64 \ --transfer-encoding=base64 \
--smtp-server="$(pwd)/fake.sendmail" \ --smtp-server="$(pwd)/fake.sendmail" \
email-using-8bit \ email-using-8bit \
2>errors >out && 2>errors >out &&
sed '1,/^$/d' msgtxt1 >actual && sed '1,/^$/d' msgtxt1 >actual &&
test_cmp expected actual test_cmp expected actual
' '
test_expect_success $PREREQ 'setup expect' ' test_expect_success $PREREQ 'setup expect' '
cat >email-using-qp <<EOF cat >email-using-qp <<-\EOF
From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001 From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001
Message-Id: <bogus-message-id@example.com> Message-Id: <bogus-message-id@example.com>
From: A U Thor <author@example.com> From: A U Thor <author@example.com>
Date: Sat, 12 Jun 2010 15:53:58 +0200 Date: Sat, 12 Jun 2010 15:53:58 +0200
MIME-Version: 1.0 MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=UTF-8 Content-Type: text/plain; charset=UTF-8
Subject: Nothing to see here. Subject: Nothing to see here.
Dieser Betreff enth=C3=A4lt auch einen Umlaut! Dieser Betreff enth=C3=A4lt auch einen Umlaut!
EOF EOF
' '
test_expect_success $PREREQ 'convert from quoted-printable to base64' ' test_expect_success $PREREQ 'convert from quoted-printable to base64' '
clean_fake_sendmail && clean_fake_sendmail &&
git send-email \ git send-email \
--transfer-encoding=base64 \ --transfer-encoding=base64 \
--smtp-server="$(pwd)/fake.sendmail" \ --smtp-server="$(pwd)/fake.sendmail" \
email-using-qp \ email-using-qp \
2>errors >out && 2>errors >out &&
sed '1,/^$/d' msgtxt1 >actual && sed '1,/^$/d' msgtxt1 >actual &&
test_cmp expected actual test_cmp expected actual
' '
test_expect_success $PREREQ 'setup expect' " test_expect_success $PREREQ 'setup expect' "
tr -d '\\015' | tr '%' '\\015' > email-using-crlf <<EOF tr -d '\\015' | tr '%' '\\015' >email-using-crlf <<EOF
From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001 From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001
Message-Id: <bogus-message-id@example.com> Message-Id: <bogus-message-id@example.com>
From: A U Thor <author@example.com> From: A U Thor <author@example.com>
@ -1421,35 +1414,35 @@ EOF
" "
test_expect_success $PREREQ 'setup expect' ' test_expect_success $PREREQ 'setup expect' '
cat >expected <<EOF cat >expected <<-\EOF
Look, I have a CRLF and an =3D sign!=0D Look, I have a CRLF and an =3D sign!=0D
EOF EOF
' '
test_expect_success $PREREQ 'CRLF and sendemail.transferencoding=quoted-printable' ' test_expect_success $PREREQ 'CRLF and sendemail.transferencoding=quoted-printable' '
clean_fake_sendmail && clean_fake_sendmail &&
git send-email \ git send-email \
--transfer-encoding=quoted-printable \ --transfer-encoding=quoted-printable \
--smtp-server="$(pwd)/fake.sendmail" \ --smtp-server="$(pwd)/fake.sendmail" \
email-using-crlf \ email-using-crlf \
2>errors >out && 2>errors >out &&
sed '1,/^$/d' msgtxt1 >actual && sed '1,/^$/d' msgtxt1 >actual &&
test_cmp expected actual test_cmp expected actual
' '
test_expect_success $PREREQ 'setup expect' ' test_expect_success $PREREQ 'setup expect' '
cat >expected <<EOF cat >expected <<-\EOF
TG9vaywgSSBoYXZlIGEgQ1JMRiBhbmQgYW4gPSBzaWduIQ0K TG9vaywgSSBoYXZlIGEgQ1JMRiBhbmQgYW4gPSBzaWduIQ0K
EOF EOF
' '
test_expect_success $PREREQ 'CRLF and sendemail.transferencoding=base64' ' test_expect_success $PREREQ 'CRLF and sendemail.transferencoding=base64' '
clean_fake_sendmail && clean_fake_sendmail &&
git send-email \ git send-email \
--transfer-encoding=base64 \ --transfer-encoding=base64 \
--smtp-server="$(pwd)/fake.sendmail" \ --smtp-server="$(pwd)/fake.sendmail" \
email-using-crlf \ email-using-crlf \
2>errors >out && 2>errors >out &&
sed '1,/^$/d' msgtxt1 >actual && sed '1,/^$/d' msgtxt1 >actual &&
test_cmp expected actual test_cmp expected actual
' '
@ -1463,13 +1456,13 @@ test_expect_success $PREREQ 'refusing to send cover letter template' '
rm -fr outdir && rm -fr outdir &&
git format-patch --cover-letter -2 -o outdir && git format-patch --cover-letter -2 -o outdir &&
test_must_fail git send-email \ test_must_fail git send-email \
--from="Example <nobody@example.com>" \ --from="Example <nobody@example.com>" \
--to=nobody@example.com \ --to=nobody@example.com \
--smtp-server="$(pwd)/fake.sendmail" \ --smtp-server="$(pwd)/fake.sendmail" \
outdir/0002-*.patch \ outdir/0002-*.patch \
outdir/0000-*.patch \ outdir/0000-*.patch \
outdir/0001-*.patch \ outdir/0001-*.patch \
2>errors >out && 2>errors >out &&
grep "SUBJECT HERE" errors && grep "SUBJECT HERE" errors &&
test -z "$(ls msgtxt*)" test -z "$(ls msgtxt*)"
' '
@ -1479,14 +1472,14 @@ test_expect_success $PREREQ '--force sends cover letter template anyway' '
rm -fr outdir && rm -fr outdir &&
git format-patch --cover-letter -2 -o outdir && git format-patch --cover-letter -2 -o outdir &&
git send-email \ git send-email \
--force \ --force \
--from="Example <nobody@example.com>" \ --from="Example <nobody@example.com>" \
--to=nobody@example.com \ --to=nobody@example.com \
--smtp-server="$(pwd)/fake.sendmail" \ --smtp-server="$(pwd)/fake.sendmail" \
outdir/0002-*.patch \ outdir/0002-*.patch \
outdir/0000-*.patch \ outdir/0000-*.patch \
outdir/0001-*.patch \ outdir/0001-*.patch \
2>errors >out && 2>errors >out &&
! grep "SUBJECT HERE" errors && ! grep "SUBJECT HERE" errors &&
test -n "$(ls msgtxt*)" test -n "$(ls msgtxt*)"
' '
@ -1501,15 +1494,15 @@ test_cover_addresses () {
mv $cover cover-to-edit.patch && mv $cover cover-to-edit.patch &&
perl -pe "s/^From:/$header: extra\@address.com\nFrom:/" cover-to-edit.patch >"$cover" && perl -pe "s/^From:/$header: extra\@address.com\nFrom:/" cover-to-edit.patch >"$cover" &&
git send-email \ git send-email \
--force \ --force \
--from="Example <nobody@example.com>" \ --from="Example <nobody@example.com>" \
--no-to --no-cc \ --no-to --no-cc \
"$@" \ "$@" \
--smtp-server="$(pwd)/fake.sendmail" \ --smtp-server="$(pwd)/fake.sendmail" \
outdir/0000-*.patch \ outdir/0000-*.patch \
outdir/0001-*.patch \ outdir/0001-*.patch \
outdir/0002-*.patch \ outdir/0002-*.patch \
2>errors >out && 2>errors >out &&
grep "^$header: extra@address.com" msgtxt1 >to1 && grep "^$header: extra@address.com" msgtxt1 >to1 &&
grep "^$header: extra@address.com" msgtxt2 >to2 && grep "^$header: extra@address.com" msgtxt2 >to2 &&
grep "^$header: extra@address.com" msgtxt3 >to3 && grep "^$header: extra@address.com" msgtxt3 >to3 &&
@ -1542,11 +1535,11 @@ test_expect_success $PREREQ 'sendemail.aliasfiletype=mailrc' '
git config --replace-all sendemail.aliasesfile "$(pwd)/.mailrc" && git config --replace-all sendemail.aliasesfile "$(pwd)/.mailrc" &&
git config sendemail.aliasfiletype mailrc && git config sendemail.aliasfiletype mailrc &&
git send-email \ git send-email \
--from="Example <nobody@example.com>" \ --from="Example <nobody@example.com>" \
--to=sbd \ --to=sbd \
--smtp-server="$(pwd)/fake.sendmail" \ --smtp-server="$(pwd)/fake.sendmail" \
outdir/0001-*.patch \ outdir/0001-*.patch \
2>errors >out && 2>errors >out &&
grep "^!somebody@example\.org!$" commandline1 grep "^!somebody@example\.org!$" commandline1
' '
@ -1556,11 +1549,11 @@ test_expect_success $PREREQ 'sendemail.aliasfile=~/.mailrc' '
git config --replace-all sendemail.aliasesfile "~/.mailrc" && git config --replace-all sendemail.aliasesfile "~/.mailrc" &&
git config sendemail.aliasfiletype mailrc && git config sendemail.aliasfiletype mailrc &&
git send-email \ git send-email \
--from="Example <nobody@example.com>" \ --from="Example <nobody@example.com>" \
--to=sbd \ --to=sbd \
--smtp-server="$(pwd)/fake.sendmail" \ --smtp-server="$(pwd)/fake.sendmail" \
outdir/0001-*.patch \ outdir/0001-*.patch \
2>errors >out && 2>errors >out &&
grep "^!someone@example\.org!$" commandline1 grep "^!someone@example\.org!$" commandline1
' '