From: "Đoàn Trần Công Danh" <congdanhqx@gmail.com>
To: git@vger.kernel.org
Cc: "Đoàn Trần Công Danh" <congdanhqx@gmail.com>
Subject: [PATCH v3 2/6] cherry-pick/revert: honour --no-gpg-sign in all case
Date: Fri, 3 Apr 2020 17:28:03 +0700 [thread overview]
Message-ID: <28ebbfe72a04b787fb92702199efea663a6b7ee5.1585909453.git.congdanhqx@gmail.com> (raw)
In-Reply-To: <cover.1585909453.git.congdanhqx@gmail.com>
{cherry-pick,revert} --edit hasn't honoured --no-gpg-sign yet.
Pass this option down to git-commit to honour it.
Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
---
Documentation/git-cherry-pick.txt | 5 +-
Documentation/git-revert.txt | 5 +-
sequencer.c | 2 +
t/t3514-cherry-pick-revert-gpg.sh | 86 +++++++++++++++++++++++++++++++
4 files changed, 96 insertions(+), 2 deletions(-)
create mode 100755 t/t3514-cherry-pick-revert-gpg.sh
diff --git a/Documentation/git-cherry-pick.txt b/Documentation/git-cherry-pick.txt
index 83ce51aedf..75feeef08a 100644
--- a/Documentation/git-cherry-pick.txt
+++ b/Documentation/git-cherry-pick.txt
@@ -109,9 +109,12 @@ effect to your index in a row.
-S[<keyid>]::
--gpg-sign[=<keyid>]::
+--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.
+ stuck to the option without a space. `--no-gpg-sign` is useful to
+ countermand both `commit.gpgSign` configuration variable, and
+ earlier `--gpg-sign`.
--ff::
If the current HEAD is the same as the parent of the
diff --git a/Documentation/git-revert.txt b/Documentation/git-revert.txt
index 9d22270757..044276e9da 100644
--- a/Documentation/git-revert.txt
+++ b/Documentation/git-revert.txt
@@ -90,9 +90,12 @@ effect to your index in a row.
-S[<keyid>]::
--gpg-sign[=<keyid>]::
+--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.
+ stuck to the option without a space. `--no-gpg-sign` is useful to
+ countermand both `commit.gpgSign` configuration variable, and
+ earlier `--gpg-sign`.
-s::
--signoff::
diff --git a/sequencer.c b/sequencer.c
index 6fd2674632..9969355de7 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -946,6 +946,8 @@ static int run_git_commit(struct repository *r,
argv_array_push(&cmd.args, "--amend");
if (opts->gpg_sign)
argv_array_pushf(&cmd.args, "-S%s", opts->gpg_sign);
+ else
+ argv_array_push(&cmd.args, "--no-gpg-sign");
if (defmsg)
argv_array_pushl(&cmd.args, "-F", defmsg, NULL);
else if (!(flags & EDIT_MSG))
diff --git a/t/t3514-cherry-pick-revert-gpg.sh b/t/t3514-cherry-pick-revert-gpg.sh
new file mode 100755
index 0000000000..5b2e250eaa
--- /dev/null
+++ b/t/t3514-cherry-pick-revert-gpg.sh
@@ -0,0 +1,86 @@
+#!/bin/sh
+#
+# Copyright (c) 2020 Doan Tran Cong Danh
+#
+
+test_description='test {cherry-pick,revert} --[no-]gpg-sign'
+
+. ./test-lib.sh
+. "$TEST_DIRECTORY/lib-gpg.sh"
+
+if ! test_have_prereq GPG
+then
+ skip_all='skip all test {cherry-pick,revert} --[no-]gpg-sign, gpg not available'
+ test_done
+fi
+
+test_gpg_sign () {
+ local must_fail= will=will fake_editor=
+ if test "x$1" = "x!"
+ then
+ must_fail=test_must_fail
+ will="won't"
+ shift
+ fi
+ conf=$1
+ cmd=$2
+ cmit=$3
+ shift 3
+ test_expect_success "$cmd $* $cmit with commit.gpgsign=$conf $will sign commit" "
+ git reset --hard tip &&
+ git config commit.gpgsign $conf &&
+ git $cmd $* $cmit &&
+ git rev-list tip.. >rev-list &&
+ $must_fail git verify-commit \$(cat rev-list)
+ "
+}
+
+test_expect_success 'setup' '
+ test_commit one &&
+ git switch -c side &&
+ test_commit side1 &&
+ test_commit side2 &&
+ git switch - &&
+ test_commit two &&
+ test_commit three &&
+ test_commit tip
+'
+
+test_gpg_sign ! false cherry-pick side
+test_gpg_sign ! false cherry-pick ..side
+test_gpg_sign true cherry-pick side
+test_gpg_sign true cherry-pick ..side
+test_gpg_sign ! true cherry-pick side --no-gpg-sign
+test_gpg_sign ! true cherry-pick ..side --no-gpg-sign
+test_gpg_sign ! true cherry-pick side --gpg-sign --no-gpg-sign
+test_gpg_sign ! true cherry-pick ..side --gpg-sign --no-gpg-sign
+test_gpg_sign false cherry-pick side --no-gpg-sign --gpg-sign
+test_gpg_sign false cherry-pick ..side --no-gpg-sign --gpg-sign
+test_gpg_sign true cherry-pick side --edit
+test_gpg_sign true cherry-pick ..side --edit
+test_gpg_sign ! true cherry-pick side --edit --no-gpg-sign
+test_gpg_sign ! true cherry-pick ..side --edit --no-gpg-sign
+test_gpg_sign ! true cherry-pick side --edit --gpg-sign --no-gpg-sign
+test_gpg_sign ! true cherry-pick ..side --edit --gpg-sign --no-gpg-sign
+test_gpg_sign false cherry-pick side --edit --no-gpg-sign --gpg-sign
+test_gpg_sign false cherry-pick ..side --edit --no-gpg-sign --gpg-sign
+
+test_gpg_sign ! false revert HEAD --edit
+test_gpg_sign ! false revert two.. --edit
+test_gpg_sign true revert HEAD --edit
+test_gpg_sign true revert two.. --edit
+test_gpg_sign ! true revert HEAD --edit --no-gpg-sign
+test_gpg_sign ! true revert two.. --edit --no-gpg-sign
+test_gpg_sign ! true revert HEAD --edit --gpg-sign --no-gpg-sign
+test_gpg_sign ! true revert two.. --edit --gpg-sign --no-gpg-sign
+test_gpg_sign false revert HEAD --edit --no-gpg-sign --gpg-sign
+test_gpg_sign false revert two.. --edit --no-gpg-sign --gpg-sign
+test_gpg_sign true revert HEAD --no-edit
+test_gpg_sign true revert two.. --no-edit
+test_gpg_sign ! true revert HEAD --no-edit --no-gpg-sign
+test_gpg_sign ! true revert two.. --no-edit --no-gpg-sign
+test_gpg_sign ! true revert HEAD --no-edit --gpg-sign --no-gpg-sign
+test_gpg_sign ! true revert two.. --no-edit --gpg-sign --no-gpg-sign
+test_gpg_sign false revert HEAD --no-edit --no-gpg-sign --gpg-sign
+
+test_done
--
2.26.0.334.g6536db25bb
next prev parent reply other threads:[~2020-04-03 10:28 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-30 20:03 Support for `--no-gpg-sign` in git rebase, cherry-pick, etc Dominic Chen
2020-03-31 6:44 ` [PATCH] rebase.c: teach --no-gpg-sign to git-rebase Danh Doan
2020-04-01 17:47 ` Junio C Hamano
2020-04-02 1:09 ` Danh Doan
2020-04-02 10:15 ` [PATCH v2 0/5] Honour and Document --no-gpg-sign Đoàn Trần Công Danh
2020-04-02 10:15 ` [PATCH v2 1/5] rebase.c: honour --no-gpg-sign Đoàn Trần Công Danh
2020-04-03 5:21 ` Martin Ågren
2020-04-02 10:15 ` [PATCH v2 2/5] cherry-pick/revert: honour --no-gpg-sign in all case Đoàn Trần Công Danh
2020-04-02 10:15 ` [PATCH v2 3/5] Documentation: document am --no-gpg-sign Đoàn Trần Công Danh
2020-04-02 10:15 ` [PATCH v2 4/5] Documentation: reword commit --no-gpg-sign Đoàn Trần Công Danh
2020-04-02 10:15 ` [PATCH v2 5/5] Documentation: document merge option --no-gpg-sign Đoàn Trần Công Danh
2020-04-02 18:07 ` Junio C Hamano
2020-04-03 0:25 ` Danh Doan
2020-04-03 10:28 ` [PATCH v3 0/6] Honour and Document --no-gpg-sign Đoàn Trần Công Danh
2020-04-03 10:28 ` [PATCH v3 1/6] rebase.c: honour --no-gpg-sign Đoàn Trần Công Danh
2020-04-03 10:28 ` Đoàn Trần Công Danh [this message]
2020-04-03 13:43 ` [PATCH v3 2/6] cherry-pick/revert: honour --no-gpg-sign in all case Phillip Wood
2020-04-03 14:26 ` Danh Doan
2020-04-03 10:28 ` [PATCH v3 3/6] Documentation: document am --no-gpg-sign Đoàn Trần Công Danh
2020-04-03 10:28 ` [PATCH v3 4/6] Documentation: reword commit --no-gpg-sign Đoàn Trần Công Danh
2020-04-03 10:28 ` [PATCH v3 5/6] Documentation: merge commit-tree --[no-]gpg-sign Đoàn Trần Công Danh
2020-04-03 10:28 ` [PATCH v3 6/6] Documentation: document merge option --no-gpg-sign Đoàn Trần Công Danh
2020-04-03 18:40 ` [PATCH v3 0/6] Honour and Document --no-gpg-sign Junio C Hamano
2020-04-04 14:36 ` Martin Ågren
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=28ebbfe72a04b787fb92702199efea663a6b7ee5.1585909453.git.congdanhqx@gmail.com \
--to=congdanhqx@gmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).