Skip to content

Commit bd2f9fd

Browse files
zivarahgitster
authored andcommitted
cherry-pick: enforce --keep-redundant-commits incompatibility
When `--keep-redundant-commits` was added in b27cfb0 (git-cherry-pick: Add keep-redundant-commits option, 2012-04-20), it was not marked as incompatible with the various operations needed to continue or exit a cherry-pick (`--continue`, `--skip`, `--abort`, and `--quit`). Enforce this incompatibility via `verify_opt_compatible` like we do for the other various options. Signed-off-by: Brian Lyles <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 661b671 commit bd2f9fd

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

builtin/revert.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ static int run_sequencer(int argc, const char **argv, const char *prefix,
167167
"--ff", opts->allow_ff,
168168
"--rerere-autoupdate", opts->allow_rerere_auto == RERERE_AUTOUPDATE,
169169
"--no-rerere-autoupdate", opts->allow_rerere_auto == RERERE_NOAUTOUPDATE,
170+
"--keep-redundant-commits", opts->keep_redundant_commits,
170171
NULL);
171172
}
172173

t/t3505-cherry-pick-empty.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,18 @@ test_expect_success 'cherry-pick a no-op with --keep-redundant' '
9999
test_cmp expect actual
100100
'
101101

102+
test_expect_success '--keep-redundant-commits is incompatible with operations' '
103+
test_must_fail git cherry-pick HEAD 2>output &&
104+
test_grep "The previous cherry-pick is now empty" output &&
105+
test_must_fail git cherry-pick --keep-redundant-commits --continue 2>output &&
106+
test_grep "fatal: cherry-pick: --keep-redundant-commits cannot be used with --continue" output &&
107+
test_must_fail git cherry-pick --keep-redundant-commits --skip 2>output &&
108+
test_grep "fatal: cherry-pick: --keep-redundant-commits cannot be used with --skip" output &&
109+
test_must_fail git cherry-pick --keep-redundant-commits --abort 2>output &&
110+
test_grep "fatal: cherry-pick: --keep-redundant-commits cannot be used with --abort" output &&
111+
test_must_fail git cherry-pick --keep-redundant-commits --quit 2>output &&
112+
test_grep "fatal: cherry-pick: --keep-redundant-commits cannot be used with --quit" output &&
113+
git cherry-pick --abort
114+
'
115+
102116
test_done

0 commit comments

Comments
 (0)