From patchwork Fri May 17 19:55:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 10948557 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 1731F14DB for ; Fri, 17 May 2019 19:56:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 081D2283AF for ; Fri, 17 May 2019 19:56:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F00E7283B2; Fri, 17 May 2019 19:56:19 +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,FREEMAIL_FROM,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 1E06F283AF for ; Fri, 17 May 2019 19:56:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728164AbfEQT4S (ORCPT ); Fri, 17 May 2019 15:56:18 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:39032 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726812AbfEQT4R (ORCPT ); Fri, 17 May 2019 15:56:17 -0400 Received: by mail-wr1-f68.google.com with SMTP id w8so8324015wrl.6 for ; Fri, 17 May 2019 12:56:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=IdOJRNUeTfSUL1GotIAxz5SgA2St4jwxPNLzKx1ZKpc=; b=EYpj4m5Ca2pdtcEGe0p7fSnW76WPmhmX+CJp8xuzQGgIbX4yseZ8LTCLh6zGJ5Bl8m aZ3LGcWfmBD9nBjtsmmC1++P94mQsPY80sjuTJbHRjpGvaqkvGnntcbq95v5ELD2L536 8NR+WwO6nJHoB0kNgwGgLaoj8dpJ4eY2cLnsRCEz7gMQS9OH93e+I/C9q0kLe1JDLlZJ v9jiCAFp0YrhfOWxhiP3ifYNcryxi9w8A+n3V5DhlSjpqVG+ghrCsO6f5wKh2ne173zz cEa8N87jr+3NX1bIuaQx8UlNLA3fVOV+ArBagUedm+lOKC+ikcRqumJr187oR8byrkjk lByg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=IdOJRNUeTfSUL1GotIAxz5SgA2St4jwxPNLzKx1ZKpc=; b=jzVJujOQqIh7lD2sNQplDDCVOp7ETh7g6Bxa6DmJffl9+4NqKJ+gi1vpnDRaG+DNbl TYWxXuqqduoHaHO6jDGpUcIhawusbloOIiWGGRl/hlSGT5I+kvtVwSwTikX3wmDlpZtP 2WLJbWDVl9HajgnhKJFapmV3fDYd//IZi+Cvb4xigD8HlBDjh8wHHualt0N00SFoVACZ Ec9/giJ0oJyZCWW+weFhT5A7qbSOq4qi5eBkfv7u0B1YEzxlMwlZLK1G6naExwchf4GT fO3o9zRgmqsP+VTBtmCo9EBm7S9Xs7bGRW/rSwnEz9lg7AzOR3LdzDs6astZl9BtWQwx eNpw== X-Gm-Message-State: APjAAAXwY9P58FoqB1UqiwEsoBn6P80sRQRDzq2zOxkAxxe3mESG+RvZ K+Is9rBeYgUevSbOiWEmco7FhXjgdGg= X-Google-Smtp-Source: APXvYqy5SvRbCzDLjjmdtbu749s6In5wMM1QNaqnoh7/x0OhQ/7TT9tqrngLNrm+hvo1MbwtwEpraw== X-Received: by 2002:adf:fc44:: with SMTP id e4mr3580824wrs.243.1558122975722; Fri, 17 May 2019 12:56:15 -0700 (PDT) Received: from vm.nix.is ([2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id r2sm18691149wrr.65.2019.05.17.12.56.14 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 17 May 2019 12:56:15 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Stephen Boyd , jrnieder@gmail.com, sandals@crustytoothpaste.net, sunshine@sunshineco.com, xypron.glpk@gmx.de, Paolo Bonzini , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFy?= =?utf-8?b?bWFzb24=?= Subject: [PATCH 1/5] send-email: remove cargo-culted multi-patch pattern in tests Date: Fri, 17 May 2019 21:55:41 +0200 Message-Id: <20190517195545.29729-2-avarab@gmail.com> X-Mailer: git-send-email 2.22.0.rc0.259.g3cce4bfedb In-Reply-To: References: 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 Change test code added in f434c083a0 ("send-email: add --no-cc, --no-to, and --no-bcc", 2010-03-07) which blindly copied a pattern from an earlier test added in 32ae83194b ("add a test for git-send-email for non-threaded mails", 2009-06-12) where the "$patches" variable was supplied more than once. As it turns out we didn't need more than one "$patches" for the test added in 32ae83194b either. The only tests that actually needed this sort of invocation were the tests added in 54aae5e1a0 ("t9001: send-email interation with --in-reply-to and --chain-reply-to", 2010-10-19). Signed-off-by: Ævar Arnfjörð Bjarmason --- t/t9001-send-email.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index 1b18201ce2..13de44686b 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -1204,7 +1204,7 @@ test_expect_success $PREREQ 'no in-reply-to and no threading' ' --from="Example " \ --to=nobody@example.com \ --no-thread \ - $patches $patches >stdout && + $patches >stdout && ! grep "In-Reply-To: " stdout ' @@ -1224,7 +1224,7 @@ test_expect_success $PREREQ 'sendemail.to works' ' git send-email \ --dry-run \ --from="Example " \ - $patches $patches >stdout && + $patches >stdout && grep "To: Somebody " stdout ' @@ -1234,7 +1234,7 @@ test_expect_success $PREREQ '--no-to overrides sendemail.to' ' --from="Example " \ --no-to \ --to=nobody@example.com \ - $patches $patches >stdout && + $patches >stdout && grep "To: nobody@example.com" stdout && ! grep "To: Somebody " stdout ' @@ -1245,7 +1245,7 @@ test_expect_success $PREREQ 'sendemail.cc works' ' --dry-run \ --from="Example " \ --to=nobody@example.com \ - $patches $patches >stdout && + $patches >stdout && grep "Cc: Somebody " stdout ' @@ -1256,7 +1256,7 @@ test_expect_success $PREREQ '--no-cc overrides sendemail.cc' ' --no-cc \ --cc=bodies@example.com \ --to=nobody@example.com \ - $patches $patches >stdout && + $patches >stdout && grep "Cc: bodies@example.com" stdout && ! grep "Cc: Somebody " stdout ' @@ -1268,7 +1268,7 @@ test_expect_success $PREREQ 'sendemail.bcc works' ' --from="Example " \ --to=nobody@example.com \ --smtp-server relay.example.com \ - $patches $patches >stdout && + $patches >stdout && grep "RCPT TO:" stdout ' @@ -1280,7 +1280,7 @@ test_expect_success $PREREQ '--no-bcc overrides sendemail.bcc' ' --bcc=bodies@example.com \ --to=nobody@example.com \ --smtp-server relay.example.com \ - $patches $patches >stdout && + $patches >stdout && grep "RCPT TO:" stdout && ! grep "RCPT TO:" stdout ' From patchwork Fri May 17 19:55:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 10948561 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 4D6B714DB for ; Fri, 17 May 2019 19:56:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3EAE0283AF for ; Fri, 17 May 2019 19:56:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 32935283E7; Fri, 17 May 2019 19:56:23 +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,FREEMAIL_FROM,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 063E4283AF for ; Fri, 17 May 2019 19:56:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728525AbfEQT4V (ORCPT ); Fri, 17 May 2019 15:56:21 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:46606 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726812AbfEQT4U (ORCPT ); Fri, 17 May 2019 15:56:20 -0400 Received: by mail-wr1-f67.google.com with SMTP id r7so8270240wrr.13 for ; Fri, 17 May 2019 12:56:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=30YV0O5IEl6ChPhFaeRzXz6N8Cu7ncdCTl2LiDP7Qa8=; b=hmDDKm67KJiyYAgBq/fcVTDb0fSLn4Uvm5As6ItOKoUcp9Xr7tjEN/dJ3TqKh09w0Z zy3YXH/3T3pnhTkJpTSWqlKeTcFT0rFGezF95tmmUWVmit9qKDDJHkoZQYt9lxdeOu7B t94gUwWUmDK3bcBpKLp3jdQVnwazeRnqzbJsr2az+JziwNfm3EEJaLSYdqucb1KBlexM mPpkXj3BcxmwzKi64Ds0LnagIlP2yshUNA+RY/e9JlQccNpivc/K7S/YZh1Ri2/nLOJz xkJs0yVFiGThkVPWOfkD30QlcPyVXuUhdSuRL7mX24oIvmn4hK8eXUn9P8yTxxnkDkbj iHbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=30YV0O5IEl6ChPhFaeRzXz6N8Cu7ncdCTl2LiDP7Qa8=; b=Mx4/JESFBjQJ5z2hs2diecPv7Z7yzwa9RRUrwUYYZWXipExh9kF/CQfKVTLFrKu5gM et43BxwAH4XDToub/vwvSFuf43mCo+CAcw7Uw8AaOCyedrfXaS6FfMih9B/bPDTS1hTB dnfkeid26uvbJgCSqFg5OkfdrNXm1ErA6lW2yrEod+sZK4kpM05md3+rcrnrqxA647dq wEnT0mvo3xPn7cUeKMYVhzL+9BBYyR1xfpXM92en1DaKmaFQZTC7dD2hJ71ZiYg9Byw6 y1hpzctt6/hg0lngx5QKViHvVOHUekUNbMSmYPuPYM7DR4VplANp8AHGpKG+fY7ThZB0 GhOw== X-Gm-Message-State: APjAAAUyXMxLhbskLo91rXYL6zjZN7/OPnBOKtP+VymW5/Vi4+U5berp dieimJ8B3Z9iHj+8PJEjSJH3zVl8VF4= X-Google-Smtp-Source: APXvYqzPQBzz5gdnAJ2hqw+r4YS1DkQBstL8W7XmiUlq/PiNt4bua/UOIWYvZvxsFvPmyYoZq9Cecg== X-Received: by 2002:adf:eb84:: with SMTP id t4mr6751413wrn.43.1558122977878; Fri, 17 May 2019 12:56:17 -0700 (PDT) Received: from vm.nix.is ([2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id r2sm18691149wrr.65.2019.05.17.12.56.16 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 17 May 2019 12:56:17 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Stephen Boyd , jrnieder@gmail.com, sandals@crustytoothpaste.net, sunshine@sunshineco.com, xypron.glpk@gmx.de, Paolo Bonzini , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFy?= =?utf-8?b?bWFzb24=?= Subject: [PATCH 2/5] send-email: fix broken transferEncoding tests Date: Fri, 17 May 2019 21:55:42 +0200 Message-Id: <20190517195545.29729-3-avarab@gmail.com> X-Mailer: git-send-email 2.22.0.rc0.259.g3cce4bfedb In-Reply-To: References: 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 I fixed a bug that had broken the reading of sendmail.transferEncoding in 3494dfd3ee ("send-email: do defaults -> config -> getopt in that order", 2019-05-09), but the test I added in that commit did nothing to assert the bug had been fixed. That issue originates in 8d81408435 ("git-send-email: add --transfer-encoding option", 2014-11-25) which first added the "sendemail.transferencoding=8bit". That test has never done anything meaningful. It tested that the "--transfer-encoding=8bit" option would turn on the 8bit Transfer-Encoding, but that was the default at the time (and now). As checking out 8d81408435 and editing the test to remove that option will reveal, supplying it never did anything. So when I copied it thinking it would work in 3494dfd3ee I copied a previously broken test, although I was making sure it did the right thing via da-hoc debugger inspection, so the bug was fixed. So fix the test I added in 3494dfd3ee, as well as the long-standing test added in 8d81408435. To test if we're actually setting the Transfer-Encoding let's set it to 7bit, not 8bit, as 7bit will error out on "email-using-8bit". This means that we can remove the "sendemail.transferencoding=7bit fails on 8bit data" test, since it was redundant, we now have other tests that assert that that'll fail. While I'm at it convert "git config " in the test setup to just "-c =" on the command-line. Then we don't need to cleanup after these tests, and there's no sense in asserting where config values come from in these tests, we can take that as a given. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/t9001-send-email.sh | 35 +++++++++++------------------------ 1 file changed, 11 insertions(+), 24 deletions(-) diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index 13de44686b..61d484d1a6 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -1437,10 +1437,10 @@ test_expect_success $PREREQ 'setup expect' ' EOF ' -test_expect_success $PREREQ 'sendemail.transferencoding=7bit fails on 8bit data' ' +test_expect_success $PREREQ '--transfer-encoding overrides sendemail.transferEncoding' ' clean_fake_sendmail && - git config sendemail.transferEncoding 7bit && - test_must_fail git send-email \ + test_must_fail git -c sendemail.transferEncoding=8bit \ + send-email \ --transfer-encoding=7bit \ --smtp-server="$(pwd)/fake.sendmail" \ email-using-8bit \ @@ -1449,11 +1449,10 @@ test_expect_success $PREREQ 'sendemail.transferencoding=7bit fails on 8bit data' test -z "$(ls msgtxt*)" ' -test_expect_success $PREREQ '--transfer-encoding overrides sendemail.transferEncoding' ' +test_expect_success $PREREQ 'sendemail.transferEncoding via config' ' clean_fake_sendmail && - git config sendemail.transferEncoding 8bit && - test_must_fail git send-email \ - --transfer-encoding=7bit \ + test_must_fail git -c sendemail.transferEncoding=7bit \ + send-email \ --smtp-server="$(pwd)/fake.sendmail" \ email-using-8bit \ 2>errors >out && @@ -1461,27 +1460,15 @@ test_expect_success $PREREQ '--transfer-encoding overrides sendemail.transferEnc test -z "$(ls msgtxt*)" ' -test_expect_success $PREREQ 'sendemail.transferencoding=8bit via config' ' +test_expect_success $PREREQ 'sendemail.transferEncoding via cli' ' clean_fake_sendmail && - git -c sendemail.transferencoding=8bit send-email \ - --smtp-server="$(pwd)/fake.sendmail" \ - email-using-8bit \ - 2>errors >out && - sed '1,/^$/d' msgtxt1 >actual && - sed '1,/^$/d' email-using-8bit >expected && - test_cmp expected actual -' - -test_expect_success $PREREQ 'sendemail.transferencoding=8bit via cli' ' - clean_fake_sendmail && - git send-email \ - --transfer-encoding=8bit \ + test_must_fail git send-email \ + --transfer-encoding=7bit \ --smtp-server="$(pwd)/fake.sendmail" \ email-using-8bit \ 2>errors >out && - sed '1,/^$/d' msgtxt1 >actual && - sed '1,/^$/d' email-using-8bit >expected && - test_cmp expected actual + grep "cannot send message as 7bit" errors && + test -z "$(ls msgtxt*)" ' test_expect_success $PREREQ 'setup expect' ' From patchwork Fri May 17 19:55:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 10948559 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 112A114C0 for ; Fri, 17 May 2019 19:56:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 01CAB283B2 for ; Fri, 17 May 2019 19:56:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E99562842B; Fri, 17 May 2019 19:56:22 +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,FREEMAIL_FROM,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 9DD1C283B2 for ; Fri, 17 May 2019 19:56:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728654AbfEQT4V (ORCPT ); Fri, 17 May 2019 15:56:21 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:33383 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728315AbfEQT4V (ORCPT ); Fri, 17 May 2019 15:56:21 -0400 Received: by mail-wr1-f68.google.com with SMTP id d9so8371977wrx.0 for ; Fri, 17 May 2019 12:56:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Ycv4qi31GgN6u311riizt4LH741B4kTHClZlB9wR2zY=; b=aqOKf3tj6Rk8WtLmuq1bo09hJeGKSE6af8WYbwP9E06dSbhKrZ4sYJxrsfhiGf9/ql ucRO1aIsnONdZGdHgWbRqlh0R+i59t/LlNMx9Vo0Fmy9tvh0Bmt6grEQxwh4z8D0FzAN Yr1DArThgEPr5pQjGBPNJ631eMCTrOuXhWhoKPvEi6TxOwBO693mHzvaa+mz8Tlaq0uR 1+HMnz1a6b0V0PYwAdx7eGP01ko1zJfFVF/8QOf35D4s7/vNIGlSoVBsIcJP2w+MLBqY QfwnoNe+LUDEbgfpYWN0YvPPZLqrcvVVYkWnPydgYb//2oc4Fwl+3lzsIpqTchQCXSiG YQXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Ycv4qi31GgN6u311riizt4LH741B4kTHClZlB9wR2zY=; b=jRo62ilk3C9Y5Dfy8U6IeqRoesm/B5WC0GqHYdK6qcHpfObv7XJaLJr/C2oMiVanCr nAqrnX8mkDolDhLwzioTnxoWEGNIixzp3I8madlIOZNYOFX76anfrovbAZmn888IsowY Kub7ds2fbrz8cV86zUWk2+zQuk0lR5k4KuSSMAVVfp16XBR0GKRFcgd3B9vdCPnB0Rdb 7mUfoReaasxXbMgwUPYtv059AMwhZz7d8kUODJtKQUwL84+5iXw8TO2oknpeWKvAo2P9 MJbZqXmIpGGM7hHPaPPM/Utg8Bdo2oVEowMrE/bpsq4vRL1HqI30PJKX34+u87VkKvSV svng== X-Gm-Message-State: APjAAAWCfjVb0PrEPX76Zrn7xLewhRhElBxYRbjR3HSx+yF4nQL/QHBu GYG3QSGQMcBDo6sHWMfj4sbOW6z8rFw= X-Google-Smtp-Source: APXvYqy14ntv898zbWwtYV7zQDKQ3LVqdUqmS+CqLcg4EngwOKHbi+9N+6cY8P5/X4HV0VjfkWSP0Q== X-Received: by 2002:adf:ec8c:: with SMTP id z12mr25588045wrn.209.1558122979445; Fri, 17 May 2019 12:56:19 -0700 (PDT) Received: from vm.nix.is ([2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id r2sm18691149wrr.65.2019.05.17.12.56.18 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 17 May 2019 12:56:18 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Stephen Boyd , jrnieder@gmail.com, sandals@crustytoothpaste.net, sunshine@sunshineco.com, xypron.glpk@gmx.de, Paolo Bonzini , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFy?= =?utf-8?b?bWFzb24=?= Subject: [PATCH 3/5] send-email: document --no-[to|cc|bcc] Date: Fri, 17 May 2019 21:55:43 +0200 Message-Id: <20190517195545.29729-4-avarab@gmail.com> X-Mailer: git-send-email 2.22.0.rc0.259.g3cce4bfedb In-Reply-To: References: 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 These options added in f434c083a0 ("send-email: add --no-cc, --no-to, and --no-bcc", 2010-03-07) were never documented. Signed-off-by: Ævar Arnfjörð Bjarmason --- Documentation/git-send-email.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt index 1afe9fc858..8100ff4b0f 100644 --- a/Documentation/git-send-email.txt +++ b/Documentation/git-send-email.txt @@ -278,6 +278,10 @@ must be used for each option. Automating ~~~~~~~~~~ +--no-[to|cc|bcc]:: + Clears any list of "To:", "Cc:", "Bcc:" addresses previously + set via config. + --to-cmd=:: Specify a command to execute once per patch file which should generate patch file specific "To:" entries. From patchwork Fri May 17 19:55:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 10948563 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 1BFDD1390 for ; Fri, 17 May 2019 19:56:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0A2A5283AF for ; Fri, 17 May 2019 19:56:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F0A11283E7; Fri, 17 May 2019 19:56:26 +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,FREEMAIL_FROM,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 B5438283AF for ; Fri, 17 May 2019 19:56:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728806AbfEQT4Y (ORCPT ); Fri, 17 May 2019 15:56:24 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:40062 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728717AbfEQT4Y (ORCPT ); Fri, 17 May 2019 15:56:24 -0400 Received: by mail-wr1-f67.google.com with SMTP id h4so8327848wre.7 for ; Fri, 17 May 2019 12:56:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=EKnmnwVOsIPI3esewNUdkHS2uubzviCxXP8JUiWSjlU=; b=LbZBsjpkZIaEGLN/Hr4iKfVjx4DLvMJCqtVU1929rTrJK/2yLGHqykp9OCYN5EFM7k 69eVNwm6snT2T6sokqmqyZGXt7QqBM+13mnjX9Pv0ljsebyivwq5RcbqxNv6YT3JZtVO XgAg5NfP/HkGAc2s9v2WyyQJD1R32H2GrfymRuhqbqO+yG8/vB+x7D0JWdjX0TrSzIxS Q1UI2CgB6S5MQJmfoxgRBycJlVzwXJlseP16/wNa0OV22uA0VKz8fEkG2hKxGwfJwsn5 HMC1MY97W93nAhexofjkbVRkTVRVNxUXM8jUfzcz0Jg8L7XF9bPrg83Z/7XyFbkGDz6R b5Iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=EKnmnwVOsIPI3esewNUdkHS2uubzviCxXP8JUiWSjlU=; b=oSEfxVWqqaqPBFz+Js6PAxLy3XU6l2/ao/+kPxIpedZdytzO14tseXbxw5KVJIpobD hpi3vJ0v/RpH0INpw4NwLQrMEyMFXTcLkp6boO5H01Twy74xtoIQLO9P9wIGLB26z9AP mFplInhwrC/qJQM7kU6qqEzsTS/TpY/M8DTRpNLTmVv/1mfgYLdmkB99x72A5mDonwHJ rZkmsv3mJ/s1juOWyEX8QW6oUhJ4b+rGTxc+/RNPOEWU8ZKsK1vwtemRQbb9oAPGuJCf p/lVSaTEV6Qc3I6s8AJRd5opVwE/x/O2UXovAxz6iCpmGbvXjW2wLROX6pdpBvEXLkXR FDJQ== X-Gm-Message-State: APjAAAXX0BxjyjNCjhKOu0j0NEScR4dnX7ccpsjGeFEOKIKrh+qgb/Ov 1vrms9un0LrMOvzHCs4fEZ0xg+gjKgQ= X-Google-Smtp-Source: APXvYqw1tw17Ga6KbHyx7PaXhs5MZRMM/noh10uDWwhVkuRsuBaEi0OBHfuMHoBPst5J0C7+4JMn6g== X-Received: by 2002:adf:c188:: with SMTP id x8mr25586930wre.256.1558122980806; Fri, 17 May 2019 12:56:20 -0700 (PDT) Received: from vm.nix.is ([2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id r2sm18691149wrr.65.2019.05.17.12.56.19 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 17 May 2019 12:56:20 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Stephen Boyd , jrnieder@gmail.com, sandals@crustytoothpaste.net, sunshine@sunshineco.com, xypron.glpk@gmx.de, Paolo Bonzini , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFy?= =?utf-8?b?bWFzb24=?= Subject: [PATCH 4/5] send-email: fix regression in sendemail.identity parsing Date: Fri, 17 May 2019 21:55:44 +0200 Message-Id: <20190517195545.29729-5-avarab@gmail.com> X-Mailer: git-send-email 2.22.0.rc0.259.g3cce4bfedb In-Reply-To: References: 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 regression in my recent 3494dfd3ee ("send-email: do defaults -> config -> getopt in that order", 2019-05-09). I missed that the $identity variable needs to be extracted from the command-line before we do the config reading, as it determines which config variable we should read first. See [1] for the report. The sendemail.identity feature was added back in 34cc60ce2b ("send-email: Add support for SSL and SMTP-AUTH", 2007-09-03), there were no tests to assert that it worked properly. So let's fix both the regression, and add some tests to assert that this is being parsed properly. While I'm at it I'm adding a --no-identity option to go with --[to|cc|bcc] variable, since the semantics are similar. It's like to/cc/bcc except that unlike those we don't support multiple identities, but we could now easily add it support for it if anyone cares. In just fixing the --identity command-line parsing bug I discovered that a narrow fix to that wouldn't do. In read_config() we had a state machine that would only set config values if they weren't set already, and thus by proxy we wouldn't e.g. set "to" based on sendemail.to if we'd seen sendemail.gmail.to before, with --identity=gmail. I'd modified some of the relevant code in 3494dfd3ee, but just reverting to that wouldn't do, since it would bring back the regression fixed in that commit. Refactor read_config() do what we actually mean here. We don't want to set a given sendemail.VAR if a sendemail.$identity.VAR previously set it. The old code was conflating this desire with the hardcoded defaults for these variables, and as discussed in 3494dfd3ee that was never going to work. Instead pass along the state of whether an identity config set something before, as distinguished from the state of the default just being false, or the default being a non-bool or true (e.g. --transferencoding). I'm still not happy with the test coverage here, e.g. there's nothing testing sendemail.smtpEncryption, but I only have so much time to fix this code. 1. https://public-inbox.org/git/5cddeb61.1c69fb81.47ed4.e648@mx.google.com/ Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Johannes Schindelin --- Documentation/git-send-email.txt | 4 ++ git-send-email.perl | 60 ++++++++++++++++++++---------- t/t9001-send-email.sh | 64 ++++++++++++++++++++++++++++++++ 3 files changed, 108 insertions(+), 20 deletions(-) diff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt index 8100ff4b0f..a861934c69 100644 --- a/Documentation/git-send-email.txt +++ b/Documentation/git-send-email.txt @@ -282,6 +282,10 @@ Automating Clears any list of "To:", "Cc:", "Bcc:" addresses previously set via config. +--no-identity:: + Clears the previously read value of `sendemail.identity` set + via config, if any. + --to-cmd=:: Specify a command to execute once per patch file which should generate patch file specific "To:" entries. diff --git a/git-send-email.perl b/git-send-email.perl index b2c4a77671..80cbbfd2b8 100755 --- a/git-send-email.perl +++ b/git-send-email.perl @@ -182,7 +182,7 @@ sub format_2822_time { $author,$sender,$smtp_authpass,$annotate,$compose,$time); # Things we either get from config, *or* are overridden on the # command-line. -my ($no_cc, $no_to, $no_bcc); +my ($no_cc, $no_to, $no_bcc, $no_identity); my (@config_to, @getopt_to); my (@config_cc, @getopt_cc); my (@config_bcc, @getopt_bcc); @@ -325,44 +325,53 @@ sub signal_handler { # Read our sendemail.* config sub read_config { - my ($prefix) = @_; + my ($configured, $prefix) = @_; foreach my $setting (keys %config_bool_settings) { my $target = $config_bool_settings{$setting}; my $v = Git::config_bool(@repo, "$prefix.$setting"); - $$target = $v if defined $v; + next unless defined $v; + next if $configured->{$setting}++; + $$target = $v; } foreach my $setting (keys %config_path_settings) { my $target = $config_path_settings{$setting}; if (ref($target) eq "ARRAY") { - unless (@$target) { - my @values = Git::config_path(@repo, "$prefix.$setting"); - @$target = @values if (@values && defined $values[0]); - } + my @values = Git::config_path(@repo, "$prefix.$setting"); + next unless @values; + next if $configured->{$setting}++; + @$target = @values; } else { my $v = Git::config_path(@repo, "$prefix.$setting"); - $$target = $v if defined $v; + next unless defined $v; + next if $configured->{$setting}++; + $$target = $v; } } foreach my $setting (keys %config_settings) { my $target = $config_settings{$setting}; if (ref($target) eq "ARRAY") { - unless (@$target) { - my @values = Git::config(@repo, "$prefix.$setting"); - @$target = @values if (@values && defined $values[0]); - } + my @values = Git::config(@repo, "$prefix.$setting"); + next unless @values; + next if $configured->{$setting}++; + @$target = @values; } else { my $v = Git::config(@repo, "$prefix.$setting"); - $$target = $v if defined $v; + next unless defined $v; + next if $configured->{$setting}++; + $$target = $v; } } if (!defined $smtp_encryption) { - my $enc = Git::config(@repo, "$prefix.smtpencryption"); + my $setting = "$prefix.smtpencryption"; + my $enc = Git::config(@repo, $setting); + return unless defined $enc; + return if $configured->{$setting}++; if (defined $enc) { $smtp_encryption = $enc; } elsif (Git::config_bool(@repo, "$prefix.smtpssl")) { @@ -371,17 +380,30 @@ sub read_config { } } +# sendemail.identity yields to --identity. We must parse this +# special-case first before the rest of the config is read. $identity = Git::config(@repo, "sendemail.identity"); -read_config("sendemail.$identity") if defined $identity; -read_config("sendemail"); +my $rc = GetOptions( + "identity=s" => \$identity, + "no-identity" => \$no_identity, +); +usage() unless $rc; +undef $identity if $no_identity; + +# Now we know enough to read the config +{ + my %configured; + read_config(\%configured, "sendemail.$identity") if defined $identity; + read_config(\%configured, "sendemail"); +} # Begin by accumulating all the variables (defined above), that we will end up # needing, first, from the command line: my $help; my $git_completion_helper; -my $rc = GetOptions("h" => \$help, - "dump-aliases" => \$dump_aliases); +$rc = GetOptions("h" => \$help, + "dump-aliases" => \$dump_aliases); usage() unless $rc; die __("--dump-aliases incompatible with other options\n") if !$help and $dump_aliases and @ARGV; @@ -410,8 +432,6 @@ sub read_config { "smtp-debug:i" => \$debug_net_smtp, "smtp-domain:s" => \$smtp_domain, "smtp-auth=s" => \$smtp_auth, - "no-smtp-auth" => sub {$smtp_auth = 'none'}, - "identity=s" => \$identity, "annotate!" => \$annotate, "no-annotate" => sub {$annotate = 0}, "compose" => \$compose, diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index 61d484d1a6..890e2874c3 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -1228,6 +1228,61 @@ test_expect_success $PREREQ 'sendemail.to works' ' grep "To: Somebody " stdout ' +test_expect_success $PREREQ 'setup sendemail.identity' ' + git config --replace-all sendemail.to "default@example.com" && + git config --replace-all sendemail.isp.to "isp@example.com" && + git config --replace-all sendemail.cloud.to "cloud@example.com" +' + +test_expect_success $PREREQ 'sendemail.identity: reads the correct identity config' ' + git -c sendemail.identity=cloud send-email \ + --dry-run \ + --from="nobody@example.com" \ + $patches >stdout && + grep "To: cloud@example.com" stdout +' + +test_expect_success $PREREQ 'sendemail.identity: identity overrides sendemail.identity' ' + git -c sendemail.identity=cloud send-email \ + --identity=isp \ + --dry-run \ + --from="nobody@example.com" \ + $patches >stdout && + grep "To: isp@example.com" stdout +' + +test_expect_success $PREREQ 'sendemail.identity: --no-identity clears previous identity' ' + git -c sendemail.identity=cloud send-email \ + --no-identity \ + --dry-run \ + --from="nobody@example.com" \ + $patches >stdout && + grep "To: default@example.com" stdout +' + +test_expect_success $PREREQ 'sendemail.identity: bool identity variable existance overrides' ' + git -c sendemail.identity=cloud \ + -c sendemail.xmailer=true \ + -c sendemail.cloud.xmailer=false \ + send-email \ + --dry-run \ + --from="nobody@example.com" \ + $patches >stdout && + grep "To: cloud@example.com" stdout && + ! grep "X-Mailer" stdout +' + +test_expect_success $PREREQ 'sendemail.identity: bool variable fallback' ' + git -c sendemail.identity=cloud \ + -c sendemail.xmailer=false \ + send-email \ + --dry-run \ + --from="nobody@example.com" \ + $patches >stdout && + grep "To: cloud@example.com" stdout && + ! grep "X-Mailer" stdout +' + test_expect_success $PREREQ '--no-to overrides sendemail.to' ' git send-email \ --dry-run \ @@ -1785,6 +1840,15 @@ test_expect_success '--dump-aliases must be used alone' ' test_must_fail git send-email --dump-aliases --to=janice@example.com -1 refs/heads/accounting ' +test_expect_success 'aliases and sendemail.identity' ' + test_must_fail git \ + -c sendemail.identity=cloud \ + -c sendemail.aliasesfile=default-aliases \ + -c sendemail.cloud.aliasesfile=cloud-aliases \ + send-email -1 2>stderr && + test_i18ngrep "cloud-aliases" stderr +' + test_sendmail_aliases () { msg="$1" && shift && expect="$@" && From patchwork Fri May 17 19:55:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 10948565 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 733CD14DB for ; Fri, 17 May 2019 19:56:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 63972283AF for ; Fri, 17 May 2019 19:56:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 57562283B2; Fri, 17 May 2019 19:56:27 +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,FREEMAIL_FROM,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 B15D7283B0 for ; Fri, 17 May 2019 19:56:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729058AbfEQT4Z (ORCPT ); Fri, 17 May 2019 15:56:25 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:45929 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728297AbfEQT4Z (ORCPT ); Fri, 17 May 2019 15:56:25 -0400 Received: by mail-wr1-f65.google.com with SMTP id b18so8275983wrq.12 for ; Fri, 17 May 2019 12:56:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=N1cXo9OerMOr2PDE69u/yN4T0DTo3NxEn/wP4arpNzE=; b=grJuKcqDz7w/2okjwFrlkZMzrt3TtuDjts2HmjFxjp6g4i6hXqKDS2ZtyKxNonJsUd rTb6jFkJK/ovDv+iPYRgMYL6TT9lo+tT9EvqVmgJzW0ws4S5snja1n68ttV5dGHA89My 6e+4IikNPsAIjL7xC06dIBSpKpXIOTEGoWlb6909gXZXGzqQpGFcrEfAX3zKgrWQ1hta 7aEOe26CyMjr9ribOdcgkaB2VBn5hzQWchy9s2M23UcUMbFrdNOeOP/jz3wqGLAei0TR FlrtWnyWn8Z17u56UiCYN7B99Ht5kVHb3RaEkTe2xENlD2rbEs1UcIS9katz8iQM3Q2E 1eZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=N1cXo9OerMOr2PDE69u/yN4T0DTo3NxEn/wP4arpNzE=; b=EU6Ksnjdz07X2HZ5aMB4pREj4IOe55qgViWWJ1yQYEjV2Ww3dWlNxkLPq3oFRlymRl BH864Lx8b3PIfkivUGE1Er962mFQcs4tyueeSq9goqZTJxD6C/srxaaZfod1YmImwZ1y b/H1dlzqzHBMIn/2VnF05TlQwc8CnoS+Gkm4cDLBdzbd74UmPVea8qZub9lOuzR4+EZR ZBrK6pxD+stSM3UL8TVsSTfeuboNtrQ4XYkocraja/Dx2SDiYqIV8J8bCe8DkPO9+Hjl VHe1HIsgcCutbClpktvqJxwyGRgUdnei92YWJJH1wfz+000i0a+eeEoO20bYGKEk7tMz 1PQQ== X-Gm-Message-State: APjAAAVwZP1cCeTnly9rIDsWZvimyRM02pilL9A3BeeLGRmmh+9eNWbQ HmqRjMEK1eHGULLSrRhKIe3aFuCOiFg= X-Google-Smtp-Source: APXvYqwSk61qzaS+TGlJllmrOfrRSjErLCwJYh8DBldqmCAxxA59X4iUQ9Grpcg+6UithX55LDv4Xw== X-Received: by 2002:adf:f407:: with SMTP id g7mr19720356wro.196.1558122982426; Fri, 17 May 2019 12:56:22 -0700 (PDT) Received: from vm.nix.is ([2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id r2sm18691149wrr.65.2019.05.17.12.56.21 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 17 May 2019 12:56:21 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Stephen Boyd , jrnieder@gmail.com, sandals@crustytoothpaste.net, sunshine@sunshineco.com, xypron.glpk@gmx.de, Paolo Bonzini , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFy?= =?utf-8?b?bWFzb24=?= Subject: [PATCH 5/5] send-email: remove support for deprecated sendemail.smtpssl Date: Fri, 17 May 2019 21:55:45 +0200 Message-Id: <20190517195545.29729-6-avarab@gmail.com> X-Mailer: git-send-email 2.22.0.rc0.259.g3cce4bfedb In-Reply-To: References: 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 Remove the sendemail.smtpssl configuration variable and its associated --smtp-ssl command-line option. This has been documented as deprecated since f6bebd121a ("git-send-email: add support for TLS via Net::SMTP::SSL", 2008-06-25) and 65180c6618 ("List send-email config options in config.txt.", 2009-07-22), respectively. Waiting for 10 years should be enough. This allows us to fix a special case in read_config(). We couldn't just parse sendemail.smtpEncryption like everything else because we'd need to fall back on sendemail.smtpssl. Now that we don't need to do that we don't need this special case anymore. Let's still find out if someone's using this and die() with a helpful message if that's the case. Because of my recent improvements to the command-line and config parsing we can also revert fa835cd572 ("git-send-email: prevent undefined variable warnings if no encryption is set", 2008-06-26), since we now sensibly support setting defaults for these mixed config & command-line options. Signed-off-by: Ævar Arnfjörð Bjarmason --- Documentation/config/sendemail.txt | 3 --- Documentation/git-send-email.txt | 3 --- git-send-email.perl | 26 +++++++++----------------- t/t9001-send-email.sh | 9 +++++++++ 4 files changed, 18 insertions(+), 23 deletions(-) diff --git a/Documentation/config/sendemail.txt b/Documentation/config/sendemail.txt index 0006faf800..d7855bff1f 100644 --- a/Documentation/config/sendemail.txt +++ b/Documentation/config/sendemail.txt @@ -8,9 +8,6 @@ sendemail.smtpEncryption:: See linkgit:git-send-email[1] for description. Note that this setting is not subject to the 'identity' mechanism. -sendemail.smtpssl (deprecated):: - Deprecated alias for 'sendemail.smtpEncryption = ssl'. - sendemail.smtpsslcertpath:: Path to ca-certificates (either a directory or a single file). Set it to an empty string to disable certificate verification. diff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt index a861934c69..6cf5c32ce8 100644 --- a/Documentation/git-send-email.txt +++ b/Documentation/git-send-email.txt @@ -236,9 +236,6 @@ The --smtp-server-option option must be repeated for each option you want to pass to the server. Likewise, different lines in the configuration files must be used for each option. ---smtp-ssl:: - Legacy alias for '--smtp-encryption ssl'. - --smtp-ssl-cert-path:: Path to a store of trusted CA certificates for SMTP SSL/TLS certificate validation (either a directory that has been processed diff --git a/git-send-email.perl b/git-send-email.perl index 80cbbfd2b8..b1ed45b907 100755 --- a/git-send-email.perl +++ b/git-send-email.perl @@ -77,7 +77,6 @@ sub usage { --smtp-user * Username for SMTP-AUTH. --smtp-pass * Password for SMTP-AUTH; not necessary. --smtp-encryption * tls or ssl; anything else disables. - --smtp-ssl * Deprecated. Use '--smtp-encryption ssl'. --smtp-ssl-cert-path * Path to ca-certificates (either directory or file). Pass an empty string to disable certificate verification. @@ -236,7 +235,7 @@ sub do_edit { my ($cover_cc, $cover_to); my ($to_cmd, $cc_cmd); my ($smtp_server, $smtp_server_port, @smtp_server_options); -my ($smtp_authuser, $smtp_encryption, $smtp_ssl_cert_path); +my ($smtp_authuser, $smtp_ssl_cert_path); my ($batch_size, $relogin_delay); my ($identity, $aliasfiletype, @alias_files, $smtp_domain, $smtp_auth); my ($confirm); @@ -250,6 +249,9 @@ sub do_edit { my $use_xmailer = 1; my $validate = 1; my $target_xfer_encoding = 'auto'; +my $smtp_encryption = ''; +# Deprecated variables +my $deprecated_smtp_ssl; my %config_bool_settings = ( "thread" => \$thread, @@ -266,10 +268,12 @@ sub do_edit { ); my %config_settings = ( + "smtpencryption" => \$smtp_encryption, "smtpserver" => \$smtp_server, "smtpserverport" => \$smtp_server_port, "smtpserveroption" => \@smtp_server_options, "smtpuser" => \$smtp_authuser, + "smtpssl" => \$deprecated_smtp_ssl, "smtppass" => \$smtp_authpass, "smtpdomain" => \$smtp_domain, "smtpauth" => \$smtp_auth, @@ -366,18 +370,6 @@ sub read_config { $$target = $v; } } - - if (!defined $smtp_encryption) { - my $setting = "$prefix.smtpencryption"; - my $enc = Git::config(@repo, $setting); - return unless defined $enc; - return if $configured->{$setting}++; - if (defined $enc) { - $smtp_encryption = $enc; - } elsif (Git::config_bool(@repo, "$prefix.smtpssl")) { - $smtp_encryption = 'ssl'; - } - } } # sendemail.identity yields to --identity. We must parse this @@ -426,7 +418,7 @@ sub read_config { "smtp-server-port=s" => \$smtp_server_port, "smtp-user=s" => \$smtp_authuser, "smtp-pass:s" => \$smtp_authpass, - "smtp-ssl" => sub { $smtp_encryption = 'ssl' }, + "smtp-ssl" => sub { $deprecated_smtp_ssl = 1 }, "smtp-encryption=s" => \$smtp_encryption, "smtp-ssl-cert-path=s" => \$smtp_ssl_cert_path, "smtp-debug:i" => \$debug_net_smtp, @@ -484,8 +476,8 @@ sub read_config { "(via command-line or configuration option)\n") if defined $relogin_delay and not defined $batch_size; -# 'default' encryption is none -- this only prevents a warning -$smtp_encryption = '' unless (defined $smtp_encryption); +die __("Use of deprecated option --smtp-ssl (or smtp.smtpssl config), use --smtp-encryption=ssl (or sendemail.smtpEncryption=ssl) instead\n") + if $deprecated_smtp_ssl; # Set CC suppressions my(%suppress_cc); diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index 890e2874c3..b5ccfa8737 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -1849,6 +1849,15 @@ test_expect_success 'aliases and sendemail.identity' ' test_i18ngrep "cloud-aliases" stderr ' +test_expect_success 'deprecated --smtp-ssl (or sendemail.smtpssl=true)' ' + test_must_fail git -c sendemail.smtpssl=true send-email -1 2>stderr && + test_i18ngrep "deprecated option.*or.*config" stderr && + test_must_fail git send-email --smtp-ssl -1 && + test_i18ngrep "deprecated option.*or.*config" stderr && + test_must_fail git -c sendemail.identity=test -c sendemail.test.smtpssl=true send-email -1 && + test_i18ngrep "deprecated option.*or.*config" stderr +' + test_sendmail_aliases () { msg="$1" && shift && expect="$@" &&