]>
Commit | Line | Data |
---|---|---|
aa29ccf4 CC |
1 | #!/bin/sh |
2 | ||
3 | test_description='test cherry-picking many commits' | |
4 | ||
5 | . ./test-lib.sh | |
6 | ||
6bc83cdd | 7 | check_head_differs_from() { |
5d77298d | 8 | ! test_cmp_rev HEAD "$1" |
6bc83cdd CC |
9 | } |
10 | ||
11 | check_head_equals() { | |
5d77298d | 12 | test_cmp_rev HEAD "$1" |
6bc83cdd CC |
13 | } |
14 | ||
aa29ccf4 CC |
15 | test_expect_success setup ' |
16 | echo first > file1 && | |
17 | git add file1 && | |
18 | test_tick && | |
19 | git commit -m "first" && | |
20 | git tag first && | |
21 | ||
22 | git checkout -b other && | |
23 | for val in second third fourth | |
24 | do | |
25 | echo $val >> file1 && | |
26 | git add file1 && | |
27 | test_tick && | |
28 | git commit -m "$val" && | |
29 | git tag $val | |
30 | done | |
31 | ' | |
32 | ||
33 | test_expect_success 'cherry-pick first..fourth works' ' | |
2593633f JN |
34 | git checkout -f master && |
35 | git reset --hard first && | |
36 | test_tick && | |
37 | git cherry-pick first..fourth && | |
38 | git diff --quiet other && | |
39 | git diff --quiet HEAD other && | |
40 | check_head_differs_from fourth | |
41 | ' | |
42 | ||
a73e22e9 | 43 | test_expect_success 'cherry-pick three one two works' ' |
d023c248 MZ |
44 | git checkout -f first && |
45 | test_commit one && | |
46 | test_commit two && | |
47 | test_commit three && | |
48 | git checkout -f master && | |
49 | git reset --hard first && | |
50 | git cherry-pick three one two && | |
51 | git diff --quiet three && | |
52 | git diff --quiet HEAD three && | |
53 | test "$(git log --reverse --format=%s first..)" = "three | |
54 | one | |
55 | two" | |
56 | ' | |
57 | ||
21246dbb MV |
58 | test_expect_success 'cherry-pick three one two: fails' ' |
59 | git checkout -f master && | |
60 | git reset --hard first && | |
61 | test_must_fail git cherry-pick three one two: | |
62 | ' | |
63 | ||
2593633f | 64 | test_expect_success 'output to keep user entertained during multi-pick' ' |
130ab8ab JN |
65 | cat <<-\EOF >expected && |
66 | [master OBJID] second | |
67 | Author: A U Thor <author@example.com> | |
b7242b8c | 68 | Date: Thu Apr 7 15:14:13 2005 -0700 |
7f814632 | 69 | 1 file changed, 1 insertion(+) |
130ab8ab JN |
70 | [master OBJID] third |
71 | Author: A U Thor <author@example.com> | |
b7242b8c | 72 | Date: Thu Apr 7 15:15:13 2005 -0700 |
7f814632 | 73 | 1 file changed, 1 insertion(+) |
130ab8ab JN |
74 | [master OBJID] fourth |
75 | Author: A U Thor <author@example.com> | |
b7242b8c | 76 | Date: Thu Apr 7 15:16:13 2005 -0700 |
7f814632 | 77 | 1 file changed, 1 insertion(+) |
7b53b92f CC |
78 | EOF |
79 | ||
80 | git checkout -f master && | |
81 | git reset --hard first && | |
82 | test_tick && | |
130ab8ab | 83 | git cherry-pick first..fourth >actual && |
2593633f JN |
84 | sed -e "s/$_x05[0-9a-f][0-9a-f]/OBJID/" <actual >actual.fuzzy && |
85 | test_line_count -ge 3 actual.fuzzy && | |
86 | test_i18ncmp expected actual.fuzzy | |
87 | ' | |
88 | ||
89 | test_expect_success 'cherry-pick --strategy resolve first..fourth works' ' | |
90 | git checkout -f master && | |
91 | git reset --hard first && | |
92 | test_tick && | |
93 | git cherry-pick --strategy resolve first..fourth && | |
7b53b92f CC |
94 | git diff --quiet other && |
95 | git diff --quiet HEAD other && | |
6bc83cdd | 96 | check_head_differs_from fourth |
7b53b92f CC |
97 | ' |
98 | ||
2593633f | 99 | test_expect_success 'output during multi-pick indicates merge strategy' ' |
130ab8ab JN |
100 | cat <<-\EOF >expected && |
101 | Trying simple merge. | |
102 | [master OBJID] second | |
103 | Author: A U Thor <author@example.com> | |
b7242b8c | 104 | Date: Thu Apr 7 15:14:13 2005 -0700 |
7f814632 | 105 | 1 file changed, 1 insertion(+) |
130ab8ab JN |
106 | Trying simple merge. |
107 | [master OBJID] third | |
108 | Author: A U Thor <author@example.com> | |
b7242b8c | 109 | Date: Thu Apr 7 15:15:13 2005 -0700 |
7f814632 | 110 | 1 file changed, 1 insertion(+) |
130ab8ab JN |
111 | Trying simple merge. |
112 | [master OBJID] fourth | |
113 | Author: A U Thor <author@example.com> | |
b7242b8c | 114 | Date: Thu Apr 7 15:16:13 2005 -0700 |
7f814632 | 115 | 1 file changed, 1 insertion(+) |
7b53b92f CC |
116 | EOF |
117 | ||
18c8ff46 | 118 | git checkout -f master && |
aa29ccf4 CC |
119 | git reset --hard first && |
120 | test_tick && | |
130ab8ab | 121 | git cherry-pick --strategy resolve first..fourth >actual && |
130ab8ab | 122 | sed -e "s/$_x05[0-9a-f][0-9a-f]/OBJID/" <actual >actual.fuzzy && |
2593633f | 123 | test_i18ncmp expected actual.fuzzy |
aa29ccf4 CC |
124 | ' |
125 | ||
126 | test_expect_success 'cherry-pick --ff first..fourth works' ' | |
18c8ff46 | 127 | git checkout -f master && |
aa29ccf4 CC |
128 | git reset --hard first && |
129 | test_tick && | |
130 | git cherry-pick --ff first..fourth && | |
131 | git diff --quiet other && | |
132 | git diff --quiet HEAD other && | |
6bc83cdd | 133 | check_head_equals fourth |
aa29ccf4 CC |
134 | ' |
135 | ||
136 | test_expect_success 'cherry-pick -n first..fourth works' ' | |
18c8ff46 | 137 | git checkout -f master && |
aa29ccf4 CC |
138 | git reset --hard first && |
139 | test_tick && | |
140 | git cherry-pick -n first..fourth && | |
141 | git diff --quiet other && | |
142 | git diff --cached --quiet other && | |
143 | git diff --quiet HEAD first | |
144 | ' | |
145 | ||
146 | test_expect_success 'revert first..fourth works' ' | |
18c8ff46 | 147 | git checkout -f master && |
aa29ccf4 CC |
148 | git reset --hard fourth && |
149 | test_tick && | |
150 | git revert first..fourth && | |
151 | git diff --quiet first && | |
152 | git diff --cached --quiet first && | |
153 | git diff --quiet HEAD first | |
154 | ' | |
155 | ||
156 | test_expect_success 'revert ^first fourth works' ' | |
18c8ff46 | 157 | git checkout -f master && |
aa29ccf4 CC |
158 | git reset --hard fourth && |
159 | test_tick && | |
160 | git revert ^first fourth && | |
161 | git diff --quiet first && | |
162 | git diff --cached --quiet first && | |
163 | git diff --quiet HEAD first | |
164 | ' | |
165 | ||
166 | test_expect_success 'revert fourth fourth~1 fourth~2 works' ' | |
18c8ff46 | 167 | git checkout -f master && |
aa29ccf4 CC |
168 | git reset --hard fourth && |
169 | test_tick && | |
170 | git revert fourth fourth~1 fourth~2 && | |
171 | git diff --quiet first && | |
172 | git diff --cached --quiet first && | |
173 | git diff --quiet HEAD first | |
174 | ' | |
175 | ||
65281b70 | 176 | test_expect_success 'cherry-pick -3 fourth works' ' |
18c8ff46 | 177 | git checkout -f master && |
aa29ccf4 CC |
178 | git reset --hard first && |
179 | test_tick && | |
180 | git cherry-pick -3 fourth && | |
181 | git diff --quiet other && | |
182 | git diff --quiet HEAD other && | |
6bc83cdd | 183 | check_head_differs_from fourth |
aa29ccf4 CC |
184 | ' |
185 | ||
f873a273 CC |
186 | test_expect_success 'cherry-pick --stdin works' ' |
187 | git checkout -f master && | |
188 | git reset --hard first && | |
189 | test_tick && | |
190 | git rev-list --reverse first..fourth | git cherry-pick --stdin && | |
191 | git diff --quiet other && | |
192 | git diff --quiet HEAD other && | |
6bc83cdd | 193 | check_head_differs_from fourth |
f873a273 CC |
194 | ' |
195 | ||
aa29ccf4 | 196 | test_done |