Merge branch 'sc/sequencer-gpg-octopus'

"git rebase --rebase-merges" did not correctly pass --gpg-sign
command line option to underlying "git merge" when replaying a merge
using non-default merge strategy or when replaying an octopus merge
(because replaying a two-head merge with the default strategy was
done in a separate codepath, the problem did not trigger for most
users), which has been corrected.

* sc/sequencer-gpg-octopus:
  t3435: add tests for rebase -r GPG signing
  sequencer: pass explicit --no-gpg-sign to merge
  sequencer: fix gpg option passed to merge subcommand
This commit is contained in:
Junio C Hamano 2020-11-02 13:17:43 -08:00
commit 73af6a4fab
2 changed files with 59 additions and 1 deletions

View File

@ -3677,7 +3677,9 @@ static int do_merge(struct repository *r,
strvec_push(&cmd.args, "-F");
strvec_push(&cmd.args, git_path_merge_msg(r));
if (opts->gpg_sign)
strvec_push(&cmd.args, opts->gpg_sign);
strvec_pushf(&cmd.args, "-S%s", opts->gpg_sign);
else
strvec_push(&cmd.args, "--no-gpg-sign");
/* Add the tips to be merged */
for (j = to_merge; j; j = j->next)

View File

@ -68,4 +68,60 @@ test_expect_failure 'rebase -p --no-gpg-sign override commit.gpgsign' '
test_must_fail git verify-commit HEAD
'
test_expect_success 'rebase -r, merge strategy, --gpg-sign will sign commit' '
git reset --hard merged &&
test_unconfig commit.gpgsign &&
git rebase -fr --gpg-sign -s resolve --root &&
git verify-commit HEAD
'
test_expect_success 'rebase -r, merge strategy, commit.gpgsign=true will sign commit' '
git reset --hard merged &&
git config commit.gpgsign true &&
git rebase -fr -s resolve --root &&
git verify-commit HEAD
'
test_expect_success 'rebase -r, merge strategy, commit.gpgsign=false --gpg-sign will sign commit' '
git reset --hard merged &&
git config commit.gpgsign false &&
git rebase -fr --gpg-sign -s resolve --root &&
git verify-commit HEAD
'
test_expect_success "rebase -r, merge strategy, commit.gpgsign=true --no-gpg-sign won't sign commit" '
git reset --hard merged &&
git config commit.gpgsign true &&
git rebase -fr --no-gpg-sign -s resolve --root &&
test_must_fail git verify-commit HEAD
'
test_expect_success 'rebase -r --gpg-sign will sign commit' '
git reset --hard merged &&
test_unconfig commit.gpgsign &&
git rebase -fr --gpg-sign --root &&
git verify-commit HEAD
'
test_expect_success 'rebase -r with commit.gpgsign=true will sign commit' '
git reset --hard merged &&
git config commit.gpgsign true &&
git rebase -fr --root &&
git verify-commit HEAD
'
test_expect_success 'rebase -r --gpg-sign with commit.gpgsign=false will sign commit' '
git reset --hard merged &&
git config commit.gpgsign false &&
git rebase -fr --gpg-sign --root &&
git verify-commit HEAD
'
test_expect_success "rebase -r --no-gpg-sign with commit.gpgsign=true won't sign commit" '
git reset --hard merged &&
git config commit.gpgsign true &&
git rebase -fr --no-gpg-sign --root &&
test_must_fail git verify-commit HEAD
'
test_done