Skip to content

Commit ae03c97

Browse files
sammkogitster
authored andcommitted
sequencer: fix gpg option passed to merge subcommand
When performing a rebase with --rebase-merges using either a custom strategy specified with -s or an octopus merge, and at the same time having gpgsign enabled (either rebase -S or config commit.gpgsign), the operation would fail on making the merge commit. Instead of "-S%s" with the key id substituted, only the bare key id would get passed to the underlying merge command, which tried to interpret it as a ref. Fix the issue and add test cases as suggested by Johannes Schindelin and Junio C Hamano. Signed-off-by: Samuel Čavoj <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d4a3924 commit ae03c97

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

sequencer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3677,7 +3677,7 @@ static int do_merge(struct repository *r,
36773677
strvec_push(&cmd.args, "-F");
36783678
strvec_push(&cmd.args, git_path_merge_msg(r));
36793679
if (opts->gpg_sign)
3680-
strvec_push(&cmd.args, opts->gpg_sign);
3680+
strvec_pushf(&cmd.args, "-S%s", opts->gpg_sign);
36813681

36823682
/* Add the tips to be merged */
36833683
for (j = to_merge; j; j = j->next)

t/t3435-rebase-gpg-sign.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,25 @@ test_expect_failure 'rebase -p --no-gpg-sign override commit.gpgsign' '
6868
test_must_fail git verify-commit HEAD
6969
'
7070

71+
test_expect_success 'rebase -r, merge strategy, --gpg-sign will sign commit' '
72+
git reset --hard merged &&
73+
test_unconfig commit.gpgsign &&
74+
git rebase -fr --gpg-sign -s resolve --root &&
75+
git verify-commit HEAD
76+
'
77+
78+
test_expect_success 'rebase -r, merge strategy, commit.gpgsign=true will sign commit' '
79+
git reset --hard merged &&
80+
git config commit.gpgsign true &&
81+
git rebase -fr -s resolve --root &&
82+
git verify-commit HEAD
83+
'
84+
85+
test_expect_success 'rebase -r, merge strategy, commit.gpgsign=false --gpg-sign will sign commit' '
86+
git reset --hard merged &&
87+
git config commit.gpgsign false &&
88+
git rebase -fr --gpg-sign -s resolve --root &&
89+
git verify-commit HEAD
90+
'
91+
7192
test_done

0 commit comments

Comments
 (0)