From patchwork Fri Nov 2 09:52:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Lindsay X-Patchwork-Id: 10665219 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 47EA913BF for ; Fri, 2 Nov 2018 09:53:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 365D22B519 for ; Fri, 2 Nov 2018 09:53:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 279F12B531; Fri, 2 Nov 2018 09:53:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B318E2B519 for ; Fri, 2 Nov 2018 09:53:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726059AbeKBS7h (ORCPT ); Fri, 2 Nov 2018 14:59:37 -0400 Received: from mail.aclindsay.com ([45.79.160.72]:39714 "EHLO mail.aclindsay.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726008AbeKBS7h (ORCPT ); Fri, 2 Nov 2018 14:59:37 -0400 Received: from localhost.localdomain (cpe-65-190-6-212.nc.res.rr.com [65.190.6.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by mail.aclindsay.com (Postfix) with ESMTPSA id 47D895E215; Fri, 2 Nov 2018 05:53:01 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=aclindsay.com; s=dkimselector; t=1541152381; bh=caQSFzKer5xRexSgZkwuxpTzcacrupNCmnlfbTv16yc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=v0RxrBSWpGSN98icLo8oVR0ujv3HiHcoZw386urND/4Zwrmd+QRuKnshsiRpgRHL7 HOF7WNiti18vdOC8sN/imuwEhoiaFHf306KradPVIO+6Fb7+ZYsuGVhrBW4Xnbw1oY 6eoh0vN8nEphqq4MPoyPX2uUwEviza0uWqR3WqdQ= From: Aaron Lindsay To: git@vger.kernel.org Cc: "brian m . carlson" , Paolo Bonzini , Junio C Hamano , Aaron Lindsay Subject: [PATCH v2] send-email: Avoid empty transfer encoding header Date: Fri, 2 Nov 2018 05:52:38 -0400 Message-Id: <20181102095238.25766-1-aaron@aclindsay.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181102015335.GC731755@genre.crustytoothpaste.net> References: <20181102015335.GC731755@genre.crustytoothpaste.net> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Signed-off-by: brian m. carlson --- 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 " \ + --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' '