From patchwork Mon Apr 10 17:01:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacques Vidrine X-Patchwork-Id: 13206525 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0715BC77B70 for ; Mon, 10 Apr 2023 17:01:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230147AbjDJRBz (ORCPT ); Mon, 10 Apr 2023 13:01:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230112AbjDJRBw (ORCPT ); Mon, 10 Apr 2023 13:01:52 -0400 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5CD661BF5 for ; Mon, 10 Apr 2023 10:01:51 -0700 (PDT) Received: by mail-wm1-x333.google.com with SMTP id s8so3165809wmo.0 for ; Mon, 10 Apr 2023 10:01:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1681146109; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=Ktnigil0zLkzS2PVEwp9McW7H+78e1D6Qrq1gi+KCYQ=; b=L1nqqtLCK4OY2qRUstrLvjqR6mnEnSs3bTm1iK/XNVmAfZXSpKPBorad+iAHyluCDl xpyXliv3tg8SqU8PPqLsvyrwOP3gQHWsEdpx7W8SPiPaXw2dn8whPZrCYRJEqdPp3DU2 KYbceMiXCoOkw+0q2g1LM/9eWtxrZpUvswS5/H4kNUyl5UKZv0kyD5sogqeZg4x1qHn8 aqlQWOk4wu94cxRNahRMCTI6vAmyAcmEQvqwWYRyIQJ2deTHnhKkj71TYAFwvJeoKknn D0Qqcolls8T/dYJEgA6J76wzD5M7kPmz+1UFfj/pXBGEj12Gr2DI01+HiRWMH6y3Yjfj 9f8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1681146109; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Ktnigil0zLkzS2PVEwp9McW7H+78e1D6Qrq1gi+KCYQ=; b=jIjXEPCfMA80UvsNMRdP25+WcKReL+fUVo9H4yqcTd5uYfXe9WY/IfEqKn65A3n634 1ajhVkTercgO3eGwy92lFngunZEcHxC7FkZcv5o6iwCgOkWgsVjfEbWqfKMYV4hLD9ME trmGkMext2pSrzbuQtwZyNVHINJ4nrf2fBCX7bACsHTIZ31ZJS/KTv0chCkj+98KWdzp uYfvWlLMtT1bN8pg6wkjdL+yGwr9wDy2JgIB7AoioNlx5oilDXV/Pocg3BW92YRPY8+q blVtC7DkF0eGvthSpc40w4MoOUIbNMnSbzTTMKj5L4DzgzEuD42tQ/+JjQIh2TVZrMgi AZFA== X-Gm-Message-State: AAQBX9c98aOCvbQK2sgel2bBkP+U1ViimXEfpcN8nywSJ8iHKJKpbkGH WahYCQV5w/N51yrHjcHP+mTN11WlQ7A= X-Google-Smtp-Source: AKy350YNHRg/1GapKNOQHaDiCVjaJXcce0Y1vXcNCD4yvSo9doSADdpVVwD5zYjrc8X2wmqRCWHUcg== X-Received: by 2002:a7b:c386:0:b0:3ed:8780:f265 with SMTP id s6-20020a7bc386000000b003ed8780f265mr8294716wmj.21.1681146109426; Mon, 10 Apr 2023 10:01:49 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id f8-20020a05600c44c800b003ef4cd057f5sm17990213wmo.4.2023.04.10.10.01.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Apr 2023 10:01:49 -0700 (PDT) Message-Id: In-Reply-To: References: Date: Mon, 10 Apr 2023 17:01:46 +0000 Subject: [PATCH 1/2] subtree: support GPG commit signing Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Allen Reese , Jacques Vidrine Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Jacques Vidrine From: Jacques Vidrine Add support for -S/--gpg-sign/--no-gpg-sign command line options and commit.gpgsign configuration. These are passed to invocations of `git commit-tree`. Signed-off-by: Allen Reese Signed-off-by: Jacques Vidrine --- contrib/subtree/git-subtree.sh | 24 +++++++++++++++++++----- contrib/subtree/git-subtree.txt | 9 +++++++++ 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh index 10c9c87839a..553b4391deb 100755 --- a/contrib/subtree/git-subtree.sh +++ b/contrib/subtree/git-subtree.sh @@ -46,6 +46,8 @@ rejoin merge the new branch back into HEAD options for 'add' and 'merge' (also: 'pull', 'split --rejoin', and 'push --rejoin') squash merge subtree changes as a single commit m,message= use the given message as the commit message for the merge commit +S,gpg-sign? GPG-sign commits, optionally specifying keyid. +no-gpg-sign Disable GPG commit signing. " indent=0 @@ -165,6 +167,7 @@ main () { arg_quiet= arg_debug= arg_prefix= + arg_gpgsign= arg_split_branch= arg_split_onto= arg_split_ignore_joins= @@ -240,6 +243,9 @@ main () { test -n "$allow_addmerge" || die_incompatible_opt "$opt" "$arg_command" arg_addmerge_squash= ;; + -S*|--gpg-sign=*|--no-gpg-sign) + arg_gpgsign="${opt}" + ;; --) break ;; @@ -268,6 +274,12 @@ main () { dir="$(dirname "$arg_prefix/.")" + if test -z "$arg_gpgsign" && + git config --bool commit.gpgsign >/dev/null + then + arg_gpgsign="-S" + fi + debug "command: {$arg_command}" debug "quiet: {$arg_quiet}" debug "dir: {$dir}" @@ -534,7 +546,7 @@ copy_commit () { printf "%s" "$arg_split_annotate" cat ) | - git commit-tree "$2" $3 # reads the rest of stdin + git commit-tree $arg_gpgsign "$2" $3 # reads the rest of stdin ) || die "fatal: can't copy commit $1" } @@ -674,10 +686,10 @@ new_squash_commit () { if test -n "$old" then squash_msg "$dir" "$oldsub" "$newsub" | - git commit-tree "$tree" -p "$old" || exit $? + git commit-tree $arg_gpgsign "$tree" -p "$old" || exit $? else squash_msg "$dir" "" "$newsub" | - git commit-tree "$tree" || exit $? + git commit-tree $arg_gpgsign "$tree" || exit $? fi } @@ -900,11 +912,13 @@ cmd_add_commit () { then rev=$(new_squash_commit "" "" "$rev") || exit $? commit=$(add_squashed_msg "$rev" "$dir" | - git commit-tree "$tree" $headp -p "$rev") || exit $? + git commit-tree $arg_gpgsign "$tree" \ + $headp -p "$rev") || exit $? else revp=$(peel_committish "$rev") || exit $? commit=$(add_msg "$dir" $headrev "$rev" | - git commit-tree "$tree" $headp -p "$revp") || exit $? + git commit-tree $arg_gpgsign "$tree" \ + $headp -p "$revp") || exit $? fi git reset "$commit" || exit $? diff --git a/contrib/subtree/git-subtree.txt b/contrib/subtree/git-subtree.txt index 004abf415b8..fa54541b288 100644 --- a/contrib/subtree/git-subtree.txt +++ b/contrib/subtree/git-subtree.txt @@ -185,6 +185,15 @@ subproject. --message=:: Specify as the commit message for the merge commit. +-S[]:: +--gpg-sign[=]:: +--no-gpg-sign:: + GPG-sign commits. The `keyid` argument is optional and + defaults to the committer identity; if specified, it must be + stuck to the option without a space. `--no-gpg-sign` is useful to + countermand both `commit.gpgSign` configuration variable, and + earlier `--gpg-sign`. + OPTIONS FOR 'split' (ALSO: 'push') ---------------------------------- These options for 'split' may also be given to 'push' (which wraps From patchwork Mon Apr 10 17:01:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allen Reese X-Patchwork-Id: 13206524 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9B2E3C77B61 for ; Mon, 10 Apr 2023 17:01:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230141AbjDJRBy (ORCPT ); Mon, 10 Apr 2023 13:01:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60542 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229669AbjDJRBw (ORCPT ); Mon, 10 Apr 2023 13:01:52 -0400 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A33211BF8 for ; Mon, 10 Apr 2023 10:01:51 -0700 (PDT) Received: by mail-wm1-x32a.google.com with SMTP id v20-20020a05600c471400b003ed8826253aso6855183wmo.0 for ; Mon, 10 Apr 2023 10:01:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1681146110; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=91IckjwX+gzGamNsobPr4wYUx7h8O6605eBuYRJb8xA=; b=Ogt4ml+V3rybpWM6l+zKxTEOapUaB/Q5lUt5sWo0WlSklgd2YOJ66amp9eRfZ73avf nUjQ33nzcsIFA8URoxi/3qF/jFhhMGkIPByNmISRv7rsOsv9EOmPq8guhhI98jgUQXLt goj8h5grdhrTvXoaQlN2AJwM4YUJQx+u6IBES52IZx9KlAG29XWzbRrfBHpDDyNNcv67 tYvEP0YxqIJEJqIzK7p7fU9GWSyHKw9UFOqfSrPZSTG592MhMkxXRpgjZOBqn4y9JkEq xi6XgR3y+REVeNdP4zx96hLLoLjROGRRiDyeqm1J9zs5g3Jsl77n/BobOFCt7fssYQWW J4Pg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1681146110; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=91IckjwX+gzGamNsobPr4wYUx7h8O6605eBuYRJb8xA=; b=PUOf/V8n2GM+tDTTMUc3JG6LC8sFihtp8EaqIDRPEwRPXWfnq/U7Ppl7qSleWlWUl4 J6Vrm/bVQuRbcrT0Pov+B/CCkrMQBQsOcZAH6UaxkkdrrNRU1Drvnf+d+/fsy4e6j0Pt t6kPZ6HwqWFBH9g3YcKF2MDEHUjKawW1HYtr7aGhZ1SYVVyzUg9AHLcJ28TGf39JTbBW ogla1K30sBOmy/9ej2ZYNaiM8yVl08TjEoI+eOTBQw52UAYtEsTclyEy/LXSHMfHXjjv xfq0mFT/qgdPrES04jgYxz08p+8zcbn85hcTbQWNKcEoNBs8ZpCXIFEQNAsT6Zznu5ZG WdkA== X-Gm-Message-State: AAQBX9dUJJC4sEeEWtKY9d4crxMLX86MG+9jG+9v0UE3CbMfDD9my1AG BVaBLHntYkOoTP9zerNzugdoloXlw6U= X-Google-Smtp-Source: AKy350af6tMJa9b7ruMTjgXOUxOz15YX36Fl+yIxT9UhoSePzUGebnS5JRkScwebb2zUohcrJ/94hg== X-Received: by 2002:a05:600c:202:b0:3f0:4e04:bd47 with SMTP id 2-20020a05600c020200b003f04e04bd47mr58589wmi.37.1681146109969; Mon, 10 Apr 2023 10:01:49 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id b2-20020a05600c4e0200b003f04057bf1bsm17879557wmq.18.2023.04.10.10.01.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Apr 2023 10:01:49 -0700 (PDT) Message-Id: <01d69fc9f12197eb43cf48b3d7eff9a40f04e51b.1681146107.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Mon, 10 Apr 2023 17:01:47 +0000 Subject: [PATCH 2/2] contrib/subtree: fix gpg_sign_arg not being passed to git merge. Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Allen Reese , Allen Reese Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Allen Reese From: Allen Reese Replace immitate -> imitate. cc: Avery apenwarr@gmail.com Signed-off-by: Allen Reese --- contrib/subtree/git-subtree.sh | 14 +++++++++++--- contrib/subtree/t/t7900-subtree.sh | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh index 553b4391deb..18dc7f8a4c2 100755 --- a/contrib/subtree/git-subtree.sh +++ b/contrib/subtree/git-subtree.sh @@ -243,8 +243,16 @@ main () { test -n "$allow_addmerge" || die_incompatible_opt "$opt" "$arg_command" arg_addmerge_squash= ;; - -S*|--gpg-sign=*|--no-gpg-sign) + -S|--gpg-sign|--no-gpg-sign) arg_gpgsign="${opt}" + case $1 in + -*) + ;; + *) + arg_gpgsign=${opt}${1} + shift + ;; + esac ;; --) break @@ -1053,10 +1061,10 @@ cmd_merge () { if test -n "$arg_addmerge_message" then - git merge --no-ff -Xsubtree="$arg_prefix" \ + git merge --no-ff $arg_gpgsign -Xsubtree="$arg_prefix" \ --message="$arg_addmerge_message" "$rev" else - git merge --no-ff -Xsubtree="$arg_prefix" $rev + git merge --no-ff $arg_gpgsign -Xsubtree="$arg_prefix" $rev fi } diff --git a/contrib/subtree/t/t7900-subtree.sh b/contrib/subtree/t/t7900-subtree.sh index 341c169eca7..fa5bd9b7af6 100755 --- a/contrib/subtree/t/t7900-subtree.sh +++ b/contrib/subtree/t/t7900-subtree.sh @@ -47,7 +47,7 @@ last_commit_subject () { # pre-2.32.0 versions of 'git subtree' would write the hash of the tag # (sub1 below), instead of the commit (sub1^{commit}) in the # "git-subtree-split" trailer. -# We immitate this behaviour below using a replace ref. +# We imitate this behaviour below using a replace ref. # This function creates 3 repositories: # - $1 # - $1-sub (added as subtree "sub" in $1)