Merge branch 'maint'
[gitweb.git] / t / t9001-send-email.sh
index b4de98c1f2a3d56858744dab4a06d96a30acdb81..ce26ea4ac53a4608f6f8234b67868a9cc85be7f8 100755 (executable)
@@ -3,6 +3,11 @@
 test_description='git send-email'
 . ./test-lib.sh
 
+if ! test_have_prereq PERL; then
+       say 'skipping git send-email tests, perl not available'
+       test_done
+fi
+
 PROG='git send-email'
 test_expect_success \
     'prepare reference tree' \
@@ -130,6 +135,19 @@ test_expect_success 'Show all headers' '
        test_cmp expected-show-all-headers actual-show-all-headers
 '
 
+test_expect_success 'Prompting works' '
+       clean_fake_sendmail &&
+       (echo "Example <from@example.com>"
+        echo "to@example.com"
+        echo ""
+       ) | GIT_SEND_EMAIL_NOTTY=1 git send-email \
+               --smtp-server="$(pwd)/fake.sendmail" \
+               $patches \
+               2>errors &&
+               grep "^From: Example <from@example.com>$" msgtxt1 &&
+               grep "^To: to@example.com$" msgtxt1
+'
+
 z8=zzzzzzzz
 z64=$z8$z8$z8$z8$z8$z8$z8$z8
 z512=$z64$z64$z64$z64$z64$z64$z64$z64
@@ -462,12 +480,14 @@ test_expect_success 'confirm by default (due to --compose)' '
 test_expect_success 'confirm detects EOF (inform assumes y)' '
        CONFIRM=$(git config --get sendemail.confirm) &&
        git config --unset sendemail.confirm &&
+       rm -fr outdir &&
+       git format-patch -2 -o outdir &&
        GIT_SEND_EMAIL_NOTTY=1 \
                git send-email \
                        --from="Example <nobody@example.com>" \
                        --to=nobody@example.com \
                        --smtp-server="$(pwd)/fake.sendmail" \
-                       $patches < /dev/null
+                       outdir/*.patch < /dev/null
        ret="$?"
        git config sendemail.confirm ${CONFIRM:-never}
        test $ret = "0"
@@ -476,7 +496,8 @@ test_expect_success 'confirm detects EOF (inform assumes y)' '
 test_expect_success 'confirm detects EOF (auto causes failure)' '
        CONFIRM=$(git config --get sendemail.confirm) &&
        git config sendemail.confirm auto &&
-       GIT_SEND_EMAIL_NOTTY=1 \
+       GIT_SEND_EMAIL_NOTTY=1 &&
+       export GIT_SEND_EMAIL_NOTTY &&
                test_must_fail git send-email \
                        --from="Example <nobody@example.com>" \
                        --to=nobody@example.com \
@@ -490,8 +511,9 @@ test_expect_success 'confirm detects EOF (auto causes failure)' '
 test_expect_success 'confirm doesnt loop forever' '
        CONFIRM=$(git config --get sendemail.confirm) &&
        git config sendemail.confirm auto &&
-       yes "bogus" | GIT_SEND_EMAIL_NOTTY=1 \
-               test_must_fail git send-email \
+       GIT_SEND_EMAIL_NOTTY=1 &&
+       export GIT_SEND_EMAIL_NOTTY &&
+               yes "bogus" | test_must_fail git send-email \
                        --from="Example <nobody@example.com>" \
                        --to=nobody@example.com \
                        --smtp-server="$(pwd)/fake.sendmail" \
@@ -501,6 +523,19 @@ test_expect_success 'confirm doesnt loop forever' '
        test $ret = "0"
 '
 
+test_expect_success 'utf8 Cc is rfc2047 encoded' '
+       clean_fake_sendmail &&
+       rm -fr outdir &&
+       git format-patch -1 -o outdir --cc="àéìöú <utf8@example.com>" &&
+       git send-email \
+       --from="Example <nobody@example.com>" \
+       --to=nobody@example.com \
+       --smtp-server="$(pwd)/fake.sendmail" \
+       outdir/*.patch &&
+       grep "^Cc:" msgtxt1 |
+       grep "=?utf-8?q?=C3=A0=C3=A9=C3=AC=C3=B6=C3=BA?= <utf8@example.com>"
+'
+
 test_expect_success '--compose adds MIME for utf8 body' '
        clean_fake_sendmail &&
        (echo "#!$SHELL_PATH" &&
@@ -581,7 +616,7 @@ test_expect_success 'in-reply-to but no threading' '
                --from="Example <nobody@example.com>" \
                --to=nobody@example.com \
                --in-reply-to="<in-reply-id@example.com>" \
-               --no-thread \
+               --nothread \
                $patches |
        grep "In-Reply-To: <in-reply-id@example.com>"
 '