From patchwork Wed May 8 08:18:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Junio C Hamano X-Patchwork-Id: 10934681 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 79C911515 for ; Wed, 8 May 2019 08:18:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6C35D286D0 for ; Wed, 8 May 2019 08:18:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6015C28935; Wed, 8 May 2019 08:18:12 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 6C2C9286D0 for ; Wed, 8 May 2019 08:18:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727065AbfEHISJ (ORCPT ); Wed, 8 May 2019 04:18:09 -0400 Received: from pb-smtp2.pobox.com ([64.147.108.71]:58935 "EHLO pb-smtp2.pobox.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726411AbfEHISI (ORCPT ); Wed, 8 May 2019 04:18:08 -0400 Received: from pb-smtp2.pobox.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id ED07D148CE2; Wed, 8 May 2019 04:18:04 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; s=sasl; bh=NXgM0EbzxscXygeS9ZpeZ+hxpZ8=; b=rEjwls 4NGY2goQ6OXXMxessgKjCKAB2bExfoaDqGy4ZZIyL+q8crCTVxHK9N5VaMnYOSC9 ajxzTDOYANgo1G5JCOLI7Ny6AFJPKCu7NrYPWSPxx2X8kNO7oL0jJkGEBfgt0P8e 8tuvDVThuqlDWdMtXKNP1xJOLaSSgEVkGJ7MQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; q=dns; s=sasl; b=sX4e3ZnG7QdYpkLTpnwlUwdY45ok0H8E o22py/bnURiPcZVN6fzdkJkK0KVa+WfT5HdjsT0CQBO+Q2UVexgriX71OBSlMwX3 gIcFrO3eoVuyAZGtMvRGKHK7TuIX5pda7IWW/AZ10/7rTma/YuiPnkv6TwqEoz+l K9StBH7rEVw= Received: from pb-smtp2.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id E4320148CE1; Wed, 8 May 2019 04:18:04 -0400 (EDT) Received: from pobox.com (unknown [34.76.255.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp2.pobox.com (Postfix) with ESMTPSA id 502BA148CDF; Wed, 8 May 2019 04:18:04 -0400 (EDT) From: Junio C Hamano To: Heinrich Schuchardt Cc: Brian M Carlson , git@vger.kernel.org, Jonathan Nieder Subject: Re* [PATCH 1/1] send-email: fix transferencoding config option References: <20190409192733.10173-1-xypron.glpk@gmx.de> <20190409215856.GD92879@google.com> Date: Wed, 08 May 2019 17:18:03 +0900 In-Reply-To: (Junio C. Hamano's message of "Wed, 10 Apr 2019 12:48:38 +0900") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux) MIME-Version: 1.0 X-Pobox-Relay-ID: CD6C11EE-7169-11E9-B93E-E828E74BB12D-77302942!pb-smtp2.pobox.com Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Junio C Hamano writes: > I wonder if we can follow the pattern used by the code to handle the > fallback for %config_bool_settings we can see immediately after > these two calls to read_config()? That is, each of the element in > the %config_* hash is not merely a pointer to where the value is > stored, but also knows what the default fallback value should be, > and a loop _in the caller of_ read_config(), after it finishes > making calls to the read_config function, fills in the missing > default? So, here is a two-patch series that tries to do so, primarily done to gauge if there still is the level of interest needed to make it worth for us to pursue this topic. Here is the first one; I'll send the second one that takes advantage of this change separately (but it should be trivial to imagine what that step would involve). -- >8 -- Subject: [PATCH 1/2] send-email: update the mechanism to set default configuration values The program has a good mechanism to specify the fallback default values for boolean configuration variables after two invocations of read_config() for "sendmail.$ident.$var" and "sendemail.$var" have not found any configuration. Imitate it so that we can set the default values for non-boolean variables as well. Signed-off-by: Junio C Hamano --- git-send-email.perl | 51 ++++++++++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 22 deletions(-) diff --git a/git-send-email.perl b/git-send-email.perl index f4c07908d2..ca7faff094 100755 --- a/git-send-email.perl +++ b/git-send-email.perl @@ -250,28 +250,28 @@ sub do_edit { ); my %config_settings = ( - "smtpserver" => \$smtp_server, - "smtpserverport" => \$smtp_server_port, - "smtpserveroption" => \@smtp_server_options, - "smtpuser" => \$smtp_authuser, - "smtppass" => \$smtp_authpass, - "smtpdomain" => \$smtp_domain, - "smtpauth" => \$smtp_auth, - "smtpbatchsize" => \$batch_size, - "smtprelogindelay" => \$relogin_delay, - "to" => \@initial_to, - "tocmd" => \$to_cmd, - "cc" => \@initial_cc, - "cccmd" => \$cc_cmd, - "aliasfiletype" => \$aliasfiletype, - "bcc" => \@bcclist, - "suppresscc" => \@suppress_cc, - "envelopesender" => \$envelope_sender, - "confirm" => \$confirm, - "from" => \$sender, - "assume8bitencoding" => \$auto_8bit_encoding, - "composeencoding" => \$compose_encoding, - "transferencoding" => \$target_xfer_encoding, + "smtpserver" => [\$smtp_server], + "smtpserverport" => [\$smtp_server_port], + "smtpserveroption" => [\@smtp_server_options], + "smtpuser" => [\$smtp_authuser], + "smtppass" => [\$smtp_authpass], + "smtpdomain" => [\$smtp_domain], + "smtpauth" => [\$smtp_auth], + "smtpbatchsize" => [\$batch_size], + "smtprelogindelay" => [\$relogin_delay], + "to" => [\@initial_to], + "tocmd" => [\$to_cmd], + "cc" => [\@initial_cc], + "cccmd" => [\$cc_cmd], + "aliasfiletype" => [\$aliasfiletype], + "bcc" => [\@bcclist], + "suppresscc" => [\@suppress_cc], + "envelopesender" => [\$envelope_sender], + "confirm" => [\$confirm], + "from" => [\$sender], + "assume8bitencoding" => [\$auto_8bit_encoding], + "composeencoding" => [\$compose_encoding], + "transferencoding" => [\$target_xfer_encoding], ); my %config_path_settings = ( @@ -446,6 +446,13 @@ sub read_config { ${$setting->[0]} = $setting->[1] unless (defined (${$setting->[0]})); } +# fall back to builtin defaults +for my $setting (values %config_settings) { + if (@$setting == 2 && !defined (${$setting->[0]})) { + ${$setting->[0]} = $setting->[1]; + } +} + # 'default' encryption is none -- this only prevents a warning $smtp_encryption = '' unless (defined $smtp_encryption); From patchwork Wed May 8 08:20:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Junio C Hamano X-Patchwork-Id: 10934701 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 A5295933 for ; Wed, 8 May 2019 08:20:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 89D7528A45 for ; Wed, 8 May 2019 08:20:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2FFF128A11; Wed, 8 May 2019 08:20:56 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 E380D28A1D for ; Wed, 8 May 2019 08:20:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726733AbfEHIUt (ORCPT ); Wed, 8 May 2019 04:20:49 -0400 Received: from pb-smtp21.pobox.com ([173.228.157.53]:56325 "EHLO pb-smtp21.pobox.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725889AbfEHIUt (ORCPT ); Wed, 8 May 2019 04:20:49 -0400 Received: from pb-smtp21.pobox.com (unknown [127.0.0.1]) by pb-smtp21.pobox.com (Postfix) with ESMTP id 299F36C894; Wed, 8 May 2019 04:20:49 -0400 (EDT) (envelope-from junio@pobox.com) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; s=sasl; bh=kY8R49DuhvdVWnQayxp07YPjByk=; b=S57S9S q7Iwp9V0BFT4/MvVWAUC2XNKkyTvRAJ/BYELejTf8dIUL/rNE1g2eyMPwhHbgA62 86GW4bWZK3ytCKmuT07siNk0b2DIfJsSxSoPpCwcDTxeBc1xkQMBuLtRp3ocFfeJ akgOBPXhGHfKvKvxZYond5vFy+xHNXK0N/tXk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; q=dns; s=sasl; b=PAK6pxK/15I/9Npx1SflvjIkzrpwg1/z Dp/2yeUGCDG+vrWVXAjboVu9jVPaTt/QlF0arjM/Uwu1H6oIxcQrPlm2eRe6FWTn tzX+q3fdfncb7thREpGM1NLYLSGyzuIL5fHUDeKrJGfRb5jeL23OgSk1auCgR4py vglBv4Dm3+0= Received: from pb-smtp21.sea.icgroup.com (unknown [127.0.0.1]) by pb-smtp21.pobox.com (Postfix) with ESMTP id 21BFC6C893; Wed, 8 May 2019 04:20:49 -0400 (EDT) (envelope-from junio@pobox.com) Received: from pobox.com (unknown [34.76.255.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp21.pobox.com (Postfix) with ESMTPSA id 51A426C892; Wed, 8 May 2019 04:20:46 -0400 (EDT) (envelope-from junio@pobox.com) From: Junio C Hamano To: Heinrich Schuchardt Cc: Brian M Carlson , git@vger.kernel.org, Jonathan Nieder Subject: [PATCH 2/2] send-email: honor transferencoding config option again References: <20190409192733.10173-1-xypron.glpk@gmx.de> <20190409215856.GD92879@google.com> Date: Wed, 08 May 2019 17:20:44 +0900 In-Reply-To: (Junio C. Hamano's message of "Wed, 08 May 2019 17:18:03 +0900") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux) MIME-Version: 1.0 X-Pobox-Relay-ID: 2DFC253A-716A-11E9-9D8F-8D86F504CC47-77302942!pb-smtp21.pobox.com Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Since e67a228cd8a ("send-email: automatically determine transfer-encoding"), the value of sendmail.transferencoding in the configuration file is ignored, because $target_xfer_encoding is already defined read_config sub parses the configuration file. Instead of initializing variable $target_xfer_encoding to 'auto' on definition, we have to set it to the default value of 'auto' if is undefined after calling read_config() twice to parsing the configuration files for "sendemail.transferencoding" and "sendemail.$ident.transferencoding". This is made trivial by the previous change. Signed-off-by: Junio C Hamano --- * And this is the second one. Totally untested, though. git-send-email.perl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/git-send-email.perl b/git-send-email.perl index ca7faff094..7458a0d1ef 100755 --- a/git-send-email.perl +++ b/git-send-email.perl @@ -231,7 +231,7 @@ sub do_edit { my (@suppress_cc); my ($auto_8bit_encoding); my ($compose_encoding); -my $target_xfer_encoding = 'auto'; +my ($target_xfer_encoding); my ($debug_net_smtp) = 0; # Net::SMTP, see send_message() @@ -271,7 +271,7 @@ sub do_edit { "from" => [\$sender], "assume8bitencoding" => [\$auto_8bit_encoding], "composeencoding" => [\$compose_encoding], - "transferencoding" => [\$target_xfer_encoding], + "transferencoding" => [\$target_xfer_encoding, 'auto'], ); my %config_path_settings = (