update-index: fix a memleak
[gitweb.git] / t / t9001-send-email.sh
index 8aa7c0335f576a54aa5555932291c2ebed957d2a..051305545c414481b6883fa619ffb39134187de0 100755 (executable)
@@ -88,12 +88,12 @@ test_expect_success $PREREQ 'Send patches' '
 '
 
 test_expect_success $PREREQ 'setup expect' '
-cat >expected <<\EOF
-!nobody@example.com!
-!author@example.com!
-!one@example.com!
-!two@example.com!
-EOF
+       cat >expected <<-\EOF
+       !nobody@example.com!
+       !author@example.com!
+       !one@example.com!
+       !two@example.com!
+       EOF
 '
 
 test_expect_success $PREREQ 'Verify commandline' '
@@ -106,14 +106,14 @@ test_expect_success $PREREQ 'Send patches with --envelope-sender' '
 '
 
 test_expect_success $PREREQ 'setup expect' '
-cat >expected <<\EOF
-!patch@example.com!
-!-i!
-!nobody@example.com!
-!author@example.com!
-!one@example.com!
-!two@example.com!
-EOF
+       cat >expected <<-\EOF
+       !patch@example.com!
+       !-i!
+       !nobody@example.com!
+       !author@example.com!
+       !one@example.com!
+       !two@example.com!
+       EOF
 '
 
 test_expect_success $PREREQ 'Verify commandline' '
@@ -126,14 +126,14 @@ test_expect_success $PREREQ 'Send patches with --envelope-sender=auto' '
 '
 
 test_expect_success $PREREQ 'setup expect' '
-cat >expected <<\EOF
-!nobody@example.com!
-!-i!
-!nobody@example.com!
-!author@example.com!
-!one@example.com!
-!two@example.com!
-EOF
+       cat >expected <<-\EOF
+       !nobody@example.com!
+       !-i!
+       !nobody@example.com!
+       !author@example.com!
+       !one@example.com!
+       !two@example.com!
+       EOF
 '
 
 test_expect_success $PREREQ 'Verify commandline' '
@@ -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 \
@@ -1060,7 +1067,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 +1077,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 +1088,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
 '
@@ -1192,7 +1199,7 @@ test_expect_success $PREREQ 'To headers from files reset each patch' '
 '
 
 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
 Message-Id: <bogus-message-id@example.com>
 From: author@example.com
@@ -1204,9 +1211,7 @@ EOF
 '
 
 test_expect_success $PREREQ 'setup expect' '
-cat >expected <<EOF
-Subject: subject goes here
-EOF
+       echo "Subject: subject goes here" >expected
 '
 
 test_expect_success $PREREQ 'ASCII subject is not RFC2047 quoted' '
@@ -1221,11 +1226,11 @@ test_expect_success $PREREQ 'ASCII subject is not RFC2047 quoted' '
 '
 
 test_expect_success $PREREQ 'setup expect' '
-cat >content-type-decl <<EOF
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-EOF
+       cat >content-type-decl <<-\EOF
+       MIME-Version: 1.0
+       Content-Type: text/plain; charset=UTF-8
+       Content-Transfer-Encoding: 8bit
+       EOF
 '
 
 test_expect_success $PREREQ 'asks about and fixes 8bit encodings' '
@@ -1265,21 +1270,21 @@ test_expect_success $PREREQ '--8bit-encoding overrides sendemail.8bitEncoding' '
 '
 
 test_expect_success $PREREQ 'setup expect' '
-cat >email-using-8bit <<EOF
-From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001
-Message-Id: <bogus-message-id@example.com>
-From: author@example.com
-Date: Sat, 12 Jun 2010 15:53:58 +0200
-Subject: Dieser Betreff enthält auch einen Umlaut!
-
-Nothing to see here.
-EOF
+       cat >email-using-8bit <<-\EOF
+       From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001
+       Message-Id: <bogus-message-id@example.com>
+       From: author@example.com
+       Date: Sat, 12 Jun 2010 15:53:58 +0200
+       Subject: Dieser Betreff enthält auch einen Umlaut!
+
+       Nothing to see here.
+       EOF
 '
 
 test_expect_success $PREREQ 'setup expect' '
-cat >expected <<EOF
-Subject: =?UTF-8?q?Dieser=20Betreff=20enth=C3=A4lt=20auch=20einen=20Umlaut!?=
-EOF
+       cat >expected <<-\EOF
+       Subject: =?UTF-8?q?Dieser=20Betreff=20enth=C3=A4lt=20auch=20einen=20Umlaut!?=
+       EOF
 '
 
 test_expect_success $PREREQ '--8bit-encoding also treats subject' '
