1
0
mirror of https://github.com/git/git.git synced 2024-09-28 07:40:44 +02:00

Merge branch 'dd/no-gpg-sign'

"git rebase" learned the "--no-gpg-sign" option to countermand
commit.gpgSign the user may have.

* dd/no-gpg-sign:
  Documentation: document merge option --no-gpg-sign
  Documentation: merge commit-tree --[no-]gpg-sign
  Documentation: reword commit --no-gpg-sign
  Documentation: document am --no-gpg-sign
  cherry-pick/revert: honour --no-gpg-sign in all case
  rebase.c: honour --no-gpg-sign
This commit is contained in:
Junio C Hamano 2020-04-22 13:42:52 -07:00
commit fc3f6fd7be
11 changed files with 190 additions and 18 deletions

View File

@ -148,9 +148,12 @@ default. You can use `--no-utf8` to override this.
-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`.
--continue::
-r::

View File

@ -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

View File

@ -61,13 +61,11 @@ OPTIONS
-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.
--no-gpg-sign::
Do not GPG-sign commit, to countermand a `--gpg-sign` option
given earlier on the command line.
stuck to the option without a space. `--no-gpg-sign` is useful to
countermand a `--gpg-sign` option given earlier on the command line.
Commit Information
------------------

View File

@ -348,13 +348,12 @@ changes to tracked files.
-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.
--no-gpg-sign::
Countermand `commit.gpgSign` configuration variable that is
set to force each and every commit to be signed.
stuck to the option without a space. `--no-gpg-sign` is useful to
countermand both `commit.gpgSign` configuration variable, and
earlier `--gpg-sign`.
\--::
Do not interpret any more arguments as options.

View File

@ -354,9 +354,12 @@ See also INCOMPATIBLE OPTIONS below.
-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`.
-q::
--quiet::

View File

@ -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::

View File

@ -61,9 +61,12 @@ When not possible, refuse to merge and exit with a non-zero status.
-S[<keyid>]::
--gpg-sign[=<keyid>]::
--no-gpg-sign::
GPG-sign the resulting merge commit. The `keyid` argument is
optional and defaults to the committer identity; if specified,
it must be stuck to the option without a space.
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`.
--log[=<n>]::
--no-log::

View File

@ -1593,6 +1593,9 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
options.allow_empty_message = 1;
git_config(rebase_config, &options);
/* options.gpg_sign_opt will be either "-S" or NULL */
gpg_sign = options.gpg_sign_opt ? "" : NULL;
FREE_AND_NULL(options.gpg_sign_opt);
if (options.use_legacy_rebase ||
!git_env_bool("GIT_TEST_REBASE_USE_BUILTIN", -1))
@ -1823,10 +1826,8 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
if (options.empty != EMPTY_UNSPECIFIED)
imply_merge(&options, "--empty");
if (gpg_sign) {
free(options.gpg_sign_opt);
if (gpg_sign)
options.gpg_sign_opt = xstrfmt("-S%s", gpg_sign);
}
if (exec.nr) {
int i;

View File

@ -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))

71
t/t3435-rebase-gpg-sign.sh Executable file
View File

@ -0,0 +1,71 @@
#!/bin/sh
#
# Copyright (c) 2020 Doan Tran Cong Danh
#
test_description='test rebase --[no-]gpg-sign'
. ./test-lib.sh
. "$TEST_DIRECTORY/lib-rebase.sh"
. "$TEST_DIRECTORY/lib-gpg.sh"
if ! test_have_prereq GPG
then
skip_all='skip all test rebase --[no-]gpg-sign, gpg not available'
test_done
fi
test_rebase_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
shift
test_expect_success "rebase $* with commit.gpgsign=$conf $will sign commit" "
git reset two &&
git config commit.gpgsign $conf &&
set_fake_editor &&
FAKE_LINES='r 1 p 2' git rebase --force-rebase --root $* &&
$must_fail git verify-commit HEAD^ &&
$must_fail git verify-commit HEAD
"
}
test_expect_success 'setup' '
test_commit one &&
test_commit two &&
test_must_fail git verify-commit HEAD &&
test_must_fail git verify-commit HEAD^
'
test_expect_success 'setup: merge commit' '
test_commit fork-point &&
git switch -c side &&
test_commit three &&
git switch master &&
git merge --no-ff side &&
git tag merged
'
test_rebase_gpg_sign ! false
test_rebase_gpg_sign true
test_rebase_gpg_sign ! true --no-gpg-sign
test_rebase_gpg_sign ! true --gpg-sign --no-gpg-sign
test_rebase_gpg_sign false --no-gpg-sign --gpg-sign
test_rebase_gpg_sign true -i
test_rebase_gpg_sign ! true -i --no-gpg-sign
test_rebase_gpg_sign ! true -i --gpg-sign --no-gpg-sign
test_rebase_gpg_sign false -i --no-gpg-sign --gpg-sign
test_expect_failure 'rebase -p --no-gpg-sign override commit.gpgsign' '
git reset --hard merged &&
git config commit.gpgsign true &&
git rebase -p --no-gpg-sign --onto=one fork-point master &&
test_must_fail git verify-commit HEAD
'
test_done

View File

@ -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