]> git.ipfire.org Git - thirdparty/git.git/blame - t/t3502-cherry-pick-merge.sh
tests: mark tests relying on the current default for `init.defaultBranch`
[thirdparty/git.git] / t / t3502-cherry-pick-merge.sh
CommitLineData
6232b343
JH
1#!/bin/sh
2
3test_description='cherry picking and reverting a merge
4
5 b---c
6 / /
7 initial---a
8
9'
10
334afbc7
JS
11GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master
12export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
13
6232b343
JH
14. ./test-lib.sh
15
16test_expect_success setup '
17
18 >A &&
19 >B &&
20 git add A B &&
21 git commit -m "Initial" &&
22 git tag initial &&
23 git branch side &&
24 echo new line >A &&
25 git commit -m "add line to A" A &&
26 git tag a &&
27 git checkout side &&
28 echo new line >B &&
29 git commit -m "add line to B" B &&
30 git tag b &&
31 git checkout master &&
32 git merge side &&
33 git tag c
34
35'
36
b16a991c
JK
37test_expect_success 'cherry-pick -m complains of bogus numbers' '
38 # expect 129 here to distinguish between cases where
39 # there was nothing to cherry-pick
40 test_expect_code 129 git cherry-pick -m &&
41 test_expect_code 129 git cherry-pick -m foo b &&
42 test_expect_code 129 git cherry-pick -m -1 b &&
43 test_expect_code 129 git cherry-pick -m 0 b
44'
45
4d67b4e4 46test_expect_success 'cherry-pick explicit first parent of a non-merge' '
6232b343
JH
47
48 git reset --hard &&
49 git checkout a^0 &&
4d67b4e4
SO
50 git cherry-pick -m 1 b &&
51 git diff --exit-code c --
6232b343
JH
52
53'
54
55test_expect_success 'cherry pick a merge without -m should fail' '
56
57 git reset --hard &&
58 git checkout a^0 &&
d492b31c 59 test_must_fail git cherry-pick c &&
9f12bec4 60 git diff --exit-code a --
6232b343
JH
61
62'
63
64test_expect_success 'cherry pick a merge (1)' '
65
66 git reset --hard &&
67 git checkout a^0 &&
68 git cherry-pick -m 1 c &&
69 git diff --exit-code c
70
71'
72
73test_expect_success 'cherry pick a merge (2)' '
74
75 git reset --hard &&
76 git checkout b^0 &&
77 git cherry-pick -m 2 c &&
78 git diff --exit-code c
79
80'
81
82test_expect_success 'cherry pick a merge relative to nonexistent parent should fail' '
83
84 git reset --hard &&
85 git checkout b^0 &&
d492b31c 86 test_must_fail git cherry-pick -m 3 c
6232b343
JH
87
88'
89
4d67b4e4 90test_expect_success 'revert explicit first parent of a non-merge' '
6232b343
JH
91
92 git reset --hard &&
93 git checkout c^0 &&
4d67b4e4
SO
94 git revert -m 1 b &&
95 git diff --exit-code a --
6232b343
JH
96
97'
98
99test_expect_success 'revert a merge without -m should fail' '
100
101 git reset --hard &&
102 git checkout c^0 &&
d492b31c 103 test_must_fail git revert c &&
6232b343
JH
104 git diff --exit-code c
105
106'
107
108test_expect_success 'revert a merge (1)' '
109
110 git reset --hard &&
111 git checkout c^0 &&
112 git revert -m 1 c &&
9f12bec4 113 git diff --exit-code a --
6232b343
JH
114
115'
116
117test_expect_success 'revert a merge (2)' '
118
119 git reset --hard &&
120 git checkout c^0 &&
121 git revert -m 2 c &&
9f12bec4 122 git diff --exit-code b --
6232b343
JH
123
124'
125
126test_expect_success 'revert a merge relative to nonexistent parent should fail' '
127
128 git reset --hard &&
129 git checkout c^0 &&
d492b31c 130 test_must_fail git revert -m 3 c &&
6232b343
JH
131 git diff --exit-code c
132
133'
134
135test_done