send-email: avoid empty transfer encoding header
Fix a small bug introduced by "7a36987ff (send-email: add an auto option for transfer encoding, 2018-07-14)". I saw the following message when setting --transfer-encoding for a file with the same encoding: $ git send-email --transfer-encoding=8bit example.patch Use of uninitialized value $xfer_encoding in concatenation (.) or string at /usr/lib/git-core/git-send-email line 1744. The new tests are by brian m. carlson. Signed-off-by: Aaron Lindsay <aaron@aclindsay.com> Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Aaron Lindsay committed
Nov 2, 2018 at 05:52 UTC
3c88e46f1a4328f594cbdcd6109034d9fb9a1b56
2 files changed
+16
-1
git-send-email.perl
+1
-1
@@ -1835,7 +1835,7 @@ sub apply_transfer_encoding {
1835
my $from = shift;
1836
my $to = shift;
1837
1838
- return $message if ($from eq $to and $from ne '7bit');
1838
+ return ($message, $to) if ($from eq $to and $from ne '7bit');
1839
1840
require MIME::QuotedPrint;
1841
require MIME::Base64;
t/t9001-send-email.sh
+15
@@ -493,6 +493,21 @@ do
493
--validate \
494
$patches longline.patch
495
'
496
+
497
+done
498
+
499
+for enc in 7bit 8bit quoted-printable base64
500
+do
501
+ test_expect_success $PREREQ "--transfer-encoding=$enc produces correct header" '
502
+ clean_fake_sendmail &&
503
+ git send-email \
504
+ --from="Example <nobody@example.com>" \
505
+ --to=nobody@example.com \
506
+ --smtp-server="$(pwd)/fake.sendmail" \
507
+ --transfer-encoding=$enc \
508
+ $patches &&
509
+ grep "Content-Transfer-Encoding: $enc" msgtxt1
510
+ '
511
done
512
513
test_expect_success $PREREQ 'Invalid In-Reply-To' '