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
10 test_expect_success setup
'
15 git commit -m "first" &&
17 git symbolic-ref HEAD refs/heads/second &&
18 rm .git/index file1 &&
19 echo second > file2 &&
22 git commit -m "second" &&
24 git symbolic-ref HEAD refs/heads/third &&
25 rm .git/index file2 &&
33 test_expect_success
'cherry-pick a root commit' '
35 git checkout second^0 &&
36 git cherry-pick main &&
42 test_expect_success
'revert a root commit' '
45 test_path_is_missing file1
49 test_expect_success
'cherry-pick a root commit with an external strategy' '
51 git cherry-pick --strategy=resolve main &&
57 test_expect_success
'revert a root commit with an external strategy' '
59 git revert --strategy=resolve main &&
60 test_path_is_missing file1
64 test_expect_success
'cherry-pick two root commits' '
66 echo first >expect.file1 &&
67 echo second >expect.file2 &&
68 echo third >expect.file3 &&
70 git checkout second^0 &&
71 git cherry-pick main third &&
73 test_cmp expect.file1 file1 &&
74 test_cmp expect.file2 file2 &&
75 test_cmp expect.file3 file3 &&
76 git rev-parse --verify HEAD^^ &&
77 test_must_fail git rev-parse --verify HEAD^^^