cherry-pick: enforce `--keep-redundant-commits` incompatibility

When `--keep-redundant-commits` was added in b27cfb0d8d (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 <brianmlyles@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Brian Lyles committed Mar 25, 2024 at 18:16 UTC bd2f9fd025e3aa2926f249e9c24f1f648e89d997
2 files changed +15
builtin/revert.c
+1
@@ -167,6 +167,7 @@ static int run_sequencer(int argc, const char **argv, const char *prefix,
167 "--ff", opts->allow_ff,
168 "--rerere-autoupdate", opts->allow_rerere_auto == RERERE_AUTOUPDATE,
169 "--no-rerere-autoupdate", opts->allow_rerere_auto == RERERE_NOAUTOUPDATE,
170 + "--keep-redundant-commits", opts->keep_redundant_commits,
171 NULL);
172 }
173
t/t3505-cherry-pick-empty.sh
+14
@@ -99,4 +99,18 @@ test_expect_success 'cherry-pick a no-op with --keep-redundant' '
99 test_cmp expect actual
100 '
101
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 +
116 test_done