3 test_description
='cherry picking and reverting a merge
11 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
=main
12 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
16 test_expect_success setup
'
21 git commit -m "Initial" &&
25 git commit -m "add line to A" A &&
29 git commit -m "add line to B" B &&
37 test_expect_success
'cherry-pick -m complains of bogus numbers' '
38 # expect 129 here to distinguish between cases where
39 # there was nothing to cherry-pick
40 test_expect_code 129 git cherry-pick -m &&
41 test_expect_code 129 git cherry-pick -m foo b &&
42 test_expect_code 129 git cherry-pick -m -1 b &&
43 test_expect_code 129 git cherry-pick -m 0 b
46 test_expect_success
'cherry-pick explicit first parent of a non-merge' '
50 git cherry-pick -m 1 b &&
51 git diff --exit-code c --
55 test_expect_success
'cherry pick a merge without -m should fail' '
59 test_must_fail git cherry-pick c &&
60 git diff --exit-code a --
64 test_expect_success
'cherry pick a merge (1)' '
68 git cherry-pick -m 1 c &&
69 git diff --exit-code c
73 test_expect_success
'cherry pick a merge (2)' '
77 git cherry-pick -m 2 c &&
78 git diff --exit-code c
82 test_expect_success
'cherry pick a merge relative to nonexistent parent should fail' '
86 test_must_fail git cherry-pick -m 3 c
90 test_expect_success
'revert explicit first parent of a non-merge' '
95 git diff --exit-code a --
99 test_expect_success
'revert a merge without -m should fail' '
103 test_must_fail git revert c &&
104 git diff --exit-code c
108 test_expect_success
'revert a merge (1)' '
113 git diff --exit-code a --
117 test_expect_success
'revert a merge (2)' '
122 git diff --exit-code b --
126 test_expect_success
'revert a merge relative to nonexistent parent should fail' '
130 test_must_fail git revert -m 3 c &&
131 git diff --exit-code c