format_config: don't init strbuf
[gitweb.git] / t / t9001-send-email.sh
index e37efef5ca6fce69b0ec5e0103a2ca9f5f5cb234..7be14a4e37f7843d9a9863a21e9181ffeceee11b 100755 (executable)
@@ -242,6 +242,13 @@ test_expect_success $PREREQ 'non-ascii self name is suppressed' "
                'non_ascii_self_suppressed'
 "
 
+# This name is long enough to force format-patch to split it into multiple
+# encoded-words, assuming it uses UTF-8 with the "Q" encoding.
+test_expect_success $PREREQ 'long non-ascii self name is suppressed' "
+       test_suppress_self_quoted 'Ƒüñníęř €. Nâṁé' 'odd_?=mail@example.com' \
+               'long_non_ascii_self_suppressed'
+"
+
 test_expect_success $PREREQ 'sanitized self name is suppressed' "
        test_suppress_self_unquoted '\"A U. Thor\"' 'author@example.com' \
                'self_name_sanitized_suppressed'
@@ -385,7 +392,7 @@ test_expect_success $PREREQ 'allow long lines with --no-validate' '
                --from="Example <nobody@example.com>" \
                --to=nobody@example.com \
                --smtp-server="$(pwd)/fake.sendmail" \
-               --novalidate \
+               --no-validate \
                $patches longline.patch \
                2>errors
 '
@@ -419,7 +426,7 @@ test_expect_success $PREREQ 'In-Reply-To without --chain-reply-to' '
        git send-email \
                --from="Example <nobody@example.com>" \
                --to=nobody@example.com \
-               --nochain-reply-to \
+               --no-chain-reply-to \
                --in-reply-to="$(cat expect)" \
                --smtp-server="$(pwd)/fake.sendmail" \
                $patches $patches $patches \
@@ -811,25 +818,19 @@ test_expect_success $PREREQ '--confirm=compose' '
 '
 
 test_expect_success $PREREQ 'confirm by default (due to cc)' '
-       CONFIRM=$(git config --get sendemail.confirm) &&
+       test_when_finished git config sendemail.confirm never &&
        git config --unset sendemail.confirm &&
        test_confirm
-       ret="$?"
-       git config sendemail.confirm ${CONFIRM:-never}
-       test $ret = "0"
 '
 
 test_expect_success $PREREQ 'confirm by default (due to --compose)' '
-       CONFIRM=$(git config --get sendemail.confirm) &&
+       test_when_finished git config sendemail.confirm never &&
        git config --unset sendemail.confirm &&
        test_confirm --suppress-cc=all --compose
-       ret="$?"
-       git config sendemail.confirm ${CONFIRM:-never}
-       test $ret = "0"
 '
 
 test_expect_success $PREREQ 'confirm detects EOF (inform assumes y)' '
-       CONFIRM=$(git config --get sendemail.confirm) &&
+       test_when_finished git config sendemail.confirm never &&
        git config --unset sendemail.confirm &&
        rm -fr outdir &&
        git format-patch -2 -o outdir &&
