git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] send-email: Avoid empty transfer encoding header
@ 2018-11-02  1:09 Aaron Lindsay
  2018-11-02  1:53 ` brian m. carlson
  0 siblings, 1 reply; 3+ messages in thread
From: Aaron Lindsay @ 2018-11-02  1:09 UTC (permalink / raw)
  To: git; +Cc: brian m . carlson, Paolo Bonzini, Junio C Hamano, Aaron Lindsay

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.

Signed-off-by: Aaron Lindsay <aaron@aclindsay.com>
---
 git-send-email.perl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/git-send-email.perl b/git-send-email.perl
index 2be5dac33..39c15bcc8 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -1834,7 +1834,7 @@ sub apply_transfer_encoding {
 	my $from = shift;
 	my $to = shift;
 
-	return $message if ($from eq $to and $from ne '7bit');
+	return ($message, $to) if ($from eq $to and $from ne '7bit');
 
 	require MIME::QuotedPrint;
 	require MIME::Base64;
-- 
2.19.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] send-email: Avoid empty transfer encoding header
  2018-11-02  1:09 [PATCH] send-email: Avoid empty transfer encoding header Aaron Lindsay
@ 2018-11-02  1:53 ` brian m. carlson
  2018-11-02  9:52   ` [PATCH v2] " Aaron Lindsay
  0 siblings, 1 reply; 3+ messages in thread
From: brian m. carlson @ 2018-11-02  1:53 UTC (permalink / raw)
  To: Aaron Lindsay; +Cc: git, Paolo Bonzini, Junio C Hamano

[-- Attachment #1: Type: text/plain, Size: 2325 bytes --]

On Thu, Nov 01, 2018 at 09:09:34PM -0400, Aaron Lindsay wrote:
> 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.
> 
> Signed-off-by: Aaron Lindsay <aaron@aclindsay.com>
> ---
>  git-send-email.perl | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/git-send-email.perl b/git-send-email.perl
> index 2be5dac33..39c15bcc8 100755
> --- a/git-send-email.perl
> +++ b/git-send-email.perl
> @@ -1834,7 +1834,7 @@ sub apply_transfer_encoding {
>  	my $from = shift;
>  	my $to = shift;
>  
> -	return $message if ($from eq $to and $from ne '7bit');
> +	return ($message, $to) if ($from eq $to and $from ne '7bit');

Thanks, this is obviously correct.

Would you like to squash in the below patch to add a test?

----- >% -----
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: "brian m. carlson" <sandals@crustytoothpaste.net>
Date: Fri, 2 Nov 2018 01:51:33 +0000
Subject: [PATCH] squash! send-email: Avoid empty transfer encoding header

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
 t/t9001-send-email.sh | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh
index 1ef1a19003..ee1efcc59d 100755
--- a/t/t9001-send-email.sh
+++ b/t/t9001-send-email.sh
@@ -492,6 +492,21 @@ do
 			--validate \
 			$patches longline.patch
 	'
+
+done
+
+for enc in 7bit 8bit quoted-printable base64
+do
+	test_expect_success $PREREQ "--transfer-encoding=$enc produces correct header" '
+		clean_fake_sendmail &&
+		git send-email \
+			--from="Example <nobody@example.com>" \
+			--to=nobody@example.com \
+			--smtp-server="$(pwd)/fake.sendmail" \
+			--transfer-encoding=$enc \
+			$patches &&
+		grep "Content-Transfer-Encoding: $enc" msgtxt1
+	'
 done
 
 test_expect_success $PREREQ 'Invalid In-Reply-To' '
-- 
brian m. carlson: Houston, Texas, US
OpenPGP: https://keybase.io/bk2204

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 868 bytes --]

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH v2] send-email: Avoid empty transfer encoding header
  2018-11-02  1:53 ` brian m. carlson
@ 2018-11-02  9:52   ` Aaron Lindsay
  0 siblings, 0 replies; 3+ messages in thread
From: Aaron Lindsay @ 2018-11-02  9:52 UTC (permalink / raw)
  To: git; +Cc: brian m . carlson, Paolo Bonzini, Junio C Hamano, Aaron Lindsay

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.

v2 adds a test provided by brian m. carlson.

Signed-off-by: Aaron Lindsay <aaron@aclindsay.com>
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
 git-send-email.perl   |  2 +-
 t/t9001-send-email.sh | 15 +++++++++++++++
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/git-send-email.perl b/git-send-email.perl
index 2be5dac33..39c15bcc8 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -1834,7 +1834,7 @@ sub apply_transfer_encoding {
 	my $from = shift;
 	my $to = shift;
 
-	return $message if ($from eq $to and $from ne '7bit');
+	return ($message, $to) if ($from eq $to and $from ne '7bit');
 
 	require MIME::QuotedPrint;
 	require MIME::Base64;
diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh
index 1ef1a1900..ee1efcc59 100755
--- a/t/t9001-send-email.sh
+++ b/t/t9001-send-email.sh
@@ -492,6 +492,21 @@ do
 			--validate \
 			$patches longline.patch
 	'
+
+done
+
+for enc in 7bit 8bit quoted-printable base64
+do
+	test_expect_success $PREREQ "--transfer-encoding=$enc produces correct header" '
+		clean_fake_sendmail &&
+		git send-email \
+			--from="Example <nobody@example.com>" \
+			--to=nobody@example.com \
+			--smtp-server="$(pwd)/fake.sendmail" \
+			--transfer-encoding=$enc \
+			$patches &&
+		grep "Content-Transfer-Encoding: $enc" msgtxt1
+	'
 done
 
 test_expect_success $PREREQ 'Invalid In-Reply-To' '
-- 
2.19.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-11-02  9:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-02  1:09 [PATCH] send-email: Avoid empty transfer encoding header Aaron Lindsay
2018-11-02  1:53 ` brian m. carlson
2018-11-02  9:52   ` [PATCH v2] " Aaron Lindsay

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).