Merge branch 'so/cherry-pick-always-allow-m1' · koraktor/git@77fbd96 · GitHub
Skip to content

Commit 77fbd96

Browse files
committed
Merge branch 'so/cherry-pick-always-allow-m1'
"git cherry-pick -m1" was forbidden when picking a non-merge commit, even though there _is_ parent number 1 for such a commit. This was done to avoid mistakes back when "cherry-pick" was about picking a single commit, but is no longer useful with "cherry-pick" that can pick a range of commits. Now the "-m$num" option is allowed when picking any commit, as long as $num names an existing parent of the commit. Technically this is a backward incompatible change; hopefully nobody is relying on the error-checking behaviour. * so/cherry-pick-always-allow-m1: t3506: validate '-m 1 -ff' is now accepted for non-merge commits t3502: validate '-m 1' argument is now accepted for non-merge commits cherry-pick: do not error on non-merge commits when '-m 1' is specified t3510: stop using '-m 1' to force failure mid-sequence of cherry-picks
2 parents 726f89c + 1c32013 commit 77fbd96

4 files changed

Lines changed: 22 additions & 14 deletions

File tree

sequencer.c

Lines changed: 7 additions & 3 deletions

t/t3502-cherry-pick-merge.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ test_expect_success 'cherry-pick -m complains of bogus numbers' '
4040
test_expect_code 129 git cherry-pick -m 0 b
4141
'
4242

43-
test_expect_success 'cherry-pick a non-merge with -m should fail' '
43+
test_expect_success 'cherry-pick explicit first parent of a non-merge' '
4444
4545
git reset --hard &&
4646
git checkout a^0 &&
47-
test_expect_code 128 git cherry-pick -m 1 b &&
48-
git diff --exit-code a --
47+
git cherry-pick -m 1 b &&
48+
git diff --exit-code c --
4949
5050
'
5151

@@ -84,12 +84,12 @@ test_expect_success 'cherry pick a merge relative to nonexistent parent should f
8484
8585
'
8686

87-
test_expect_success 'revert a non-merge with -m should fail' '
87+
test_expect_success 'revert explicit first parent of a non-merge' '
8888
8989
git reset --hard &&
9090
git checkout c^0 &&
91-
test_must_fail git revert -m 1 b &&
92-
git diff --exit-code c
91+
git revert -m 1 b &&
92+
git diff --exit-code a --
9393
9494
'
9595

t/t3506-cherry-pick-ff.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ test_expect_success 'merge setup' '
6464
git checkout -b new A
6565
'
6666

67-
test_expect_success 'cherry-pick a non-merge with --ff and -m should fail' '
67+
test_expect_success 'cherry-pick explicit first parent of a non-merge with --ff' '
6868
git reset --hard A -- &&
69-
test_must_fail git cherry-pick --ff -m 1 B &&
70-
git diff --exit-code A --
69+
git cherry-pick --ff -m 1 B &&
70+
git diff --exit-code C --
7171
'
7272

7373
test_expect_success 'cherry pick a merge with --ff but without -m should fail' '

t/t3510-cherry-pick-sequence.sh

Lines changed: 6 additions & 2 deletions

0 commit comments

Comments
 (0)