string-list.[ch]: add a string_list_init_{nodup,dup}()
[git.git] / t / t3503-cherry-pick-root.sh
blob95fe4feaeee98f6432b39ee3a4817f05da5d649b
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-lib.sh
10 test_expect_success setup '
12 echo first > file1 &&
13 git add file1 &&
14 test_tick &&
15 git commit -m "first" &&
17 git symbolic-ref HEAD refs/heads/second &&
18 rm .git/index file1 &&
19 echo second > file2 &&
20 git add file2 &&
21 test_tick &&
22 git commit -m "second" &&
24 git symbolic-ref HEAD refs/heads/third &&
25 rm .git/index file2 &&
26 echo third > file3 &&
27 git add file3 &&
28 test_tick &&
29 git commit -m "third"
33 test_expect_success 'cherry-pick a root commit' '
35 git checkout second^0 &&
36 git cherry-pick main &&
37 echo first >expect &&
38 test_cmp expect file1
42 test_expect_success 'revert a root commit' '
44 git revert main &&
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 &&
52 echo first >expect &&
53 test_cmp expect file1
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^^^
81 test_done