1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-04-27 18:45:09 +02:00

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>
This commit is contained in:
Brian Lyles 2024-03-25 18:16:53 -05:00 committed by Junio C Hamano
parent 661b671aec
commit bd2f9fd025
2 changed files with 15 additions and 0 deletions

View File

@ -167,6 +167,7 @@ static int run_sequencer(int argc, const char **argv, const char *prefix,
"--ff", opts->allow_ff,
"--rerere-autoupdate", opts->allow_rerere_auto == RERERE_AUTOUPDATE,
"--no-rerere-autoupdate", opts->allow_rerere_auto == RERERE_NOAUTOUPDATE,
"--keep-redundant-commits", opts->keep_redundant_commits,
NULL);
}

View File

@ -99,4 +99,18 @@ test_expect_success 'cherry-pick a no-op with --keep-redundant' '
test_cmp expect actual
'
test_expect_success '--keep-redundant-commits is incompatible with operations' '
test_must_fail git cherry-pick HEAD 2>output &&
test_grep "The previous cherry-pick is now empty" output &&
test_must_fail git cherry-pick --keep-redundant-commits --continue 2>output &&
test_grep "fatal: cherry-pick: --keep-redundant-commits cannot be used with --continue" output &&
test_must_fail git cherry-pick --keep-redundant-commits --skip 2>output &&
test_grep "fatal: cherry-pick: --keep-redundant-commits cannot be used with --skip" output &&
test_must_fail git cherry-pick --keep-redundant-commits --abort 2>output &&
test_grep "fatal: cherry-pick: --keep-redundant-commits cannot be used with --abort" output &&
test_must_fail git cherry-pick --keep-redundant-commits --quit 2>output &&
test_grep "fatal: cherry-pick: --keep-redundant-commits cannot be used with --quit" output &&
git cherry-pick --abort
'
test_done