]> git.ipfire.org Git - thirdparty/git.git/blame - t/t3503-cherry-pick-root.sh
Merge branch 'fc/remove-header-workarounds-for-asciidoc'
[thirdparty/git.git] / t / t3503-cherry-pick-root.sh
CommitLineData
f95ebf74
JS
1#!/bin/sh
2
e9fe74cb 3test_description='test cherry-picking (and reverting) a root commit'
f95ebf74 4
cbc75a12 5GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
334afbc7
JS
6export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
7
9ff2f060 8TEST_PASSES_SANITIZE_LEAK=true
f95ebf74
JS
9. ./test-lib.sh
10
11test_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 &&
127f0452
JN
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"
f95ebf74
JS
31
32'
33
34test_expect_success 'cherry-pick a root commit' '
35
127f0452 36 git checkout second^0 &&
cbc75a12 37 git cherry-pick main &&
e9fe74cb
JK
38 echo first >expect &&
39 test_cmp expect file1
40
41'
42
43test_expect_success 'revert a root commit' '
44
cbc75a12 45 git revert main &&
e9fe74cb
JK
46 test_path_is_missing file1
47
48'
49
50test_expect_success 'cherry-pick a root commit with an external strategy' '
51
cbc75a12 52 git cherry-pick --strategy=resolve main &&
e9fe74cb
JK
53 echo first >expect &&
54 test_cmp expect file1
55
56'
57
58test_expect_success 'revert a root commit with an external strategy' '
59
cbc75a12 60 git revert --strategy=resolve main &&
e9fe74cb 61 test_path_is_missing file1
f95ebf74
JS
62
63'
64
127f0452
JN
65test_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 &&
cbc75a12 72 git cherry-pick main third &&
127f0452
JN
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
f95ebf74 82test_done