The eleventh batch
[git/gitster.git] / t / t3503-cherry-pick-root.sh
blob76d393dc8a307ebef13dfab5e4eb3d88a7a7cd69
1 #!/bin/sh
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
9 . ./test-lib.sh
11 test_expect_success setup '
13 echo first > file1 &&
14 git add file1 &&
15 test_tick &&
16 git commit -m "first" &&
18 git symbolic-ref HEAD refs/heads/second &&
19 rm .git/index file1 &&
20 echo second > file2 &&
21 git add file2 &&
22 test_tick &&
23 git commit -m "second" &&
25 git symbolic-ref HEAD refs/heads/third &&
26 rm .git/index file2 &&
27 echo third > file3 &&
28 git add file3 &&
29 test_tick &&
30 git commit -m "third"
34 test_expect_success 'cherry-pick a root commit' '
36 git checkout second^0 &&
37 git cherry-pick main &&
38 echo first >expect &&
39 test_cmp expect file1
43 test_expect_success 'revert a root commit' '
45 git revert main &&
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 &&
53 echo first >expect &&
54 test_cmp expect file1
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^^^
82 test_done