Skip to content

Commit

Permalink
cherry-pick: Enforce --keep-redundant-commits incompatibility
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
zivarah committed Jan 28, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 126c3cb commit 36a59dd
Showing 2 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions builtin/revert.c
Original file line number Diff line number Diff line change
@@ -165,6 +165,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);
}

34 changes: 34 additions & 0 deletions t/t3515-cherry-pick-incompatible-options.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/sh

test_description='test if cherry-pick detects and aborts on incompatible options'

. ./test-lib.sh

test_expect_success setup '
echo first > file1 &&
git add file1 &&
test_tick &&
git commit -m "first" &&
echo second > file1 &&
git add file1 &&
test_tick &&
git commit -m "second"
'

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

0 comments on commit 36a59dd

Please sign in to comment.