From patchwork Sat Jan 19 23:23:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Brandon Richardson X-Patchwork-Id: 10772225 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 B269013B4 for ; Sat, 19 Jan 2019 23:24:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 92F142B486 for ; Sat, 19 Jan 2019 23:24:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6D90C2B489; Sat, 19 Jan 2019 23:24: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 0896C2B486 for ; Sat, 19 Jan 2019 23:24:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729778AbfASXYQ (ORCPT ); Sat, 19 Jan 2019 18:24:16 -0500 Received: from mail-oi1-f196.google.com ([209.85.167.196]:44364 "EHLO mail-oi1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729766AbfASXYQ (ORCPT ); Sat, 19 Jan 2019 18:24:16 -0500 Received: by mail-oi1-f196.google.com with SMTP id m6so11837062oig.11 for ; Sat, 19 Jan 2019 15:24:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=NVpLm8zt4mqkBiwvwti1T/4jQszzhNoXc+dS8HWMqVk=; b=Ynp5PWDJ02tKvK1ybG+p4e+5z4CXdiXbdll7bgqpA6Dp5BzwZRNb1FEp3zdwjWfH4l u8w0JZ6qCNzcZYVd2dMGJBxxJmrBVsOchAHVN62c5Uu/06xTRbseqSLw9qlu6Ex/M2Mo z1mIzbXDsZXwOAgxl7Nq4AYNKAOY3O+NgePgzYEoIkR0wEkJKYexhT+FATa9RkvJV7xI 1/xuN/AS7dcfbDLG2DSr97UNHfwOP/zx8iEa7W/j1xYs16A5TKxbrjJK1xErDOXWFs5j WWe5gPg3WJ7tk3wV1/WIDFqJTP76IUYJ+gKZtfgD+TW/SglPK33jYAfFEA0Cob7rWnCi rbOg== 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:mime-version :content-transfer-encoding; bh=NVpLm8zt4mqkBiwvwti1T/4jQszzhNoXc+dS8HWMqVk=; b=aw6GSzJHG0ie0OGr7dePfJMiFP1LbtuyYf9CP3cXjXHbfhbX+HiMfOHR6yEyoxxPQM p0IRf5DX1oVSZ3KKk8myDfRBdW3usqfzyRMoYOX+i+9OglriK+YtDQi9dPtl1bNkw34w FwMl7IojlA4WunrnjsRO+xprND1AAKBAQ5mGTEQUu2uTi//LteNTuraUFrSQGzTQy7PK SV8cS1awiFSKchRwpV3+o8v+k7VACKEYjIgt0puLnLyGaCRv3uzm3dILw7L4uyJOMS5y bcQiB+u2xF4U/duyoVRDHBNkwmUYFznonKuy90g7dHgwGwOWTZYfeMtYMtKL9rapTUEA Ut7g== X-Gm-Message-State: AJcUukfr6IlTJHlNGJTM221EotukKaEQtoxSXPSSV+B4mDa7ecTZ2ayA HsLO6JNiC4ULIqPF/S0ZTJ/6vlkKnKujkQ== X-Google-Smtp-Source: ALg8bN44B4+U3hwPB6KoYyCgtmuGvEThLtTjv/4XcLaYQCI5InDuBZdXUm+Hf5hXmRxKf7tajdxxPw== X-Received: by 2002:aca:293:: with SMTP id 141mr2031508oic.28.1547940254429; Sat, 19 Jan 2019 15:24:14 -0800 (PST) Received: from localhost.localdomain ([165.231.210.5]) by smtp.gmail.com with ESMTPSA id q131sm4217385oih.1.2019.01.19.15.24.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 19 Jan 2019 15:24:13 -0800 (PST) From: Brandon Richardson To: git@vger.kernel.org, martin.agren@gmail.com, gitster@pobox.com Cc: Brandon Richardson Subject: [PATCH v4 1/2] t7510: invoke git as part of &&-chain Date: Sat, 19 Jan 2019 19:23:33 -0400 Message-Id: <20190119232334.31646-1-brandon1024.br@gmail.com> X-Mailer: git-send-email 2.20.1 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 From: Martin Ågren If `git commit-tree HEAD^{tree}` fails on us and produces no output on stdout, we will substitute that empty string and execute `git tag ninth-unsigned`, i.e., we will tag HEAD rather than a newly created object. But we are lucky: we have a signature on HEAD, so we should eventually fail the next test, where we verify that "ninth-unsigned" is indeed unsigned. We have a similar problem a few lines later. If `git commit-tree -S` fails with no output, we will happily tag HEAD as "tenth-signed". Here, we are not so lucky. The tag ends up on the same commit as "eighth-signed-alt", and that's a signed commit, so t7510-signed-commit will pass, despite `git commit-tree -S` failing. Make these `git commit-tree` invocations a direct part of the &&-chain, so that we can rely less on luck and set a better example for future tests modeled after this one. Fix a 9/10 copy/paste error while at it. Signed-off-by: Martin Ågren Signed-off-by: Brandon Richardson --- t/t7510-signed-commit.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/t/t7510-signed-commit.sh b/t/t7510-signed-commit.sh index 86d3f93fa..58f528b98 100755 --- a/t/t7510-signed-commit.sh +++ b/t/t7510-signed-commit.sh @@ -49,9 +49,13 @@ test_expect_success GPG 'create signed commits' ' git tag eighth-signed-alt && # commit.gpgsign is still on but this must not be signed - git tag ninth-unsigned $(echo 9 | git commit-tree HEAD^{tree}) && + echo 9 | git commit-tree HEAD^{tree} >oid && + test_line_count = 1 oid && + git tag ninth-unsigned $(cat oid) && # explicit -S of course must sign. - git tag tenth-signed $(echo 9 | git commit-tree -S HEAD^{tree}) + echo 10 | git commit-tree -S HEAD^{tree} >oid && + test_line_count = 1 oid && + git tag tenth-signed $(cat oid) ' test_expect_success GPG 'verify and show signatures' ' From patchwork Sat Jan 19 23:23:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brandon Richardson X-Patchwork-Id: 10772227 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 9C0E76C2 for ; Sat, 19 Jan 2019 23:24:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8AB672B486 for ; Sat, 19 Jan 2019 23:24:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7E0962B48A; Sat, 19 Jan 2019 23:24:30 +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 F162A2B487 for ; Sat, 19 Jan 2019 23:24:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729795AbfASXY2 (ORCPT ); Sat, 19 Jan 2019 18:24:28 -0500 Received: from mail-ot1-f68.google.com ([209.85.210.68]:39714 "EHLO mail-ot1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729766AbfASXY1 (ORCPT ); Sat, 19 Jan 2019 18:24:27 -0500 Received: by mail-ot1-f68.google.com with SMTP id n8so17623596otl.6 for ; Sat, 19 Jan 2019 15:24:27 -0800 (PST) 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=CrQJ6Ebd3VtzSPWqslP5PzREESXV3sNQcopcYazD8tA=; b=JDFWXEVhW+Vhfh5TgI1xHLQoa8mfeE+MgBsd3AyafuAU5GfZudRY4lnsTC8tn80ON5 YKqY5q61eAUW0QyOVI/k1zq1/YYFj67ZoAv16Zz5up8gh7yFZ5iw/PVMDRmXhkd93Atu s/Sp10OoaHbC7VWyhZui2rUjfScJXQhDzdfrU1jnwQUDVgifBTeawaYw9bf3nj5htoI6 IWaT4n8EGrHD9neUtpXxBytJYdcDPh2l/UbtXs5uvw4Yh4iPcXGN47iqWN56QOCSbwtv JGZfTAkVqd+fm9W5NNtRSAtmt53Njnx1GBsIsWVBWjlbm5bW9fA3eKetHxWgV9LVmhwt WyTA== 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=CrQJ6Ebd3VtzSPWqslP5PzREESXV3sNQcopcYazD8tA=; b=nHCj4S1IuZTrz9PJeJQkDdD9N5jOTyVNilZE5BDYVWHMd7Qgd8kyGOnkq+/rVWIhEI WHskqcYaOooAYVKKpN4eyN4ZveWft5MDoujEIu00bLoavxXMYfwRqWOe/J31mNVMS2XI NhG6ukVOTqlauKhMhT/TkUB0Bg9c674iXLLzfVcKLkHapIbSR4Ig3OQxadBQbem0ezFi vIwxkwMoeq3eqz4f3PB125qvPldJqsU+fGBoj2V+HtDGc4nRecQepxN7cxP5nIRN/G0T lhnLUh0VmetrswfGSHKxYiYLfRCIx4oKOrWeysEnqJX1FmYp/pBYFgNKvpwK2dvEeDWI 64sA== X-Gm-Message-State: AJcUukc7TKYEfwyF0MhZPWTt5hTKQXa21+LoqWU0JMTCb8mjWrES/2tW bu9k0rUoP/5plLIQ/MliVz8j/v7o+4x3AQ== X-Google-Smtp-Source: ALg8bN67XzSgxTxoWhyD23wBJPwFJ+CqLkSl5Et//zLiightL19H8BfZ1hQ/VXJN9woOQvsxneENTw== X-Received: by 2002:a9d:51c2:: with SMTP id d2mr16221822oth.0.1547940266605; Sat, 19 Jan 2019 15:24:26 -0800 (PST) Received: from localhost.localdomain ([165.231.210.5]) by smtp.gmail.com with ESMTPSA id q131sm4217385oih.1.2019.01.19.15.24.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 19 Jan 2019 15:24:26 -0800 (PST) From: Brandon Richardson To: git@vger.kernel.org, martin.agren@gmail.com, gitster@pobox.com Cc: Brandon Richardson Subject: [PATCH v4 2/2] commit-tree: add missing --gpg-sign flag Date: Sat, 19 Jan 2019 19:23:34 -0400 Message-Id: <20190119232334.31646-2-brandon1024.br@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190119232334.31646-1-brandon1024.br@gmail.com> References: <20190119232334.31646-1-brandon1024.br@gmail.com> 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 Add --gpg-sign option in commit-tree, which was documented, but not implemented, in 55ca3f99ae. Add tests for the --gpg-sign option. Signed-off-by: Brandon Richardson --- builtin/commit-tree.c | 8 +++++++- t/t7510-signed-commit.sh | 15 ++++++++++++--- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/builtin/commit-tree.c b/builtin/commit-tree.c index 9ec36a82b..12cc403bd 100644 --- a/builtin/commit-tree.c +++ b/builtin/commit-tree.c @@ -66,7 +66,13 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix) continue; } - if (skip_prefix(arg, "-S", &sign_commit)) + if (!strcmp(arg, "--gpg-sign")) { + sign_commit = ""; + continue; + } + + if (skip_prefix(arg, "-S", &sign_commit) || + skip_prefix(arg, "--gpg-sign=", &sign_commit)) continue; if (!strcmp(arg, "--no-gpg-sign")) { diff --git a/t/t7510-signed-commit.sh b/t/t7510-signed-commit.sh index 58f528b98..682b23a06 100755 --- a/t/t7510-signed-commit.sh +++ b/t/t7510-signed-commit.sh @@ -55,13 +55,22 @@ test_expect_success GPG 'create signed commits' ' # explicit -S of course must sign. echo 10 | git commit-tree -S HEAD^{tree} >oid && test_line_count = 1 oid && - git tag tenth-signed $(cat oid) + git tag tenth-signed $(cat oid) && + + # --gpg-sign[=] must sign. + echo 11 | git commit-tree --gpg-sign HEAD^{tree} >oid && + test_line_count = 1 oid && + git tag eleventh-signed $(cat oid) && + echo 12 | git commit-tree --gpg-sign=B7227189 HEAD^{tree} >oid && + test_line_count = 1 oid && + git tag twelfth-signed-alt $(cat oid) ' test_expect_success GPG 'verify and show signatures' ' ( for commit in initial second merge fourth-signed \ - fifth-signed sixth-signed seventh-signed tenth-signed + fifth-signed sixth-signed seventh-signed tenth-signed \ + eleventh-signed do git verify-commit $commit && git show --pretty=short --show-signature $commit >actual && @@ -82,7 +91,7 @@ test_expect_success GPG 'verify and show signatures' ' done ) && ( - for commit in eighth-signed-alt + for commit in eighth-signed-alt twelfth-signed-alt do git show --pretty=short --show-signature $commit >actual && grep "Good signature from" actual &&