@@ -839,13 +840,10 @@ test_expect_success $PREREQ 'confirm detects EOF (inform assumes y)' '
                        --to=nobody@example.com \
                        --smtp-server="$(pwd)/fake.sendmail" \
                        outdir/*.patch </dev/null
-       ret="$?"
-       git config sendemail.confirm ${CONFIRM:-never}
-       test $ret = "0"
 '
 
 test_expect_success $PREREQ 'confirm detects EOF (auto causes failure)' '
-       CONFIRM=$(git config --get sendemail.confirm) &&
+       test_when_finished git config sendemail.confirm never &&
        git config sendemail.confirm auto &&
        GIT_SEND_EMAIL_NOTTY=1 &&
        export GIT_SEND_EMAIL_NOTTY &&
@@ -854,13 +852,10 @@ test_expect_success $PREREQ 'confirm detects EOF (auto causes failure)' '
                        --to=nobody@example.com \
                        --smtp-server="$(pwd)/fake.sendmail" \
                        $patches </dev/null
-       ret="$?"
-       git config sendemail.confirm ${CONFIRM:-never}
-       test $ret = "0"
 '
 
 test_expect_success $PREREQ 'confirm does not loop forever' '
-       CONFIRM=$(git config --get sendemail.confirm) &&
+       test_when_finished git config sendemail.confirm never &&
        git config sendemail.confirm auto &&
        GIT_SEND_EMAIL_NOTTY=1 &&
        export GIT_SEND_EMAIL_NOTTY &&
@@ -869,9 +864,6 @@ test_expect_success $PREREQ 'confirm does not loop forever' '
                        --to=nobody@example.com \
                        --smtp-server="$(pwd)/fake.sendmail" \
                        $patches
-       ret="$?"
-       git config sendemail.confirm ${CONFIRM:-never}
-       test $ret = "0"
 '
 
 test_expect_success $PREREQ 'utf8 Cc is rfc2047 encoded' '
@@ -1060,7 +1052,7 @@ test_expect_success $PREREQ 'in-reply-to but no threading' '
                --from="Example <nobody@example.com>" \
                --to=nobody@example.com \
                --in-reply-to="<in-reply-id@example.com>" \
-               --nothread \
+               --no-thread \
                $patches |
        grep "In-Reply-To: <in-reply-id@example.com>"
 '
@@ -1070,7 +1062,7 @@ test_expect_success $PREREQ 'no in-reply-to and no threading' '
                --dry-run \
                --from="Example <nobody@example.com>" \
                --to=nobody@example.com \
-               --nothread \
+               --no-thread \
                $patches $patches >stdout &&
        ! grep "In-Reply-To: " stdout
 '
@@ -1081,7 +1073,7 @@ test_expect_success $PREREQ 'threading but no chain-reply-to' '
                --from="Example <nobody@example.com>" \
                --to=nobody@example.com \
                --thread \
-               --nochain-reply-to \
+               --no-chain-reply-to \
                $patches $patches >stdout &&
        grep "In-Reply-To: " stdout
 '
@@ -1318,7 +1310,7 @@ test_expect_success $PREREQ 'sendemail.transferencoding=7bit fails on 8bit data'
 
 test_expect_success $PREREQ '--transfer-encoding overrides sendemail.transferEncoding' '
        clean_fake_sendmail &&
-       git config sendemail.transferEncoding 8bit
+       git config sendemail.transferEncoding 8bit &&
        test_must_fail git send-email \
                --transfer-encoding=7bit \
                --smtp-server="$(pwd)/fake.sendmail" \
@@ -1557,4 +1549,37 @@ test_expect_success $PREREQ 'sendemail.aliasfile=~/.mailrc' '
        grep "^!someone@example\.org!$" commandline1
 '
 
+do_xmailer_test () {
+       expected=$1 params=$2 &&
+       git format-patch -1 &&
+       git send-email \
+               --from="Example <nobody@example.com>" \
+               --to=someone@example.com \
+               --smtp-server="$(pwd)/fake.sendmail" \
+               $params \
+               0001-*.patch \
+               2>errors >out &&
+       { grep '^X-Mailer:' out || :; } >mailer &&
+       test_line_count = $expected mailer
+}
+
+test_expect_success $PREREQ '--[no-]xmailer without any configuration' '
+       do_xmailer_test 1 "--xmailer" &&
+       do_xmailer_test 0 "--no-xmailer"
+'
+
+test_expect_success $PREREQ '--[no-]xmailer with sendemail.xmailer=true' '
+       test_config sendemail.xmailer true &&
+       do_xmailer_test 1 "" &&
+       do_xmailer_test 0 "--no-xmailer" &&
+       do_xmailer_test 1 "--xmailer"
+'
+
+test_expect_success $PREREQ '--[no-]xmailer with sendemail.xmailer=false' '
+       test_config sendemail.xmailer false &&
+       do_xmailer_test 0 "" &&
+       do_xmailer_test 0 "--no-xmailer" &&
+       do_xmailer_test 1 "--xmailer"
+'
+
 test_done