Skip to content

Commit 73af6a4

Browse files
committed
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
2 parents 9879f3b + 43ad4f2 commit 73af6a4

File tree

2 files changed

+59
-1
lines changed

2 files changed

+59
-1
lines changed

sequencer.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3677,7 +3677,9 @@ 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);
3681+
else
3682+
strvec_push(&cmd.args, "--no-gpg-sign");
36813683

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

t/t3435-rebase-gpg-sign.sh

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,60 @@ 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+
92+
test_expect_success "rebase -r, merge strategy, commit.gpgsign=true --no-gpg-sign won't sign commit" '
93+
git reset --hard merged &&
94+
git config commit.gpgsign true &&
95+
git rebase -fr --no-gpg-sign -s resolve --root &&
96+
test_must_fail git verify-commit HEAD
97+
'
98+
99+
test_expect_success 'rebase -r --gpg-sign will sign commit' '
100+
git reset --hard merged &&
101+
test_unconfig commit.gpgsign &&
102+
git rebase -fr --gpg-sign --root &&
103+
git verify-commit HEAD
104+
'
105+
106+
test_expect_success 'rebase -r with commit.gpgsign=true will sign commit' '
107+
git reset --hard merged &&
108+
git config commit.gpgsign true &&
109+
git rebase -fr --root &&
110+
git verify-commit HEAD
111+
'
112+
113+
test_expect_success 'rebase -r --gpg-sign with commit.gpgsign=false will sign commit' '
114+
git reset --hard merged &&
115+
git config commit.gpgsign false &&
116+
git rebase -fr --gpg-sign --root &&
117+
git verify-commit HEAD
118+
'
119+
120+
test_expect_success "rebase -r --no-gpg-sign with commit.gpgsign=true won't sign commit" '
121+
git reset --hard merged &&
122+
git config commit.gpgsign true &&
123+
git rebase -fr --no-gpg-sign --root &&
124+
test_must_fail git verify-commit HEAD
125+
'
126+
71127
test_done

0 commit comments

Comments
 (0)