]> git.ipfire.org Git - thirdparty/git.git/blob - t/t3503-cherry-pick-root.sh
The third batch
[thirdparty/git.git] / t / t3503-cherry-pick-root.sh
1 #!/bin/sh
2
3 test_description='test cherry-picking (and reverting) a root commit'
4
5 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
6 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
7
8 TEST_PASSES_SANITIZE_LEAK=true
9 . ./test-lib.sh
10
11 test_expect_success setup '
12
13 echo first > file1 &&
14 git add file1 &&
15 test_tick &&
16 git commit -m "first" &&
17
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" &&
24
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"
31
32 '
33
34 test_expect_success 'cherry-pick a root commit' '
35
36 git checkout second^0 &&
37 git cherry-pick main &&
38 echo first >expect &&
39 test_cmp expect file1
40
41 '
42
43 test_expect_success 'revert a root commit' '
44
45 git revert main &&
46 test_path_is_missing file1
47
48 '
49
50 test_expect_success 'cherry-pick a root commit with an external strategy' '
51
52 git cherry-pick --strategy=resolve main &&
53 echo first >expect &&
54 test_cmp expect file1
55
56 '
57
58 test_expect_success 'revert a root commit with an external strategy' '
59
60 git revert --strategy=resolve main &&
61 test_path_is_missing file1
62
63 '
64
65 test_expect_success 'cherry-pick two root commits' '
66
67 echo first >expect.file1 &&
68 echo second >expect.file2 &&
69 echo third >expect.file3 &&
70
71 git checkout second^0 &&
72 git cherry-pick main third &&
73
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^^^
79
80 '
81
82 test_done