]> git.ipfire.org Git - thirdparty/git.git/commitdiff
cherry-pick: enforce `--keep-redundant-commits` incompatibility
authorBrian Lyles <brianmlyles@gmail.com>
Mon, 25 Mar 2024 23:16:53 +0000 (18:16 -0500)
committerJunio C Hamano <gitster@pobox.com>
Mon, 25 Mar 2024 23:45:41 +0000 (16:45 -0700)
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>
builtin/revert.c
t/t3505-cherry-pick-empty.sh

index 89821bab95745a5fca294d00811804799ecd323d..a1936ef70e91e9d61b358d3a41f9349181904b71 100644 (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);
        }
 
index eba3c38d5ad861a5d71b7fa9615ee804b24e6fc4..61f91aaa0a67650722c6cde7e19bc97ec58edc45 100755 (executable)
@@ -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