]> git.ipfire.org Git - thirdparty/git.git/blobdiff - t/t9001-send-email.sh
Merge branch 'ma/mailing-list-address-in-git-help' into maint
[thirdparty/git.git] / t / t9001-send-email.sh
index 81869d89133a55b8e2d1fe676ff217636466f66f..1ef1a19003db5c9be94197e9d6cb25110591705b 100755 (executable)
@@ -178,6 +178,25 @@ test_expect_success $PREREQ 'cc trailer with various syntax' '
        test_cmp expected-cc commandline1
 '
 
+test_expect_success $PREREQ 'setup fake get_maintainer.pl script for cc trailer' "
+       write_script expected-cc-script.sh <<-EOF
+       echo 'One Person <one@example.com> (supporter:THIS (FOO/bar))'
+       echo 'Two Person <two@example.com> (maintainer:THIS THING)'
+       echo 'Third List <three@example.com> (moderated list:THIS THING (FOO/bar))'
+       echo '<four@example.com> (moderated list:FOR THING)'
+       echo 'five@example.com (open list:FOR THING (FOO/bar))'
+       echo 'six@example.com (open list)'
+       EOF
+"
+
+test_expect_success $PREREQ 'cc trailer with get_maintainer.pl output' '
+       clean_fake_sendmail &&
+       git send-email -1 --to=recipient@example.com \
+               --cc-cmd=./expected-cc-script.sh \
+               --smtp-server="$(pwd)/fake.sendmail" &&
+       test_cmp expected-cc commandline1
+'
+
 test_expect_success $PREREQ 'setup expect' "
 cat >expected-show-all-headers <<\EOF
 0001-Second.patch
@@ -205,6 +224,9 @@ Message-Id: MESSAGE-ID-STRING
 X-Mailer: X-MAILER-STRING
 In-Reply-To: <unique-message-id@example.com>
 References: <unique-message-id@example.com>
+Reply-To: Reply <reply@example.com>
+MIME-Version: 1.0
+Content-Transfer-Encoding: 8bit
 
 Result: OK
 EOF
