3 test_description
='test cherry-picking (and reverting) a root commit'
5 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
=main
6 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
8 TEST_PASSES_SANITIZE_LEAK
=true
11 test_expect_success setup
'
16 git commit -m "first" &&
18 git symbolic-ref HEAD refs/heads/second &&
19 rm .git/index file1 &&
20 echo second > file2 &&
23 git commit -m "second" &&
25 git symbolic-ref HEAD refs/heads/third &&
26 rm .git/index file2 &&
34 test_expect_success
'cherry-pick a root commit' '
36 git checkout second^0 &&
37 git cherry-pick main &&
43 test_expect_success
'revert a root commit' '
46 test_path_is_missing file1
50 test_expect_success
'cherry-pick a root commit with an external strategy' '
52 git cherry-pick --strategy=resolve main &&
58 test_expect_success
'revert a root commit with an external strategy' '
60 git revert --strategy=resolve main &&
61 test_path_is_missing file1
65 test_expect_success
'cherry-pick two root commits' '
67 echo first >expect.file1 &&
68 echo second >expect.file2 &&
69 echo third >expect.file3 &&
71 git checkout second^0 &&
72 git cherry-pick main third &&
74 test_cmp expect.file1 file1 &&
75 test_cmp expect.file2 file2 &&
76 test_cmp expect.file3 file3 &&
77 git rev-parse --verify HEAD^^ &&
78 test_must_fail git rev-parse --verify HEAD^^^