@@ -1294,16 +1299,16 @@ test_expect_success $PREREQ '--8bit-encoding also treats subject' '
 '
 
 test_expect_success $PREREQ 'setup expect' '
-cat >email-using-8bit <<EOF
-From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001
-Message-Id: <bogus-message-id@example.com>
-From: A U Thor <author@example.com>
-Date: Sat, 12 Jun 2010 15:53:58 +0200
-Content-Type: text/plain; charset=UTF-8
-Subject: Nothing to see here.
-
-Dieser Betreff enthält auch einen Umlaut!
-EOF
+       cat >email-using-8bit <<-\EOF
+       From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001
+       Message-Id: <bogus-message-id@example.com>
+       From: A U Thor <author@example.com>
+       Date: Sat, 12 Jun 2010 15:53:58 +0200
+       Content-Type: text/plain; charset=UTF-8
+       Subject: Nothing to see here.
+
+       Dieser Betreff enthält auch einen Umlaut!
+       EOF
 '
 
 test_expect_success $PREREQ 'sendemail.transferencoding=7bit fails on 8bit data' '
@@ -1343,9 +1348,9 @@ test_expect_success $PREREQ 'sendemail.transferencoding=8bit' '
 '
 
 test_expect_success $PREREQ 'setup expect' '
-cat >expected <<EOF
-Dieser Betreff enth=C3=A4lt auch einen Umlaut!
-EOF
+       cat >expected <<-\EOF
+       Dieser Betreff enth=C3=A4lt auch einen Umlaut!
+       EOF
 '
 
 test_expect_success $PREREQ '8-bit and sendemail.transferencoding=quoted-printable' '
@@ -1360,9 +1365,9 @@ test_expect_success $PREREQ '8-bit and sendemail.transferencoding=quoted-printab
 '
 
 test_expect_success $PREREQ 'setup expect' '
-cat >expected <<EOF
-RGllc2VyIEJldHJlZmYgZW50aMOkbHQgYXVjaCBlaW5lbiBVbWxhdXQhCg==
-EOF
+       cat >expected <<-\EOF
+       RGllc2VyIEJldHJlZmYgZW50aMOkbHQgYXVjaCBlaW5lbiBVbWxhdXQhCg==
+       EOF
 '
 
 test_expect_success $PREREQ '8-bit and sendemail.transferencoding=base64' '
@@ -1377,18 +1382,18 @@ test_expect_success $PREREQ '8-bit and sendemail.transferencoding=base64' '
 '
 
 test_expect_success $PREREQ 'setup expect' '
-cat >email-using-qp <<EOF
-From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001
-Message-Id: <bogus-message-id@example.com>
-From: A U Thor <author@example.com>
-Date: Sat, 12 Jun 2010 15:53:58 +0200
-MIME-Version: 1.0
-Content-Transfer-Encoding: quoted-printable
-Content-Type: text/plain; charset=UTF-8
-Subject: Nothing to see here.
+       cat >email-using-qp <<-\EOF
+       From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001
+       Message-Id: <bogus-message-id@example.com>
+       From: A U Thor <author@example.com>
+       Date: Sat, 12 Jun 2010 15:53:58 +0200
+       MIME-Version: 1.0
+       Content-Transfer-Encoding: quoted-printable
+       Content-Type: text/plain; charset=UTF-8
+       Subject: Nothing to see here.
 
-Dieser Betreff enth=C3=A4lt auch einen Umlaut!
-EOF
+       Dieser Betreff enth=C3=A4lt auch einen Umlaut!
+       EOF
 '
 
 test_expect_success $PREREQ 'convert from quoted-printable to base64' '
@@ -1416,9 +1421,9 @@ EOF
 "
 
 test_expect_success $PREREQ 'setup expect' '
-cat >expected <<EOF
-Look, I have a CRLF and an =3D sign!=0D
-EOF
+       cat >expected <<-\EOF
+       Look, I have a CRLF and an =3D sign!=0D
+       EOF
 '
 
 test_expect_success $PREREQ 'CRLF and sendemail.transferencoding=quoted-printable' '
@@ -1433,9 +1438,9 @@ test_expect_success $PREREQ 'CRLF and sendemail.transferencoding=quoted-printabl
 '
 
 test_expect_success $PREREQ 'setup expect' '
-cat >expected <<EOF
-TG9vaywgSSBoYXZlIGEgQ1JMRiBhbmQgYW4gPSBzaWduIQ0K
-EOF
+       cat >expected <<-\EOF
+       TG9vaywgSSBoYXZlIGEgQ1JMRiBhbmQgYW4gPSBzaWduIQ0K
+       EOF
 '
 
 test_expect_success $PREREQ 'CRLF and sendemail.transferencoding=base64' '
@@ -1559,4 +1564,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