@@ -231,10 +253,9 @@ test_suppress_self () {
 
        mv msgtxt1 msgtxt1-$3 &&
        sed -e '/^$/q' msgtxt1-$3 >"msghdr1-$3" &&
-       >"expected-no-cc-$3" &&
 
        (grep '^Cc:' msghdr1-$3 >"actual-no-cc-$3";
-        test_cmp expected-no-cc-$3 actual-no-cc-$3)
+        test_must_be_empty actual-no-cc-$3)
 }
 
 test_suppress_self_unquoted () {
@@ -297,6 +318,7 @@ test_expect_success $PREREQ 'Show all headers' '
                --dry-run \
                --suppress-cc=sob \
                --from="Example <from@example.com>" \
+               --reply-to="Reply <reply@example.com>" \
                --to=to@example.com \
                --cc=cc@example.com \
                --bcc=bcc@example.com \
@@ -309,7 +331,7 @@ test_expect_success $PREREQ 'Show all headers' '
 
 test_expect_success $PREREQ 'Prompting works' '
        clean_fake_sendmail &&
-       (echo "to@example.com"
+       (echo "to@example.com" &&
         echo ""
        ) | GIT_SEND_EMAIL_NOTTY=1 git send-email \
                --smtp-server="$(pwd)/fake.sendmail" \
@@ -394,6 +416,7 @@ test_expect_success $PREREQ 'reject long lines' '
                --from="Example <nobody@example.com>" \
                --to=nobody@example.com \
                --smtp-server="$(pwd)/fake.sendmail" \
+               --transfer-encoding=8bit \
                $patches longline.patch \
                2>errors &&
        grep longline.patch errors
@@ -435,6 +458,42 @@ test_expect_success $PREREQ 'allow long lines with --no-validate' '
                2>errors
 '
 
+test_expect_success $PREREQ 'short lines with auto encoding are 8bit' '
+       clean_fake_sendmail &&
+       git send-email \
+               --from="A <author@example.com>" \
+               --to=nobody@example.com \
+               --smtp-server="$(pwd)/fake.sendmail" \
+               --transfer-encoding=auto \
+               $patches &&
+       grep "Content-Transfer-Encoding: 8bit" msgtxt1
+'
+
+test_expect_success $PREREQ 'long lines with auto encoding are quoted-printable' '
+       clean_fake_sendmail &&
+       git send-email \
+               --from="Example <nobody@example.com>" \
+               --to=nobody@example.com \
+               --smtp-server="$(pwd)/fake.sendmail" \
+               --transfer-encoding=auto \
+               --no-validate \
+               longline.patch &&
+       grep "Content-Transfer-Encoding: quoted-printable" msgtxt1
+'
+
+for enc in auto quoted-printable base64
+do
+       test_expect_success $PREREQ "--validate passes with encoding $enc" '
+               git send-email \
+                       --from="Example <nobody@example.com>" \
+                       --to=nobody@example.com \
+                       --smtp-server="$(pwd)/fake.sendmail" \
+                       --transfer-encoding=$enc \
+                       --validate \
+                       $patches longline.patch
+       '
+done
+
 test_expect_success $PREREQ 'Invalid In-Reply-To' '
        clean_fake_sendmail &&
        git send-email \
@@ -449,8 +508,8 @@ test_expect_success $PREREQ 'Invalid In-Reply-To' '
 
 test_expect_success $PREREQ 'Valid In-Reply-To when prompting' '
        clean_fake_sendmail &&
-       (echo "From Example <from@example.com>"
-        echo "To Example <to@example.com>"
+       (echo "From Example <from@example.com>" &&
+        echo "To Example <to@example.com>" &&
         echo ""
        ) | GIT_SEND_EMAIL_NOTTY=1 git send-email \
                --smtp-server="$(pwd)/fake.sendmail" \
@@ -552,6 +611,8 @@ Subject: [PATCH 1/1] Second.
 Date: DATE-STRING
 Message-Id: MESSAGE-ID-STRING
 X-Mailer: X-MAILER-STRING
+MIME-Version: 1.0
+Content-Transfer-Encoding: 8bit
 
 Result: OK
 EOF
@@ -596,6 +657,8 @@ Subject: [PATCH 1/1] Second.
 Date: DATE-STRING
 Message-Id: MESSAGE-ID-STRING
 X-Mailer: X-MAILER-STRING
+MIME-Version: 1.0
+Content-Transfer-Encoding: 8bit
 
 Result: OK
 EOF
@@ -631,6 +694,8 @@ Subject: [PATCH 1/1] Second.
 Date: DATE-STRING
 Message-Id: MESSAGE-ID-STRING
 X-Mailer: X-MAILER-STRING
+MIME-Version: 1.0
+Content-Transfer-Encoding: 8bit
 
 Result: OK
 EOF
@@ -657,6 +722,8 @@ Subject: [PATCH 1/1] Second.
 Date: DATE-STRING
 Message-Id: MESSAGE-ID-STRING
 X-Mailer: X-MAILER-STRING
+MIME-Version: 1.0
+Content-Transfer-Encoding: 8bit
 
 Result: OK
 EOF
@@ -691,6 +758,8 @@ Subject: [PATCH 1/1] Second.
 Date: DATE-STRING
 Message-Id: MESSAGE-ID-STRING
 X-Mailer: X-MAILER-STRING
+MIME-Version: 1.0
+Content-Transfer-Encoding: 8bit
 
 Result: OK
 EOF
@@ -722,6 +791,8 @@ Subject: [PATCH 1/1] Second.
 Date: DATE-STRING
 Message-Id: MESSAGE-ID-STRING
 X-Mailer: X-MAILER-STRING
+MIME-Version: 1.0
+Content-Transfer-Encoding: 8bit
 
 Result: OK
 EOF
@@ -753,6 +824,8 @@ Subject: [PATCH 1/1] Second.
 Date: DATE-STRING
 Message-Id: MESSAGE-ID-STRING
 X-Mailer: X-MAILER-STRING
+MIME-Version: 1.0
+Content-Transfer-Encoding: 8bit
 
 Result: OK
 EOF
@@ -788,6 +861,8 @@ Subject: [PATCH 1/1] Second.
 Date: DATE-STRING
 Message-Id: MESSAGE-ID-STRING
 X-Mailer: X-MAILER-STRING
+MIME-Version: 1.0
+Content-Transfer-Encoding: 8bit
 
 Result: OK
 EOF
@@ -816,6 +891,8 @@ Subject: [PATCH 1/1] Second.
 Date: DATE-STRING
 Message-Id: MESSAGE-ID-STRING
 X-Mailer: X-MAILER-STRING
+MIME-Version: 1.0
+Content-Transfer-Encoding: 8bit
 
 Result: OK
 EOF
@@ -1945,11 +2022,11 @@ test_expect_success $PREREQ 'invoke hook' '
 
                # Verify error message when a patch is rejected by the hook
                sed -e "s/add master/x/" ../0001-add-master.patch >../another.patch &&
-               git send-email \
+               test_must_fail git send-email \
                        --from="Example <nobody@example.com>" \
                        --to=nobody@example.com \
                        --smtp-server="$(pwd)/../fake.sendmail" \
-                       ../another.patch 2>err
+                       ../another.patch 2>err &&
                test_i18ngrep "rejected by sendemail-validate hook" err
        )
 '