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
14 TEST_PASSES_SANITIZE_LEAK
=true
17 test_expect_success setup
'
22 git commit -m "Initial" &&
26 git commit -m "add line to A" A &&
30 git commit -m "add line to B" B &&
38 test_expect_success
'cherry-pick -m complains of bogus numbers' '
39 # expect 129 here to distinguish between cases where
40 # there was nothing to cherry-pick
41 test_expect_code 129 git cherry-pick -m &&
42 test_expect_code 129 git cherry-pick -m foo b &&
43 test_expect_code 129 git cherry-pick -m -1 b &&
44 test_expect_code 129 git cherry-pick -m 0 b
47 test_expect_success
'cherry-pick explicit first parent of a non-merge' '
51 git cherry-pick -m 1 b &&
52 git diff --exit-code c --
56 test_expect_success
'cherry pick a merge without -m should fail' '
60 test_must_fail git cherry-pick c &&
61 git diff --exit-code a --
65 test_expect_success
'cherry pick a merge (1)' '
69 git cherry-pick -m 1 c &&
70 git diff --exit-code c
74 test_expect_success
'cherry pick a merge (2)' '
78 git cherry-pick -m 2 c &&
79 git diff --exit-code c
83 test_expect_success
'cherry pick a merge relative to nonexistent parent should fail' '
87 test_must_fail git cherry-pick -m 3 c
91 test_expect_success
'revert explicit first parent of a non-merge' '
96 git diff --exit-code a --
100 test_expect_success
'revert a merge without -m should fail' '
104 test_must_fail git revert c &&
105 git diff --exit-code c
109 test_expect_success
'revert a merge (1)' '
114 git diff --exit-code a --
118 test_expect_success
'revert a merge (2)' '
123 git diff --exit-code b --
127 test_expect_success
'revert a merge relative to nonexistent parent should fail' '
131 test_must_fail git revert -m 3 c &&
132 git diff --exit-code c