Blame


1 069bbb86 2022-03-07 thomas #!/bin/sh
2 069bbb86 2022-03-07 thomas #
3 069bbb86 2022-03-07 thomas # Copyright (c) 2022 Omar Polo <op@openbsd.org>
4 069bbb86 2022-03-07 thomas #
5 069bbb86 2022-03-07 thomas # Permission to use, copy, modify, and distribute this software for any
6 069bbb86 2022-03-07 thomas # purpose with or without fee is hereby granted, provided that the above
7 069bbb86 2022-03-07 thomas # copyright notice and this permission notice appear in all copies.
8 069bbb86 2022-03-07 thomas #
9 069bbb86 2022-03-07 thomas # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 069bbb86 2022-03-07 thomas # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 069bbb86 2022-03-07 thomas # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 069bbb86 2022-03-07 thomas # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 069bbb86 2022-03-07 thomas # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 069bbb86 2022-03-07 thomas # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 069bbb86 2022-03-07 thomas # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 069bbb86 2022-03-07 thomas
17 069bbb86 2022-03-07 thomas . ./common.sh
18 069bbb86 2022-03-07 thomas
19 8d8dc2a3 2022-07-03 thomas test_patch_add_file() {
20 8d8dc2a3 2022-07-03 thomas local testroot=`test_init patch_add_file`
21 069bbb86 2022-03-07 thomas
22 069bbb86 2022-03-07 thomas got checkout $testroot/repo $testroot/wt > /dev/null
23 069bbb86 2022-03-07 thomas ret=$?
24 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
25 069bbb86 2022-03-07 thomas test_done $testroot $ret
26 069bbb86 2022-03-07 thomas return 1
27 069bbb86 2022-03-07 thomas fi
28 069bbb86 2022-03-07 thomas
29 069bbb86 2022-03-07 thomas cat <<EOF > $testroot/wt/patch
30 069bbb86 2022-03-07 thomas --- /dev/null
31 069bbb86 2022-03-07 thomas +++ eta
32 8d8dc2a3 2022-07-03 thomas @@ -0,0 +5,5 @@
33 8d8dc2a3 2022-07-03 thomas +1
34 8d8dc2a3 2022-07-03 thomas +2
35 8d8dc2a3 2022-07-03 thomas +3
36 8d8dc2a3 2022-07-03 thomas +4
37 8d8dc2a3 2022-07-03 thomas +5
38 069bbb86 2022-03-07 thomas EOF
39 069bbb86 2022-03-07 thomas
40 069bbb86 2022-03-07 thomas (cd $testroot/wt && got patch patch) > $testroot/stdout
41 069bbb86 2022-03-07 thomas ret=$?
42 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
43 069bbb86 2022-03-07 thomas test_done $testroot $ret
44 069bbb86 2022-03-07 thomas return 1
45 069bbb86 2022-03-07 thomas fi
46 069bbb86 2022-03-07 thomas
47 069bbb86 2022-03-07 thomas echo "A eta" > $testroot/stdout.expected
48 069bbb86 2022-03-07 thomas cmp -s $testroot/stdout.expected $testroot/stdout
49 069bbb86 2022-03-07 thomas ret=$?
50 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
51 069bbb86 2022-03-07 thomas diff -u $testroot/stdout.expected $testroot/stdout
52 069bbb86 2022-03-07 thomas test_done $testroot $ret
53 069bbb86 2022-03-07 thomas return 1
54 069bbb86 2022-03-07 thomas fi
55 069bbb86 2022-03-07 thomas
56 8d8dc2a3 2022-07-03 thomas jot 5 > $testroot/wt/eta.expected
57 069bbb86 2022-03-07 thomas cmp -s $testroot/wt/eta.expected $testroot/wt/eta
58 069bbb86 2022-03-07 thomas ret=$?
59 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
60 069bbb86 2022-03-07 thomas diff -u $testroot/wt/eta.expected $testroot/wt/eta
61 069bbb86 2022-03-07 thomas fi
62 069bbb86 2022-03-07 thomas test_done $testroot $ret
63 069bbb86 2022-03-07 thomas }
64 069bbb86 2022-03-07 thomas
65 762e07b8 2022-07-03 thomas test_patch_rm_file() {
66 762e07b8 2022-07-03 thomas local testroot=`test_init patch_rm_file`
67 069bbb86 2022-03-07 thomas
68 069bbb86 2022-03-07 thomas got checkout $testroot/repo $testroot/wt > /dev/null
69 069bbb86 2022-03-07 thomas ret=$?
70 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
71 069bbb86 2022-03-07 thomas test_done $testroot $ret
72 069bbb86 2022-03-07 thomas return 1
73 069bbb86 2022-03-07 thomas fi
74 069bbb86 2022-03-07 thomas
75 069bbb86 2022-03-07 thomas cat <<EOF > $testroot/wt/patch
76 069bbb86 2022-03-07 thomas --- alpha
77 069bbb86 2022-03-07 thomas +++ /dev/null
78 069bbb86 2022-03-07 thomas @@ -1 +0,0 @@
79 069bbb86 2022-03-07 thomas -alpha
80 069bbb86 2022-03-07 thomas EOF
81 069bbb86 2022-03-07 thomas
82 069bbb86 2022-03-07 thomas echo "D alpha" > $testroot/stdout.expected
83 069bbb86 2022-03-07 thomas
84 069bbb86 2022-03-07 thomas (cd $testroot/wt && got patch patch) > $testroot/stdout
85 069bbb86 2022-03-07 thomas ret=$?
86 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
87 069bbb86 2022-03-07 thomas test_done $testroot $ret
88 069bbb86 2022-03-07 thomas return 1
89 069bbb86 2022-03-07 thomas fi
90 069bbb86 2022-03-07 thomas
91 069bbb86 2022-03-07 thomas cmp -s $testroot/stdout.expected $testroot/stdout
92 069bbb86 2022-03-07 thomas ret=$?
93 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
94 069bbb86 2022-03-07 thomas diff -u $testroot/stdout.expected $testroot/stdout
95 069bbb86 2022-03-07 thomas test_done $testroot $ret
96 069bbb86 2022-03-07 thomas return 1
97 069bbb86 2022-03-07 thomas fi
98 069bbb86 2022-03-07 thomas
99 069bbb86 2022-03-07 thomas if [ -f $testroot/wt/alpha ]; then
100 069bbb86 2022-03-07 thomas ret=1
101 069bbb86 2022-03-07 thomas echo "alpha still exists!"
102 069bbb86 2022-03-07 thomas fi
103 069bbb86 2022-03-07 thomas test_done $testroot $ret
104 069bbb86 2022-03-07 thomas }
105 069bbb86 2022-03-07 thomas
106 069bbb86 2022-03-07 thomas test_patch_simple_edit_file() {
107 069bbb86 2022-03-07 thomas local testroot=`test_init patch_simple_edit_file`
108 069bbb86 2022-03-07 thomas
109 069bbb86 2022-03-07 thomas got checkout $testroot/repo $testroot/wt > /dev/null
110 069bbb86 2022-03-07 thomas ret=$?
111 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
112 069bbb86 2022-03-07 thomas test_done $testroot $ret
113 069bbb86 2022-03-07 thomas return 1
114 069bbb86 2022-03-07 thomas fi
115 069bbb86 2022-03-07 thomas
116 069bbb86 2022-03-07 thomas cat <<EOF > $testroot/wt/patch
117 069bbb86 2022-03-07 thomas --- alpha
118 069bbb86 2022-03-07 thomas +++ alpha
119 069bbb86 2022-03-07 thomas @@ -1 +1 @@
120 069bbb86 2022-03-07 thomas -alpha
121 069bbb86 2022-03-07 thomas +alpha is my favourite character
122 069bbb86 2022-03-07 thomas EOF
123 069bbb86 2022-03-07 thomas
124 069bbb86 2022-03-07 thomas echo "M alpha" > $testroot/stdout.expected
125 069bbb86 2022-03-07 thomas
126 069bbb86 2022-03-07 thomas (cd $testroot/wt && got patch patch) > $testroot/stdout
127 069bbb86 2022-03-07 thomas ret=$?
128 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
129 069bbb86 2022-03-07 thomas test_done $testroot $ret
130 069bbb86 2022-03-07 thomas return 1
131 069bbb86 2022-03-07 thomas fi
132 069bbb86 2022-03-07 thomas
133 069bbb86 2022-03-07 thomas cmp -s $testroot/stdout.expected $testroot/stdout
134 069bbb86 2022-03-07 thomas ret=$?
135 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
136 069bbb86 2022-03-07 thomas diff -u $testroot/stdout.expected $testroot/stdout
137 069bbb86 2022-03-07 thomas test_done $testroot $ret
138 069bbb86 2022-03-07 thomas return 1
139 069bbb86 2022-03-07 thomas fi
140 069bbb86 2022-03-07 thomas
141 069bbb86 2022-03-07 thomas echo 'alpha is my favourite character' > $testroot/wt/alpha.expected
142 069bbb86 2022-03-07 thomas cmp -s $testroot/wt/alpha.expected $testroot/wt/alpha
143 069bbb86 2022-03-07 thomas ret=$?
144 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
145 069bbb86 2022-03-07 thomas diff -u $testroot/wt/alpha.expected $testroot/wt/alpha
146 069bbb86 2022-03-07 thomas fi
147 069bbb86 2022-03-07 thomas test_done $testroot $ret
148 069bbb86 2022-03-07 thomas }
149 069bbb86 2022-03-07 thomas
150 069bbb86 2022-03-07 thomas test_patch_prepend_line() {
151 069bbb86 2022-03-07 thomas local testroot=`test_init patch_prepend_line`
152 069bbb86 2022-03-07 thomas
153 069bbb86 2022-03-07 thomas got checkout $testroot/repo $testroot/wt > /dev/null
154 069bbb86 2022-03-07 thomas ret=$?
155 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
156 069bbb86 2022-03-07 thomas test_done $testroot $ret
157 069bbb86 2022-03-07 thomas return 1
158 069bbb86 2022-03-07 thomas fi
159 069bbb86 2022-03-07 thomas
160 069bbb86 2022-03-07 thomas cat <<EOF > $testroot/wt/patch
161 069bbb86 2022-03-07 thomas --- alpha
162 069bbb86 2022-03-07 thomas +++ alpha
163 069bbb86 2022-03-07 thomas @@ -1 +1,2 @@
164 069bbb86 2022-03-07 thomas +hatsuseno
165 069bbb86 2022-03-07 thomas alpha
166 069bbb86 2022-03-07 thomas EOF
167 069bbb86 2022-03-07 thomas
168 069bbb86 2022-03-07 thomas echo "M alpha" > $testroot/stdout.expected
169 069bbb86 2022-03-07 thomas
170 069bbb86 2022-03-07 thomas (cd $testroot/wt && got patch patch) > $testroot/stdout
171 069bbb86 2022-03-07 thomas ret=$?
172 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
173 069bbb86 2022-03-07 thomas test_done $testroot $ret
174 069bbb86 2022-03-07 thomas return 1
175 069bbb86 2022-03-07 thomas fi
176 069bbb86 2022-03-07 thomas
177 069bbb86 2022-03-07 thomas cmp -s $testroot/stdout.expected $testroot/stdout
178 069bbb86 2022-03-07 thomas ret=$?
179 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
180 069bbb86 2022-03-07 thomas diff -u $testroot/stdout.expected $testroot/stdout
181 069bbb86 2022-03-07 thomas test_done $testroot $ret
182 069bbb86 2022-03-07 thomas return 1
183 069bbb86 2022-03-07 thomas fi
184 069bbb86 2022-03-07 thomas
185 069bbb86 2022-03-07 thomas echo hatsuseno > $testroot/wt/alpha.expected
186 069bbb86 2022-03-07 thomas echo alpha >> $testroot/wt/alpha.expected
187 069bbb86 2022-03-07 thomas cmp -s $testroot/wt/alpha.expected $testroot/wt/alpha
188 069bbb86 2022-03-07 thomas ret=$?
189 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
190 069bbb86 2022-03-07 thomas diff -u $testroot/wt/alpha.expected $testroot/wt/alpha
191 069bbb86 2022-03-07 thomas fi
192 069bbb86 2022-03-07 thomas test_done $testroot $ret
193 069bbb86 2022-03-07 thomas }
194 069bbb86 2022-03-07 thomas
195 069bbb86 2022-03-07 thomas test_patch_replace_line() {
196 069bbb86 2022-03-07 thomas local testroot=`test_init patch_replace_line`
197 069bbb86 2022-03-07 thomas
198 069bbb86 2022-03-07 thomas got checkout $testroot/repo $testroot/wt > /dev/null
199 069bbb86 2022-03-07 thomas ret=$?
200 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
201 069bbb86 2022-03-07 thomas test_done $testroot $ret
202 069bbb86 2022-03-07 thomas return 1
203 069bbb86 2022-03-07 thomas fi
204 069bbb86 2022-03-07 thomas
205 069bbb86 2022-03-07 thomas jot 10 > $testroot/wt/numbers
206 069bbb86 2022-03-07 thomas (cd $testroot/wt/ && got add numbers && got ci -m 'add numbers') \
207 069bbb86 2022-03-07 thomas >/dev/null
208 069bbb86 2022-03-07 thomas ret=$?
209 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
210 069bbb86 2022-03-07 thomas test_done $testroot $ret
211 069bbb86 2022-03-07 thomas return 1
212 069bbb86 2022-03-07 thomas fi
213 069bbb86 2022-03-07 thomas
214 069bbb86 2022-03-07 thomas cat <<EOF > $testroot/wt/patch
215 069bbb86 2022-03-07 thomas --- numbers
216 069bbb86 2022-03-07 thomas +++ numbers
217 069bbb86 2022-03-07 thomas @@ -3,7 +3,7 @@
218 069bbb86 2022-03-07 thomas 3
219 069bbb86 2022-03-07 thomas 4
220 069bbb86 2022-03-07 thomas 5
221 069bbb86 2022-03-07 thomas -6
222 069bbb86 2022-03-07 thomas +foo
223 069bbb86 2022-03-07 thomas 7
224 069bbb86 2022-03-07 thomas 8
225 069bbb86 2022-03-07 thomas 9
226 069bbb86 2022-03-07 thomas EOF
227 069bbb86 2022-03-07 thomas
228 069bbb86 2022-03-07 thomas echo "M numbers" > $testroot/stdout.expected
229 069bbb86 2022-03-07 thomas
230 069bbb86 2022-03-07 thomas (cd $testroot/wt && got patch patch) > $testroot/stdout
231 069bbb86 2022-03-07 thomas ret=$?
232 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
233 069bbb86 2022-03-07 thomas test_done $testroot $ret
234 069bbb86 2022-03-07 thomas return 1
235 069bbb86 2022-03-07 thomas fi
236 069bbb86 2022-03-07 thomas
237 069bbb86 2022-03-07 thomas cmp -s $testroot/stdout.expected $testroot/stdout
238 069bbb86 2022-03-07 thomas ret=$?
239 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
240 069bbb86 2022-03-07 thomas diff -u $testroot/stdout.expected $testroot/stdout
241 069bbb86 2022-03-07 thomas test_done $testroot $ret
242 069bbb86 2022-03-07 thomas return 1
243 069bbb86 2022-03-07 thomas fi
244 069bbb86 2022-03-07 thomas
245 069bbb86 2022-03-07 thomas jot 10 | sed 's/6/foo/' > $testroot/wt/numbers.expected
246 069bbb86 2022-03-07 thomas cmp -s $testroot/wt/numbers.expected $testroot/wt/numbers
247 069bbb86 2022-03-07 thomas ret=$?
248 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
249 069bbb86 2022-03-07 thomas diff -u $testroot/wt/numbers.expected $testroot/wt/numbers
250 069bbb86 2022-03-07 thomas fi
251 069bbb86 2022-03-07 thomas test_done $testroot $ret
252 069bbb86 2022-03-07 thomas }
253 069bbb86 2022-03-07 thomas
254 069bbb86 2022-03-07 thomas test_patch_multiple_hunks() {
255 02e4f0d8 2022-03-08 thomas local testroot=`test_init patch_replace_multiple_hunks`
256 069bbb86 2022-03-07 thomas
257 069bbb86 2022-03-07 thomas got checkout $testroot/repo $testroot/wt > /dev/null
258 069bbb86 2022-03-07 thomas ret=$?
259 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
260 069bbb86 2022-03-07 thomas test_done $testroot $ret
261 069bbb86 2022-03-07 thomas return 1
262 069bbb86 2022-03-07 thomas fi
263 069bbb86 2022-03-07 thomas
264 069bbb86 2022-03-07 thomas jot 100 > $testroot/wt/numbers
265 069bbb86 2022-03-07 thomas (cd $testroot/wt/ && got add numbers && got ci -m 'add numbers') \
266 069bbb86 2022-03-07 thomas >/dev/null
267 069bbb86 2022-03-07 thomas ret=$?
268 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
269 069bbb86 2022-03-07 thomas test_done $testroot $ret
270 069bbb86 2022-03-07 thomas return 1
271 069bbb86 2022-03-07 thomas fi
272 069bbb86 2022-03-07 thomas
273 069bbb86 2022-03-07 thomas cat <<EOF > $testroot/wt/patch
274 069bbb86 2022-03-07 thomas --- numbers
275 069bbb86 2022-03-07 thomas +++ numbers
276 069bbb86 2022-03-07 thomas @@ -3,7 +3,7 @@
277 069bbb86 2022-03-07 thomas 3
278 069bbb86 2022-03-07 thomas 4
279 069bbb86 2022-03-07 thomas 5
280 069bbb86 2022-03-07 thomas -6
281 069bbb86 2022-03-07 thomas +foo
282 069bbb86 2022-03-07 thomas 7
283 069bbb86 2022-03-07 thomas 8
284 069bbb86 2022-03-07 thomas 9
285 069bbb86 2022-03-07 thomas @@ -57,7 +57,7 @@
286 069bbb86 2022-03-07 thomas 57
287 069bbb86 2022-03-07 thomas 58
288 069bbb86 2022-03-07 thomas 59
289 069bbb86 2022-03-07 thomas -60
290 069bbb86 2022-03-07 thomas +foo foo
291 069bbb86 2022-03-07 thomas 61
292 069bbb86 2022-03-07 thomas 62
293 069bbb86 2022-03-07 thomas 63
294 069bbb86 2022-03-07 thomas @@ -98,3 +98,6 @@
295 069bbb86 2022-03-07 thomas 98
296 069bbb86 2022-03-07 thomas 99
297 069bbb86 2022-03-07 thomas 100
298 069bbb86 2022-03-07 thomas +101
299 069bbb86 2022-03-07 thomas +102
300 069bbb86 2022-03-07 thomas +...
301 069bbb86 2022-03-07 thomas EOF
302 069bbb86 2022-03-07 thomas
303 069bbb86 2022-03-07 thomas echo "M numbers" > $testroot/stdout.expected
304 069bbb86 2022-03-07 thomas
305 069bbb86 2022-03-07 thomas (cd $testroot/wt && got patch patch) > $testroot/stdout
306 069bbb86 2022-03-07 thomas ret=$?
307 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
308 069bbb86 2022-03-07 thomas test_done $testroot $ret
309 069bbb86 2022-03-07 thomas return 1
310 069bbb86 2022-03-07 thomas fi
311 069bbb86 2022-03-07 thomas
312 069bbb86 2022-03-07 thomas cmp -s $testroot/stdout.expected $testroot/stdout
313 069bbb86 2022-03-07 thomas ret=$?
314 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
315 069bbb86 2022-03-07 thomas diff -u $testroot/stdout.expected $testroot/stdout
316 069bbb86 2022-03-07 thomas test_done $testroot $ret
317 069bbb86 2022-03-07 thomas return 1
318 069bbb86 2022-03-07 thomas fi
319 069bbb86 2022-03-07 thomas
320 069bbb86 2022-03-07 thomas jot 100 | sed -e 's/^6$/foo/' -e 's/^60$/foo foo/' \
321 069bbb86 2022-03-07 thomas > $testroot/wt/numbers.expected
322 069bbb86 2022-03-07 thomas echo "101" >> $testroot/wt/numbers.expected
323 069bbb86 2022-03-07 thomas echo "102" >> $testroot/wt/numbers.expected
324 069bbb86 2022-03-07 thomas echo "..." >> $testroot/wt/numbers.expected
325 069bbb86 2022-03-07 thomas
326 069bbb86 2022-03-07 thomas cmp -s $testroot/wt/numbers.expected $testroot/wt/numbers
327 069bbb86 2022-03-07 thomas ret=$?
328 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
329 069bbb86 2022-03-07 thomas diff -u $testroot/wt/numbers.expected $testroot/wt/numbers
330 069bbb86 2022-03-07 thomas fi
331 069bbb86 2022-03-07 thomas test_done $testroot $ret
332 069bbb86 2022-03-07 thomas }
333 069bbb86 2022-03-07 thomas
334 069bbb86 2022-03-07 thomas test_patch_multiple_files() {
335 069bbb86 2022-03-07 thomas local testroot=`test_init patch_multiple_files`
336 069bbb86 2022-03-07 thomas
337 069bbb86 2022-03-07 thomas got checkout $testroot/repo $testroot/wt > /dev/null
338 069bbb86 2022-03-07 thomas ret=$?
339 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
340 069bbb86 2022-03-07 thomas test_done $testroot $ret
341 069bbb86 2022-03-07 thomas return 1
342 069bbb86 2022-03-07 thomas fi
343 069bbb86 2022-03-07 thomas
344 069bbb86 2022-03-07 thomas cat <<EOF > $testroot/wt/patch
345 069bbb86 2022-03-07 thomas --- alpha Mon Mar 7 19:02:07 2022
346 069bbb86 2022-03-07 thomas +++ alpha Mon Mar 7 19:01:53 2022
347 069bbb86 2022-03-07 thomas @@ -1 +1,3 @@
348 069bbb86 2022-03-07 thomas +new
349 069bbb86 2022-03-07 thomas alpha
350 069bbb86 2022-03-07 thomas +available
351 069bbb86 2022-03-07 thomas --- beta Mon Mar 7 19:02:11 2022
352 069bbb86 2022-03-07 thomas +++ beta Mon Mar 7 19:01:46 2022
353 069bbb86 2022-03-07 thomas @@ -1 +1,3 @@
354 069bbb86 2022-03-07 thomas beta
355 069bbb86 2022-03-07 thomas +was
356 069bbb86 2022-03-07 thomas +improved
357 069bbb86 2022-03-07 thomas --- gamma/delta Mon Mar 7 19:02:17 2022
358 069bbb86 2022-03-07 thomas +++ gamma/delta Mon Mar 7 19:01:37 2022
359 069bbb86 2022-03-07 thomas @@ -1 +1 @@
360 069bbb86 2022-03-07 thomas -delta
361 069bbb86 2022-03-07 thomas +delta new
362 069bbb86 2022-03-07 thomas EOF
363 069bbb86 2022-03-07 thomas
364 069bbb86 2022-03-07 thomas echo "M alpha" > $testroot/stdout.expected
365 069bbb86 2022-03-07 thomas echo "M beta" >> $testroot/stdout.expected
366 069bbb86 2022-03-07 thomas echo "M gamma/delta" >> $testroot/stdout.expected
367 069bbb86 2022-03-07 thomas
368 069bbb86 2022-03-07 thomas (cd $testroot/wt && got patch patch) > $testroot/stdout
369 069bbb86 2022-03-07 thomas ret=$?
370 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
371 02e4f0d8 2022-03-08 thomas test_done $testroot $ret
372 069bbb86 2022-03-07 thomas return 1
373 069bbb86 2022-03-07 thomas fi
374 069bbb86 2022-03-07 thomas
375 069bbb86 2022-03-07 thomas cmp -s $testroot/stdout.expected $testroot/stdout
376 069bbb86 2022-03-07 thomas ret=$?
377 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
378 069bbb86 2022-03-07 thomas diff -u $testroot/stdout.expected $testroot/stdout
379 069bbb86 2022-03-07 thomas test_done $testroot $ret
380 069bbb86 2022-03-07 thomas return 1
381 069bbb86 2022-03-07 thomas fi
382 069bbb86 2022-03-07 thomas
383 069bbb86 2022-03-07 thomas printf 'new\nalpha\navailable\n' > $testroot/wt/alpha.expected
384 069bbb86 2022-03-07 thomas printf 'beta\nwas\nimproved\n' > $testroot/wt/beta.expected
385 069bbb86 2022-03-07 thomas printf 'delta new\n' > $testroot/wt/gamma/delta.expected
386 069bbb86 2022-03-07 thomas
387 069bbb86 2022-03-07 thomas for f in alpha beta gamma/delta; do
388 069bbb86 2022-03-07 thomas cmp -s $testroot/wt/$f.expected $testroot/wt/$f
389 069bbb86 2022-03-07 thomas ret=$?
390 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
391 069bbb86 2022-03-07 thomas diff -u $testroot/wt/$f.expected $testroot/wt/$f
392 069bbb86 2022-03-07 thomas test_done $testroot $ret
393 069bbb86 2022-03-07 thomas return 1
394 069bbb86 2022-03-07 thomas fi
395 069bbb86 2022-03-07 thomas done
396 069bbb86 2022-03-07 thomas
397 069bbb86 2022-03-07 thomas test_done $testroot 0
398 069bbb86 2022-03-07 thomas }
399 069bbb86 2022-03-07 thomas
400 069bbb86 2022-03-07 thomas test_patch_dont_apply() {
401 069bbb86 2022-03-07 thomas local testroot=`test_init patch_dont_apply`
402 069bbb86 2022-03-07 thomas
403 069bbb86 2022-03-07 thomas got checkout $testroot/repo $testroot/wt > /dev/null
404 069bbb86 2022-03-07 thomas ret=$?
405 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
406 069bbb86 2022-03-07 thomas test_done $testroot $ret
407 069bbb86 2022-03-07 thomas return 1
408 069bbb86 2022-03-07 thomas fi
409 069bbb86 2022-03-07 thomas
410 7dd42450 2022-03-13 thomas jot 100 > $testroot/wt/numbers
411 7dd42450 2022-03-13 thomas (cd $testroot/wt && got add numbers && got commit -m 'add numbers') \
412 7dd42450 2022-03-13 thomas >/dev/null
413 7dd42450 2022-03-13 thomas ret=$?
414 7dd42450 2022-03-13 thomas if [ $ret -ne 0 ]; then
415 7dd42450 2022-03-13 thomas test_done $testroot $ret
416 7dd42450 2022-03-13 thomas return 1
417 7dd42450 2022-03-13 thomas fi
418 7dd42450 2022-03-13 thomas
419 7dd42450 2022-03-13 thomas cat <<EOF > $testroot/wt/patch
420 49114f01 2022-03-22 thomas --- alpha
421 49114f01 2022-03-22 thomas +++ alpha
422 49114f01 2022-03-22 thomas @@ -1 +1,2 @@
423 49114f01 2022-03-22 thomas +hatsuseno
424 49114f01 2022-03-22 thomas alpha something
425 7dd42450 2022-03-13 thomas --- numbers
426 7dd42450 2022-03-13 thomas +++ /dev/null
427 7dd42450 2022-03-13 thomas @@ -1,9 +0,0 @@
428 7dd42450 2022-03-13 thomas -1
429 7dd42450 2022-03-13 thomas -2
430 7dd42450 2022-03-13 thomas -3
431 7dd42450 2022-03-13 thomas -4
432 7dd42450 2022-03-13 thomas -5
433 7dd42450 2022-03-13 thomas -6
434 7dd42450 2022-03-13 thomas -7
435 7dd42450 2022-03-13 thomas -8
436 7dd42450 2022-03-13 thomas -9
437 7dd42450 2022-03-13 thomas EOF
438 7dd42450 2022-03-13 thomas
439 49114f01 2022-03-22 thomas (cd $testroot/wt && got patch patch) > $testroot/stdout 2> /dev/null
440 7dd42450 2022-03-13 thomas ret=$?
441 7dd42450 2022-03-13 thomas if [ $ret -eq 0 ]; then # should fail
442 7dd42450 2022-03-13 thomas test_done $testroot 1
443 069bbb86 2022-03-07 thomas return 1
444 069bbb86 2022-03-07 thomas fi
445 069bbb86 2022-03-07 thomas
446 49114f01 2022-03-22 thomas cat <<EOF > $testroot/stdout.expected
447 49114f01 2022-03-22 thomas # alpha
448 49114f01 2022-03-22 thomas @@ -1,1 +1,2 @@ hunk failed to apply
449 49114f01 2022-03-22 thomas # numbers
450 49114f01 2022-03-22 thomas @@ -1,9 +0,0 @@ hunk failed to apply
451 49114f01 2022-03-22 thomas EOF
452 49114f01 2022-03-22 thomas
453 49114f01 2022-03-22 thomas cmp -s $testroot/stdout.expected $testroot/stdout
454 7dd42450 2022-03-13 thomas ret=$?
455 7dd42450 2022-03-13 thomas if [ $ret -ne 0 ]; then
456 49114f01 2022-03-22 thomas diff -u $testroot/stdout.expected $testroot/stdout
457 7dd42450 2022-03-13 thomas fi
458 069bbb86 2022-03-07 thomas test_done $testroot $ret
459 069bbb86 2022-03-07 thomas }
460 069bbb86 2022-03-07 thomas
461 069bbb86 2022-03-07 thomas test_patch_malformed() {
462 069bbb86 2022-03-07 thomas local testroot=`test_init patch_malformed`
463 069bbb86 2022-03-07 thomas
464 069bbb86 2022-03-07 thomas got checkout $testroot/repo $testroot/wt > /dev/null
465 069bbb86 2022-03-07 thomas ret=$?
466 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
467 069bbb86 2022-03-07 thomas test_done $testroot $ret
468 069bbb86 2022-03-07 thomas return 1
469 069bbb86 2022-03-07 thomas fi
470 069bbb86 2022-03-07 thomas
471 069bbb86 2022-03-07 thomas # missing "@@"
472 069bbb86 2022-03-07 thomas cat <<EOF > $testroot/wt/patch
473 069bbb86 2022-03-07 thomas --- alpha
474 069bbb86 2022-03-07 thomas +++ alpha
475 069bbb86 2022-03-07 thomas @@ -1 +1,2
476 069bbb86 2022-03-07 thomas +hatsuseno
477 069bbb86 2022-03-07 thomas alpha
478 069bbb86 2022-03-07 thomas EOF
479 069bbb86 2022-03-07 thomas
480 069bbb86 2022-03-07 thomas echo -n > $testroot/stdout.expected
481 069bbb86 2022-03-07 thomas echo "got: malformed patch" > $testroot/stderr.expected
482 069bbb86 2022-03-07 thomas
483 069bbb86 2022-03-07 thomas (cd $testroot/wt && got patch patch) \
484 069bbb86 2022-03-07 thomas > $testroot/stdout \
485 069bbb86 2022-03-07 thomas 2> $testroot/stderr
486 069bbb86 2022-03-07 thomas ret=$?
487 10cdd9aa 2022-03-08 thomas if [ $ret -eq 0 ]; then
488 069bbb86 2022-03-07 thomas echo "got managed to apply an invalid patch"
489 069bbb86 2022-03-07 thomas test_done $testroot 1
490 069bbb86 2022-03-07 thomas return 1
491 069bbb86 2022-03-07 thomas fi
492 069bbb86 2022-03-07 thomas
493 069bbb86 2022-03-07 thomas cmp -s $testroot/stdout.expected $testroot/stdout
494 069bbb86 2022-03-07 thomas ret=$?
495 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
496 069bbb86 2022-03-07 thomas diff -u $testroot/stdout.expected $testroot/stdout
497 069bbb86 2022-03-07 thomas test_done $testroot $ret
498 069bbb86 2022-03-07 thomas return 1
499 069bbb86 2022-03-07 thomas fi
500 069bbb86 2022-03-07 thomas
501 069bbb86 2022-03-07 thomas cmp -s $testroot/stderr.expected $testroot/stderr
502 069bbb86 2022-03-07 thomas ret=$?
503 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
504 069bbb86 2022-03-07 thomas diff -u $testroot/stderr.expected $testroot/stderr
505 069bbb86 2022-03-07 thomas test_done $testroot $ret
506 069bbb86 2022-03-07 thomas return 1
507 069bbb86 2022-03-07 thomas fi
508 069bbb86 2022-03-07 thomas
509 069bbb86 2022-03-07 thomas # wrong first character
510 069bbb86 2022-03-07 thomas cat <<EOF > $testroot/wt/patch
511 069bbb86 2022-03-07 thomas --- alpha
512 069bbb86 2022-03-07 thomas +++ alpha
513 069bbb86 2022-03-07 thomas @@ -1 +1,2 @@
514 069bbb86 2022-03-07 thomas +hatsuseno
515 069bbb86 2022-03-07 thomas alpha
516 88c260f4 2022-05-14 thomas EOF
517 88c260f4 2022-05-14 thomas
518 88c260f4 2022-05-14 thomas (cd $testroot/wt && got patch patch) \
519 88c260f4 2022-05-14 thomas > $testroot/stdout \
520 88c260f4 2022-05-14 thomas 2> $testroot/stderr
521 88c260f4 2022-05-14 thomas ret=$?
522 88c260f4 2022-05-14 thomas if [ $ret -eq 0 ]; then
523 88c260f4 2022-05-14 thomas echo "got managed to apply an invalid patch"
524 88c260f4 2022-05-14 thomas test_done $testroot 1
525 88c260f4 2022-05-14 thomas return 1
526 88c260f4 2022-05-14 thomas fi
527 88c260f4 2022-05-14 thomas
528 88c260f4 2022-05-14 thomas cmp -s $testroot/stdout.expected $testroot/stdout
529 88c260f4 2022-05-14 thomas ret=$?
530 88c260f4 2022-05-14 thomas if [ $ret -ne 0 ]; then
531 88c260f4 2022-05-14 thomas diff -u $testroot/stdout.expected $testroot/stdout
532 88c260f4 2022-05-14 thomas test_done $testroot $ret
533 88c260f4 2022-05-14 thomas return 1
534 88c260f4 2022-05-14 thomas fi
535 88c260f4 2022-05-14 thomas
536 88c260f4 2022-05-14 thomas cmp -s $testroot/stderr.expected $testroot/stderr
537 88c260f4 2022-05-14 thomas ret=$?
538 88c260f4 2022-05-14 thomas if [ $ret -ne 0 ]; then
539 88c260f4 2022-05-14 thomas diff -u $testroot/stderr.expected $testroot/stderr
540 88c260f4 2022-05-14 thomas test_done $testroot $ret
541 88c260f4 2022-05-14 thomas return 1
542 88c260f4 2022-05-14 thomas fi
543 88c260f4 2022-05-14 thomas
544 88c260f4 2022-05-14 thomas # empty hunk
545 88c260f4 2022-05-14 thomas cat <<EOF > $testroot/wt/patch
546 88c260f4 2022-05-14 thomas diff --git a/alpha b/iota
547 88c260f4 2022-05-14 thomas --- a/alpha
548 88c260f4 2022-05-14 thomas +++ b/iota
549 88c260f4 2022-05-14 thomas @@ -0,0 +0,0 @@
550 069bbb86 2022-03-07 thomas EOF
551 069bbb86 2022-03-07 thomas
552 069bbb86 2022-03-07 thomas (cd $testroot/wt && got patch patch) \
553 069bbb86 2022-03-07 thomas > $testroot/stdout \
554 069bbb86 2022-03-07 thomas 2> $testroot/stderr
555 069bbb86 2022-03-07 thomas ret=$?
556 10cdd9aa 2022-03-08 thomas if [ $ret -eq 0 ]; then
557 069bbb86 2022-03-07 thomas echo "got managed to apply an invalid patch"
558 069bbb86 2022-03-07 thomas test_done $testroot 1
559 069bbb86 2022-03-07 thomas return 1
560 069bbb86 2022-03-07 thomas fi
561 069bbb86 2022-03-07 thomas
562 069bbb86 2022-03-07 thomas cmp -s $testroot/stdout.expected $testroot/stdout
563 069bbb86 2022-03-07 thomas ret=$?
564 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
565 069bbb86 2022-03-07 thomas diff -u $testroot/stdout.expected $testroot/stdout
566 069bbb86 2022-03-07 thomas test_done $testroot $ret
567 069bbb86 2022-03-07 thomas return 1
568 069bbb86 2022-03-07 thomas fi
569 069bbb86 2022-03-07 thomas
570 069bbb86 2022-03-07 thomas cmp -s $testroot/stderr.expected $testroot/stderr
571 069bbb86 2022-03-07 thomas ret=$?
572 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
573 069bbb86 2022-03-07 thomas diff -u $testroot/stderr.expected $testroot/stderr
574 069bbb86 2022-03-07 thomas test_done $testroot $ret
575 069bbb86 2022-03-07 thomas return 1
576 069bbb86 2022-03-07 thomas fi
577 069bbb86 2022-03-07 thomas
578 069bbb86 2022-03-07 thomas test_done $testroot $ret
579 069bbb86 2022-03-07 thomas }
580 069bbb86 2022-03-07 thomas
581 069bbb86 2022-03-07 thomas test_patch_no_patch() {
582 069bbb86 2022-03-07 thomas local testroot=`test_init patch_no_patch`
583 069bbb86 2022-03-07 thomas
584 069bbb86 2022-03-07 thomas got checkout $testroot/repo $testroot/wt > /dev/null
585 069bbb86 2022-03-07 thomas ret=$?
586 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
587 069bbb86 2022-03-07 thomas test_done $testroot $ret
588 069bbb86 2022-03-07 thomas return 1
589 069bbb86 2022-03-07 thomas fi
590 069bbb86 2022-03-07 thomas
591 069bbb86 2022-03-07 thomas cat <<EOF > $testroot/wt/patch
592 069bbb86 2022-03-07 thomas hello world!
593 069bbb86 2022-03-07 thomas ...
594 069bbb86 2022-03-07 thomas
595 069bbb86 2022-03-07 thomas some other nonsense
596 069bbb86 2022-03-07 thomas ...
597 069bbb86 2022-03-07 thomas
598 069bbb86 2022-03-07 thomas there's no patch in here!
599 069bbb86 2022-03-07 thomas EOF
600 069bbb86 2022-03-07 thomas
601 069bbb86 2022-03-07 thomas echo -n > $testroot/stdout.expected
602 069bbb86 2022-03-07 thomas echo "got: no patch found" > $testroot/stderr.expected
603 069bbb86 2022-03-07 thomas
604 069bbb86 2022-03-07 thomas (cd $testroot/wt && got patch patch) \
605 069bbb86 2022-03-07 thomas > $testroot/stdout \
606 069bbb86 2022-03-07 thomas 2> $testroot/stderr
607 069bbb86 2022-03-07 thomas ret=$?
608 10cdd9aa 2022-03-08 thomas if [ $ret -eq 0 ]; then # should fail
609 069bbb86 2022-03-07 thomas test_done $testroot 1
610 069bbb86 2022-03-07 thomas return 1
611 069bbb86 2022-03-07 thomas fi
612 e1c219c8 2022-04-22 thomas
613 069bbb86 2022-03-07 thomas cmp -s $testroot/stdout.expected $testroot/stdout
614 069bbb86 2022-03-07 thomas ret=$?
615 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
616 069bbb86 2022-03-07 thomas diff -u $testroot/stdout.expected $testroot/stdout
617 069bbb86 2022-03-07 thomas test_done $testroot $ret
618 069bbb86 2022-03-07 thomas return 1
619 069bbb86 2022-03-07 thomas fi
620 069bbb86 2022-03-07 thomas
621 069bbb86 2022-03-07 thomas cmp -s $testroot/stderr.expected $testroot/stderr
622 069bbb86 2022-03-07 thomas ret=$?
623 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
624 069bbb86 2022-03-07 thomas diff -u $testroot/stderr.expected $testroot/stderr
625 069bbb86 2022-03-07 thomas test_done $testroot $ret
626 069bbb86 2022-03-07 thomas return 1
627 069bbb86 2022-03-07 thomas fi
628 069bbb86 2022-03-07 thomas
629 069bbb86 2022-03-07 thomas test_done $testroot $ret
630 069bbb86 2022-03-07 thomas }
631 069bbb86 2022-03-07 thomas
632 069bbb86 2022-03-07 thomas test_patch_equals_for_context() {
633 9a49df74 2022-04-23 thomas local testroot=`test_init patch_equals_for_context`
634 069bbb86 2022-03-07 thomas
635 069bbb86 2022-03-07 thomas got checkout $testroot/repo $testroot/wt > /dev/null
636 069bbb86 2022-03-07 thomas ret=$?
637 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
638 069bbb86 2022-03-07 thomas test_done $testroot $ret
639 069bbb86 2022-03-07 thomas return 1
640 069bbb86 2022-03-07 thomas fi
641 069bbb86 2022-03-07 thomas
642 069bbb86 2022-03-07 thomas cat <<EOF > $testroot/wt/patch
643 069bbb86 2022-03-07 thomas --- alpha
644 069bbb86 2022-03-07 thomas +++ alpha
645 069bbb86 2022-03-07 thomas @@ -1 +1,2 @@
646 069bbb86 2022-03-07 thomas +hatsuseno
647 069bbb86 2022-03-07 thomas =alpha
648 069bbb86 2022-03-07 thomas EOF
649 069bbb86 2022-03-07 thomas
650 069bbb86 2022-03-07 thomas echo "M alpha" > $testroot/stdout.expected
651 069bbb86 2022-03-07 thomas
652 069bbb86 2022-03-07 thomas (cd $testroot/wt && got patch patch) > $testroot/stdout
653 069bbb86 2022-03-07 thomas ret=$?
654 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
655 069bbb86 2022-03-07 thomas test_done $testroot $ret
656 069bbb86 2022-03-07 thomas return 1
657 069bbb86 2022-03-07 thomas fi
658 069bbb86 2022-03-07 thomas
659 069bbb86 2022-03-07 thomas cmp -s $testroot/stdout.expected $testroot/stdout
660 069bbb86 2022-03-07 thomas ret=$?
661 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
662 069bbb86 2022-03-07 thomas diff -u $testroot/stdout.expected $testroot/stdout
663 069bbb86 2022-03-07 thomas test_done $testroot $ret
664 069bbb86 2022-03-07 thomas return 1
665 069bbb86 2022-03-07 thomas fi
666 069bbb86 2022-03-07 thomas
667 069bbb86 2022-03-07 thomas echo hatsuseno > $testroot/wt/alpha.expected
668 069bbb86 2022-03-07 thomas echo alpha >> $testroot/wt/alpha.expected
669 069bbb86 2022-03-07 thomas cmp -s $testroot/wt/alpha.expected $testroot/wt/alpha
670 069bbb86 2022-03-07 thomas ret=$?
671 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
672 069bbb86 2022-03-07 thomas diff -u $testroot/wt/alpha.expected $testroot/wt/alpha
673 069bbb86 2022-03-07 thomas fi
674 069bbb86 2022-03-07 thomas test_done $testroot $ret
675 069bbb86 2022-03-07 thomas }
676 bb2ad8ff 2022-03-13 thomas
677 bb2ad8ff 2022-03-13 thomas test_patch_rename() {
678 bb2ad8ff 2022-03-13 thomas local testroot=`test_init patch_rename`
679 bb2ad8ff 2022-03-13 thomas
680 bb2ad8ff 2022-03-13 thomas got checkout $testroot/repo $testroot/wt > /dev/null
681 bb2ad8ff 2022-03-13 thomas ret=$?
682 bb2ad8ff 2022-03-13 thomas if [ $ret -ne 0 ]; then
683 bb2ad8ff 2022-03-13 thomas test_done $testroot $ret
684 bb2ad8ff 2022-03-13 thomas return 1
685 bb2ad8ff 2022-03-13 thomas fi
686 bb2ad8ff 2022-03-13 thomas
687 bb2ad8ff 2022-03-13 thomas cat <<EOF > $testroot/wt/patch
688 8afe1f71 2022-05-12 thomas diff --git a/beta b/iota
689 8afe1f71 2022-05-12 thomas similarity index 100%
690 8afe1f71 2022-05-12 thomas rename from beta
691 8afe1f71 2022-05-12 thomas rename to iota
692 be53ddb1 2022-03-22 thomas diff --git a/alpha b/eta
693 be53ddb1 2022-03-22 thomas --- a/alpha
694 be53ddb1 2022-03-22 thomas +++ b/eta
695 8afe1f71 2022-05-12 thomas @@ -1 +1 @@
696 8afe1f71 2022-05-12 thomas -alpha
697 8afe1f71 2022-05-12 thomas +eta
698 bb2ad8ff 2022-03-13 thomas EOF
699 069bbb86 2022-03-07 thomas
700 8afe1f71 2022-05-12 thomas echo 'D beta' > $testroot/stdout.expected
701 8afe1f71 2022-05-12 thomas echo 'A iota' >> $testroot/stdout.expected
702 8afe1f71 2022-05-12 thomas echo 'D alpha' >> $testroot/stdout.expected
703 8afe1f71 2022-05-12 thomas echo 'A eta' >> $testroot/stdout.expected
704 bb2ad8ff 2022-03-13 thomas
705 bb2ad8ff 2022-03-13 thomas (cd $testroot/wt && got patch patch) > $testroot/stdout
706 bb2ad8ff 2022-03-13 thomas ret=$?
707 bb2ad8ff 2022-03-13 thomas if [ $ret -ne 0 ]; then
708 bb2ad8ff 2022-03-13 thomas test_done $testroot $ret
709 bb2ad8ff 2022-03-13 thomas return 1
710 bb2ad8ff 2022-03-13 thomas fi
711 bb2ad8ff 2022-03-13 thomas
712 bb2ad8ff 2022-03-13 thomas cmp -s $testroot/stdout.expected $testroot/stdout
713 bb2ad8ff 2022-03-13 thomas ret=$?
714 bb2ad8ff 2022-03-13 thomas if [ $ret -ne 0 ]; then
715 bb2ad8ff 2022-03-13 thomas diff -u $testroot/stdout.expected $testroot/stdout
716 bb2ad8ff 2022-03-13 thomas test_done $testroot $ret
717 bb2ad8ff 2022-03-13 thomas return 1
718 bb2ad8ff 2022-03-13 thomas fi
719 bb2ad8ff 2022-03-13 thomas
720 8afe1f71 2022-05-12 thomas if [ -f $testroot/wt/alpha -o -f $testroot/wt/beta ]; then
721 8afe1f71 2022-05-12 thomas echo "alpha or beta were not removed" >&2
722 bb2ad8ff 2022-03-13 thomas test_done $testroot 1
723 bb2ad8ff 2022-03-13 thomas return 1
724 bb2ad8ff 2022-03-13 thomas fi
725 8afe1f71 2022-05-12 thomas if [ ! -f $testroot/wt/iota -o ! -f $testroot/wt/eta ]; then
726 8afe1f71 2022-05-12 thomas echo "iota or eta were not created" >&2
727 bb2ad8ff 2022-03-13 thomas test_done $testroot 1
728 bb2ad8ff 2022-03-13 thomas return 1
729 bb2ad8ff 2022-03-13 thomas fi
730 bb2ad8ff 2022-03-13 thomas
731 8afe1f71 2022-05-12 thomas echo beta > $testroot/wt/iota.expected
732 8afe1f71 2022-05-12 thomas cmp -s $testroot/wt/iota.expected $testroot/wt/iota
733 bb2ad8ff 2022-03-13 thomas ret=$?
734 bb2ad8ff 2022-03-13 thomas if [ $ret -ne 0 ]; then
735 8afe1f71 2022-05-12 thomas diff -u $testroot/wt/iota.expected $testroot/wt/iota
736 bb2ad8ff 2022-03-13 thomas test_done $testroot $ret
737 bb2ad8ff 2022-03-13 thomas return 1
738 bb2ad8ff 2022-03-13 thomas fi
739 bb2ad8ff 2022-03-13 thomas
740 8afe1f71 2022-05-12 thomas echo eta > $testroot/wt/eta.expected
741 8afe1f71 2022-05-12 thomas cmp -s $testroot/wt/eta.expected $testroot/wt/eta
742 bb2ad8ff 2022-03-13 thomas ret=$?
743 bb2ad8ff 2022-03-13 thomas if [ $ret -ne 0 ]; then
744 8afe1f71 2022-05-12 thomas diff -u $testroot/wt/eta.expected $testroot/wt/eta
745 bb2ad8ff 2022-03-13 thomas test_done $testroot $ret
746 bb2ad8ff 2022-03-13 thomas return 1
747 bb2ad8ff 2022-03-13 thomas fi
748 bb2ad8ff 2022-03-13 thomas
749 bb2ad8ff 2022-03-13 thomas test_done $testroot $ret
750 bb2ad8ff 2022-03-13 thomas }
751 10e55613 2022-03-22 thomas
752 10e55613 2022-03-22 thomas test_patch_illegal_status() {
753 10e55613 2022-03-22 thomas local testroot=`test_init patch_illegal_status`
754 10e55613 2022-03-22 thomas
755 10e55613 2022-03-22 thomas got checkout $testroot/repo $testroot/wt > /dev/null
756 10e55613 2022-03-22 thomas ret=$?
757 10e55613 2022-03-22 thomas if [ $ret -ne 0 ]; then
758 10e55613 2022-03-22 thomas test_done $testroot $ret
759 10e55613 2022-03-22 thomas return 1
760 10e55613 2022-03-22 thomas fi
761 10e55613 2022-03-22 thomas
762 49114f01 2022-03-22 thomas # try to patch an obstructed file, add a versioned one, edit a
763 49114f01 2022-03-22 thomas # non existent file and an unversioned one, and remove a
764 49114f01 2022-03-22 thomas # non existent file.
765 10e55613 2022-03-22 thomas cat <<EOF > $testroot/wt/patch
766 49114f01 2022-03-22 thomas --- alpha
767 49114f01 2022-03-22 thomas +++ alpha
768 49114f01 2022-03-22 thomas @@ -1 +1,2 @@
769 49114f01 2022-03-22 thomas alpha
770 49114f01 2022-03-22 thomas +was edited
771 49114f01 2022-03-22 thomas --- /dev/null
772 49114f01 2022-03-22 thomas +++ beta
773 49114f01 2022-03-22 thomas @@ -0,0 +1 @@
774 49114f01 2022-03-22 thomas +beta
775 10e55613 2022-03-22 thomas --- iota
776 10e55613 2022-03-22 thomas +++ iota
777 10e55613 2022-03-22 thomas @@ -1 +1 @@
778 49114f01 2022-03-22 thomas -iota
779 49114f01 2022-03-22 thomas +IOTA
780 49114f01 2022-03-22 thomas --- kappa
781 49114f01 2022-03-22 thomas +++ kappa
782 49114f01 2022-03-22 thomas @@ -1 +1 @@
783 49114f01 2022-03-22 thomas -kappa
784 49114f01 2022-03-22 thomas +KAPPA
785 49114f01 2022-03-22 thomas --- lambda
786 49114f01 2022-03-22 thomas +++ /dev/null
787 49114f01 2022-03-22 thomas @@ -1 +0,0 @@
788 49114f01 2022-03-22 thomas -lambda
789 10e55613 2022-03-22 thomas EOF
790 42d9d68e 2022-03-13 thomas
791 49114f01 2022-03-22 thomas echo kappa > $testroot/wt/kappa
792 10e55613 2022-03-22 thomas rm $testroot/wt/alpha
793 10e55613 2022-03-22 thomas mkdir $testroot/wt/alpha
794 10e55613 2022-03-22 thomas
795 49114f01 2022-03-22 thomas (cd $testroot/wt && got patch patch) > $testroot/stdout \
796 10e55613 2022-03-22 thomas 2> $testroot/stderr
797 10e55613 2022-03-22 thomas ret=$?
798 10e55613 2022-03-22 thomas if [ $ret -eq 0 ]; then
799 10e55613 2022-03-22 thomas echo "edited a missing file" >&2
800 4e2bdb0d 2022-06-13 thomas test_done $testroot 1
801 10e55613 2022-03-22 thomas return 1
802 10e55613 2022-03-22 thomas fi
803 10e55613 2022-03-22 thomas
804 49114f01 2022-03-22 thomas cat <<EOF > $testroot/stdout.expected
805 49114f01 2022-03-22 thomas # alpha
806 49114f01 2022-03-22 thomas # beta
807 49114f01 2022-03-22 thomas # iota
808 49114f01 2022-03-22 thomas # kappa
809 49114f01 2022-03-22 thomas # lambda
810 49114f01 2022-03-22 thomas EOF
811 10e55613 2022-03-22 thomas
812 49114f01 2022-03-22 thomas cat <<EOF > $testroot/stderr.expected
813 49114f01 2022-03-22 thomas got: alpha: file has unexpected status
814 49114f01 2022-03-22 thomas got: beta: file has unexpected status
815 49114f01 2022-03-22 thomas got: iota: No such file or directory
816 49114f01 2022-03-22 thomas got: kappa: file has unexpected status
817 49114f01 2022-03-22 thomas got: lambda: No such file or directory
818 49114f01 2022-03-22 thomas got: patch failed to apply
819 10e55613 2022-03-22 thomas EOF
820 10e55613 2022-03-22 thomas
821 49114f01 2022-03-22 thomas cmp -s $testroot/stdout.expected $testroot/stdout
822 10e55613 2022-03-22 thomas ret=$?
823 49114f01 2022-03-22 thomas if [ $ret -ne 0 ]; then
824 49114f01 2022-03-22 thomas diff -u $testroot/stdout.expected $testroot/stdout
825 10e55613 2022-03-22 thomas test_done $testroot $ret
826 10e55613 2022-03-22 thomas return 1
827 10e55613 2022-03-22 thomas fi
828 10e55613 2022-03-22 thomas
829 10e55613 2022-03-22 thomas cmp -s $testroot/stderr.expected $testroot/stderr
830 10e55613 2022-03-22 thomas ret=$?
831 49114f01 2022-03-22 thomas if [ $ret -ne 0 ]; then
832 10e55613 2022-03-22 thomas diff -u $testroot/stderr.expected $testroot/stderr
833 814624e7 2022-03-22 thomas test_done $testroot $ret
834 814624e7 2022-03-22 thomas return 1
835 10e55613 2022-03-22 thomas fi
836 814624e7 2022-03-22 thomas
837 814624e7 2022-03-22 thomas (cd $testroot/wt && got status) > $testroot/stdout
838 814624e7 2022-03-22 thomas cat <<EOF > $testroot/stdout.expected
839 814624e7 2022-03-22 thomas ~ alpha
840 814624e7 2022-03-22 thomas ? kappa
841 814624e7 2022-03-22 thomas ? patch
842 814624e7 2022-03-22 thomas EOF
843 814624e7 2022-03-22 thomas
844 814624e7 2022-03-22 thomas cmp -s $testroot/stdout.expected $testroot/stdout
845 814624e7 2022-03-22 thomas ret=$?
846 814624e7 2022-03-22 thomas if [ $ret -ne 0 ]; then
847 814624e7 2022-03-22 thomas diff -u $testroot/stdout.expected $testroot/stdout
848 814624e7 2022-03-22 thomas fi
849 eaf99875 2022-03-22 thomas test_done $testroot $ret
850 eaf99875 2022-03-22 thomas }
851 eaf99875 2022-03-22 thomas
852 eaf99875 2022-03-22 thomas test_patch_nop() {
853 eaf99875 2022-03-22 thomas local testroot=`test_init patch_nop`
854 eaf99875 2022-03-22 thomas
855 eaf99875 2022-03-22 thomas got checkout $testroot/repo $testroot/wt > /dev/null
856 eaf99875 2022-03-22 thomas ret=$?
857 eaf99875 2022-03-22 thomas if [ $ret -ne 0 ]; then
858 eaf99875 2022-03-22 thomas test_done $testroot $ret
859 eaf99875 2022-03-22 thomas return 1
860 eaf99875 2022-03-22 thomas fi
861 eaf99875 2022-03-22 thomas
862 eaf99875 2022-03-22 thomas cat <<EOF > $testroot/wt/patch
863 eaf99875 2022-03-22 thomas --- alpha
864 eaf99875 2022-03-22 thomas +++ alpha
865 eaf99875 2022-03-22 thomas @@ -1 +1 @@
866 eaf99875 2022-03-22 thomas -alpha
867 eaf99875 2022-03-22 thomas +cafe alpha
868 eaf99875 2022-03-22 thomas --- beta
869 eaf99875 2022-03-22 thomas +++ /dev/null
870 eaf99875 2022-03-22 thomas @@ -1 +0,0 @@
871 eaf99875 2022-03-22 thomas -beta
872 be53ddb1 2022-03-22 thomas diff --git a/gamma/delta b/gamma/delta.new
873 eaf99875 2022-03-22 thomas --- gamma/delta
874 eaf99875 2022-03-22 thomas +++ gamma/delta.new
875 eaf99875 2022-03-22 thomas @@ -1 +1 @@
876 eaf99875 2022-03-22 thomas -delta
877 eaf99875 2022-03-22 thomas +delta updated and renamed!
878 eaf99875 2022-03-22 thomas EOF
879 eaf99875 2022-03-22 thomas
880 eaf99875 2022-03-22 thomas (cd $testroot/wt && got patch -n patch)
881 eaf99875 2022-03-22 thomas ret=$?
882 eaf99875 2022-03-22 thomas if [ $ret -ne 0 ]; then
883 eaf99875 2022-03-22 thomas test_done $testroot $ret
884 eaf99875 2022-03-22 thomas return 1
885 10e55613 2022-03-22 thomas fi
886 eaf99875 2022-03-22 thomas
887 eaf99875 2022-03-22 thomas # remove the patch to avoid the ? entry
888 eaf99875 2022-03-22 thomas rm $testroot/wt/patch
889 eaf99875 2022-03-22 thomas
890 eaf99875 2022-03-22 thomas (cd $testroot/wt && got status) > $testroot/stdout
891 eaf99875 2022-03-22 thomas ret=$?
892 eaf99875 2022-03-22 thomas if [ $ret -ne 0 ]; then
893 eaf99875 2022-03-22 thomas test_done $testroot $ret
894 eaf99875 2022-03-22 thomas return 1
895 eaf99875 2022-03-22 thomas fi
896 eaf99875 2022-03-22 thomas
897 eaf99875 2022-03-22 thomas echo -n > $testroot/stdout.expected
898 eaf99875 2022-03-22 thomas cmp -s $testroot/stdout.expected $testroot/stdout
899 eaf99875 2022-03-22 thomas ret=$?
900 eaf99875 2022-03-22 thomas if [ $ret -ne 0 ]; then
901 eaf99875 2022-03-22 thomas diff -u $testroot/stdout.expected $testroot/stdout
902 eaf99875 2022-03-22 thomas fi
903 10e55613 2022-03-22 thomas test_done $testroot $ret
904 da09d8ed 2022-03-22 thomas }
905 da09d8ed 2022-03-22 thomas
906 da09d8ed 2022-03-22 thomas test_patch_preserve_perm() {
907 da09d8ed 2022-03-22 thomas local testroot=`test_init patch_preserve_perm`
908 da09d8ed 2022-03-22 thomas
909 da09d8ed 2022-03-22 thomas got checkout $testroot/repo $testroot/wt > /dev/null
910 da09d8ed 2022-03-22 thomas ret=$?
911 da09d8ed 2022-03-22 thomas if [ $ret -ne 0 ]; then
912 da09d8ed 2022-03-22 thomas test_done $testroot $ret
913 da09d8ed 2022-03-22 thomas return 1
914 da09d8ed 2022-03-22 thomas fi
915 da09d8ed 2022-03-22 thomas
916 da09d8ed 2022-03-22 thomas chmod +x $testroot/wt/alpha
917 da09d8ed 2022-03-22 thomas (cd $testroot/wt && got commit -m 'alpha executable') > /dev/null
918 da09d8ed 2022-03-22 thomas ret=$?
919 da09d8ed 2022-03-22 thomas if [ $ret -ne 0 ]; then
920 da09d8ed 2022-03-22 thomas test_done $testroot $ret
921 da09d8ed 2022-03-22 thomas return 1
922 da09d8ed 2022-03-22 thomas fi
923 da09d8ed 2022-03-22 thomas
924 da09d8ed 2022-03-22 thomas cat <<EOF > $testroot/wt/patch
925 da09d8ed 2022-03-22 thomas --- alpha
926 da09d8ed 2022-03-22 thomas +++ alpha
927 da09d8ed 2022-03-22 thomas @@ -1 +1,2 @@
928 da09d8ed 2022-03-22 thomas alpha
929 da09d8ed 2022-03-22 thomas +was edited
930 da09d8ed 2022-03-22 thomas EOF
931 da09d8ed 2022-03-22 thomas
932 da09d8ed 2022-03-22 thomas (cd $testroot/wt && got patch patch) > /dev/null
933 da09d8ed 2022-03-22 thomas ret=$?
934 da09d8ed 2022-03-22 thomas if [ $ret -ne 0 ]; then
935 da09d8ed 2022-03-22 thomas test_done $testroot $ret
936 da09d8ed 2022-03-22 thomas return 1
937 da09d8ed 2022-03-22 thomas fi
938 da09d8ed 2022-03-22 thomas
939 da09d8ed 2022-03-22 thomas if [ ! -x $testroot/wt/alpha ]; then
940 da09d8ed 2022-03-22 thomas echo "alpha is no more executable!" >&2
941 da09d8ed 2022-03-22 thomas test_done $testroot 1
942 e0c1f81c 2022-03-22 thomas return 1
943 e0c1f81c 2022-03-22 thomas fi
944 e0c1f81c 2022-03-22 thomas test_done $testroot 0
945 e0c1f81c 2022-03-22 thomas }
946 e0c1f81c 2022-03-22 thomas
947 e0c1f81c 2022-03-22 thomas test_patch_create_dirs() {
948 e0c1f81c 2022-03-22 thomas local testroot=`test_init patch_create_dirs`
949 e0c1f81c 2022-03-22 thomas
950 e0c1f81c 2022-03-22 thomas got checkout $testroot/repo $testroot/wt > /dev/null
951 e0c1f81c 2022-03-22 thomas ret=$?
952 e0c1f81c 2022-03-22 thomas if [ $ret -ne 0 ]; then
953 e0c1f81c 2022-03-22 thomas test_done $testroot $ret
954 e0c1f81c 2022-03-22 thomas return 1
955 e0c1f81c 2022-03-22 thomas fi
956 e0c1f81c 2022-03-22 thomas
957 e0c1f81c 2022-03-22 thomas cat <<EOF > $testroot/wt/patch
958 e0c1f81c 2022-03-22 thomas --- /dev/null
959 e0c1f81c 2022-03-22 thomas +++ iota/kappa/lambda
960 e0c1f81c 2022-03-22 thomas @@ -0,0 +1 @@
961 e0c1f81c 2022-03-22 thomas +lambda
962 e0c1f81c 2022-03-22 thomas EOF
963 e0c1f81c 2022-03-22 thomas
964 e0c1f81c 2022-03-22 thomas (cd $testroot/wt && got patch patch) > $testroot/stdout
965 e0c1f81c 2022-03-22 thomas ret=$?
966 e0c1f81c 2022-03-22 thomas if [ $ret -ne 0 ]; then
967 e0c1f81c 2022-03-22 thomas test_done $testroot $ret
968 da09d8ed 2022-03-22 thomas return 1
969 da09d8ed 2022-03-22 thomas fi
970 e0c1f81c 2022-03-22 thomas
971 e0c1f81c 2022-03-22 thomas echo 'A iota/kappa/lambda' >> $testroot/stdout.expected
972 e0c1f81c 2022-03-22 thomas cmp -s $testroot/stdout.expected $testroot/stdout
973 e0c1f81c 2022-03-22 thomas ret=$?
974 e0c1f81c 2022-03-22 thomas if [ $ret -ne 0 ]; then
975 e0c1f81c 2022-03-22 thomas diff -u $testroot/stdout.expected $testroot/stdout
976 e0c1f81c 2022-03-22 thomas test_done $testroot $ret
977 e0c1f81c 2022-03-22 thomas return 1
978 e0c1f81c 2022-03-22 thomas fi
979 e0c1f81c 2022-03-22 thomas
980 e0c1f81c 2022-03-22 thomas if [ ! -f $testroot/wt/iota/kappa/lambda ]; then
981 e0c1f81c 2022-03-22 thomas echo "file not created!" >&2
982 e0c1f81c 2022-03-22 thomas test_done $testroot $ret
983 e0c1f81c 2022-03-22 thomas return 1
984 e0c1f81c 2022-03-22 thomas fi
985 da09d8ed 2022-03-22 thomas test_done $testroot 0
986 10e55613 2022-03-22 thomas }
987 10e55613 2022-03-22 thomas
988 49114f01 2022-03-22 thomas test_patch_with_offset() {
989 49114f01 2022-03-22 thomas local testroot=`test_init patch_with_offset`
990 49114f01 2022-03-22 thomas
991 49114f01 2022-03-22 thomas got checkout $testroot/repo $testroot/wt > /dev/null
992 49114f01 2022-03-22 thomas ret=$?
993 49114f01 2022-03-22 thomas if [ $ret -ne 0 ]; then
994 49114f01 2022-03-22 thomas test_done $testroot $ret
995 49114f01 2022-03-22 thomas return 1
996 49114f01 2022-03-22 thomas fi
997 49114f01 2022-03-22 thomas
998 49114f01 2022-03-22 thomas cat <<EOF > $testroot/wt/patch
999 49114f01 2022-03-22 thomas --- numbers
1000 49114f01 2022-03-22 thomas +++ numbers
1001 49114f01 2022-03-22 thomas @@ -47,7 +47,7 @@
1002 49114f01 2022-03-22 thomas 47
1003 49114f01 2022-03-22 thomas 48
1004 49114f01 2022-03-22 thomas 49
1005 49114f01 2022-03-22 thomas -50
1006 49114f01 2022-03-22 thomas +midway tru it!
1007 49114f01 2022-03-22 thomas 51
1008 49114f01 2022-03-22 thomas 52
1009 49114f01 2022-03-22 thomas 53
1010 49114f01 2022-03-22 thomas @@ -87,7 +87,7 @@
1011 49114f01 2022-03-22 thomas 87
1012 49114f01 2022-03-22 thomas 88
1013 49114f01 2022-03-22 thomas 89
1014 49114f01 2022-03-22 thomas -90
1015 49114f01 2022-03-22 thomas +almost there!
1016 49114f01 2022-03-22 thomas 91
1017 49114f01 2022-03-22 thomas 92
1018 49114f01 2022-03-22 thomas 93
1019 49114f01 2022-03-22 thomas EOF
1020 49114f01 2022-03-22 thomas
1021 49114f01 2022-03-22 thomas jot 100 > $testroot/wt/numbers
1022 49114f01 2022-03-22 thomas ed $testroot/wt/numbers <<EOF > /dev/null 2> /dev/null
1023 49114f01 2022-03-22 thomas 1,10d
1024 49114f01 2022-03-22 thomas 50r !jot 20
1025 49114f01 2022-03-22 thomas w
1026 49114f01 2022-03-22 thomas q
1027 49114f01 2022-03-22 thomas EOF
1028 49114f01 2022-03-22 thomas
1029 49114f01 2022-03-22 thomas (cd $testroot/wt && got add numbers && got commit -m '+numbers') \
1030 49114f01 2022-03-22 thomas > /dev/null
1031 49114f01 2022-03-22 thomas ret=$?
1032 49114f01 2022-03-22 thomas if [ $ret -ne 0 ]; then
1033 49114f01 2022-03-22 thomas test_done $testroot $ret
1034 49114f01 2022-03-22 thomas return 1
1035 49114f01 2022-03-22 thomas fi
1036 49114f01 2022-03-22 thomas
1037 49114f01 2022-03-22 thomas (cd $testroot/wt && got patch patch) > $testroot/stdout
1038 49114f01 2022-03-22 thomas ret=$?
1039 49114f01 2022-03-22 thomas if [ $ret -ne 0 ]; then
1040 49114f01 2022-03-22 thomas test_done $testroot/wt $ret
1041 49114f01 2022-03-22 thomas return 1
1042 49114f01 2022-03-22 thomas fi
1043 49114f01 2022-03-22 thomas
1044 49114f01 2022-03-22 thomas cat <<EOF > $testroot/stdout.expected
1045 49114f01 2022-03-22 thomas M numbers
1046 49114f01 2022-03-22 thomas @@ -47,7 +47,7 @@ applied with offset -10
1047 49114f01 2022-03-22 thomas @@ -87,7 +87,7 @@ applied with offset 10
1048 be53ddb1 2022-03-22 thomas EOF
1049 be53ddb1 2022-03-22 thomas
1050 be53ddb1 2022-03-22 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1051 be53ddb1 2022-03-22 thomas ret=$?
1052 be53ddb1 2022-03-22 thomas if [ $ret -ne 0 ]; then
1053 be53ddb1 2022-03-22 thomas diff -u $testroot/stdout.expected $testroot/stdout
1054 be53ddb1 2022-03-22 thomas fi
1055 be53ddb1 2022-03-22 thomas test_done $testroot $ret
1056 be53ddb1 2022-03-22 thomas }
1057 be53ddb1 2022-03-22 thomas
1058 be53ddb1 2022-03-22 thomas test_patch_prefer_new_path() {
1059 be53ddb1 2022-03-22 thomas local testroot=`test_init patch_orig`
1060 be53ddb1 2022-03-22 thomas
1061 be53ddb1 2022-03-22 thomas got checkout $testroot/repo $testroot/wt > /dev/null
1062 be53ddb1 2022-03-22 thomas ret=$?
1063 be53ddb1 2022-03-22 thomas if [ $ret -ne 0 ]; then
1064 be53ddb1 2022-03-22 thomas test_done $testroot $ret
1065 be53ddb1 2022-03-22 thomas return 1
1066 be53ddb1 2022-03-22 thomas fi
1067 be53ddb1 2022-03-22 thomas
1068 be53ddb1 2022-03-22 thomas cat <<EOF > $testroot/wt/patch
1069 be53ddb1 2022-03-22 thomas --- alpha.orig
1070 be53ddb1 2022-03-22 thomas +++ alpha
1071 be53ddb1 2022-03-22 thomas @@ -1 +1,2 @@
1072 be53ddb1 2022-03-22 thomas alpha
1073 be53ddb1 2022-03-22 thomas +was edited
1074 49114f01 2022-03-22 thomas EOF
1075 49114f01 2022-03-22 thomas
1076 be53ddb1 2022-03-22 thomas (cd $testroot/wt && got patch patch) > $testroot/stdout
1077 be53ddb1 2022-03-22 thomas ret=$?
1078 be53ddb1 2022-03-22 thomas if [ $ret -ne 0 ]; then
1079 be53ddb1 2022-03-22 thomas test_done $testroot $ret
1080 be53ddb1 2022-03-22 thomas return 1
1081 be53ddb1 2022-03-22 thomas fi
1082 be53ddb1 2022-03-22 thomas
1083 e1c219c8 2022-04-22 thomas echo 'M alpha' > $testroot/stdout.expected
1084 49114f01 2022-03-22 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1085 49114f01 2022-03-22 thomas ret=$?
1086 49114f01 2022-03-22 thomas if [ $ret -ne 0 ]; then
1087 49114f01 2022-03-22 thomas diff -u $testroot/stdout.expected $testroot/stdout
1088 49114f01 2022-03-22 thomas fi
1089 49114f01 2022-03-22 thomas test_done $testroot $ret
1090 49114f01 2022-03-22 thomas }
1091 49114f01 2022-03-22 thomas
1092 ff7f34d3 2022-03-22 thomas test_patch_no_newline() {
1093 ff7f34d3 2022-03-22 thomas local testroot=`test_init patch_no_newline`
1094 ff7f34d3 2022-03-22 thomas
1095 ff7f34d3 2022-03-22 thomas got checkout $testroot/repo $testroot/wt > /dev/null
1096 ff7f34d3 2022-03-22 thomas ret=$?
1097 ff7f34d3 2022-03-22 thomas if [ $ret -ne 0 ]; then
1098 ff7f34d3 2022-03-22 thomas test_done $testroot $ret
1099 ff7f34d3 2022-03-22 thomas return 1
1100 ff7f34d3 2022-03-22 thomas fi
1101 ff7f34d3 2022-03-22 thomas
1102 ff7f34d3 2022-03-22 thomas cat <<EOF > $testroot/wt/patch
1103 ff7f34d3 2022-03-22 thomas --- /dev/null
1104 ff7f34d3 2022-03-22 thomas +++ eta
1105 ff7f34d3 2022-03-22 thomas @@ -0,0 +1 @@
1106 ff7f34d3 2022-03-22 thomas +eta
1107 ff7f34d3 2022-03-22 thomas \ No newline at end of file
1108 ff7f34d3 2022-03-22 thomas EOF
1109 ff7f34d3 2022-03-22 thomas
1110 ff7f34d3 2022-03-22 thomas (cd $testroot/wt && got patch patch) > $testroot/stdout
1111 ff7f34d3 2022-03-22 thomas ret=$?
1112 ff7f34d3 2022-03-22 thomas if [ $ret -ne 0 ]; then
1113 ff7f34d3 2022-03-22 thomas test_done $testroot $ret
1114 ff7f34d3 2022-03-22 thomas return 1
1115 ff7f34d3 2022-03-22 thomas fi
1116 ff7f34d3 2022-03-22 thomas
1117 ff7f34d3 2022-03-22 thomas echo "A eta" > $testroot/stdout.expected
1118 ff7f34d3 2022-03-22 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1119 ff7f34d3 2022-03-22 thomas ret=$?
1120 ff7f34d3 2022-03-22 thomas if [ $ret -ne 0 ]; then
1121 ff7f34d3 2022-03-22 thomas diff -u $testroot/stdout.expected $testroot/stdout
1122 ff7f34d3 2022-03-22 thomas test_done $testroot $ret
1123 ff7f34d3 2022-03-22 thomas return 1
1124 ff7f34d3 2022-03-22 thomas fi
1125 ff7f34d3 2022-03-22 thomas
1126 ff7f34d3 2022-03-22 thomas echo -n eta > $testroot/wt/eta.expected
1127 ff7f34d3 2022-03-22 thomas cmp -s $testroot/wt/eta.expected $testroot/wt/eta
1128 ff7f34d3 2022-03-22 thomas ret=$?
1129 ff7f34d3 2022-03-22 thomas if [ $ret -ne 0 ]; then
1130 ff7f34d3 2022-03-22 thomas diff -u $testroot/wt/eta.expected $testroot/wt/eta
1131 ff7f34d3 2022-03-22 thomas test_done $testroot $ret
1132 ff7f34d3 2022-03-22 thomas return 1
1133 ff7f34d3 2022-03-22 thomas fi
1134 ff7f34d3 2022-03-22 thomas
1135 ff7f34d3 2022-03-22 thomas (cd $testroot/wt && got commit -m 'add eta') > /dev/null
1136 ff7f34d3 2022-03-22 thomas ret=$?
1137 ff7f34d3 2022-03-22 thomas if [ $ret -ne 0 ]; then
1138 ff7f34d3 2022-03-22 thomas test_done $testroot $ret
1139 ff7f34d3 2022-03-22 thomas return 1
1140 ff7f34d3 2022-03-22 thomas fi
1141 ff7f34d3 2022-03-22 thomas
1142 ff7f34d3 2022-03-22 thomas cat <<EOF > $testroot/wt/patch
1143 ff7f34d3 2022-03-22 thomas --- eta
1144 ff7f34d3 2022-03-22 thomas +++ eta
1145 ff7f34d3 2022-03-22 thomas @@ -1 +1 @@
1146 ff7f34d3 2022-03-22 thomas -eta
1147 ff7f34d3 2022-03-22 thomas \ No newline at end of file
1148 ff7f34d3 2022-03-22 thomas +ETA
1149 ff7f34d3 2022-03-22 thomas \ No newline at end of file
1150 ff7f34d3 2022-03-22 thomas EOF
1151 ff7f34d3 2022-03-22 thomas
1152 ff7f34d3 2022-03-22 thomas (cd $testroot/wt && got patch patch) > $testroot/stdout
1153 ff7f34d3 2022-03-22 thomas ret=$?
1154 ff7f34d3 2022-03-22 thomas if [ $ret -ne 0 ]; then
1155 ff7f34d3 2022-03-22 thomas test_done $testroot $ret
1156 ff7f34d3 2022-03-22 thomas return 1
1157 ff7f34d3 2022-03-22 thomas fi
1158 ff7f34d3 2022-03-22 thomas
1159 ff7f34d3 2022-03-22 thomas echo "M eta" > $testroot/stdout.expected
1160 ff7f34d3 2022-03-22 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1161 ff7f34d3 2022-03-22 thomas ret=$?
1162 ff7f34d3 2022-03-22 thomas if [ $ret -ne 0 ]; then
1163 ff7f34d3 2022-03-22 thomas diff -u $testroot/stdout.expected $testroot/stdout
1164 ff7f34d3 2022-03-22 thomas test_done $testroot $ret
1165 ff7f34d3 2022-03-22 thomas return 1
1166 ff7f34d3 2022-03-22 thomas fi
1167 ff7f34d3 2022-03-22 thomas
1168 ff7f34d3 2022-03-22 thomas echo -n ETA > $testroot/wt/eta.expected
1169 ff7f34d3 2022-03-22 thomas cmp -s $testroot/wt/eta.expected $testroot/wt/eta
1170 ff7f34d3 2022-03-22 thomas ret=$?
1171 ff7f34d3 2022-03-22 thomas if [ $ret -ne 0 ]; then
1172 ff7f34d3 2022-03-22 thomas diff -u $testroot/wt/eta.expected $testroot/wt/eta
1173 ff7f34d3 2022-03-22 thomas test_done $testroot $ret
1174 ff7f34d3 2022-03-22 thomas return 1
1175 ff7f34d3 2022-03-22 thomas fi
1176 ff7f34d3 2022-03-22 thomas
1177 ff7f34d3 2022-03-22 thomas (cd $testroot/wt && got commit -m 'edit eta') > /dev/null
1178 ff7f34d3 2022-03-22 thomas ret=$?
1179 ff7f34d3 2022-03-22 thomas if [ $ret -ne 0 ]; then
1180 ff7f34d3 2022-03-22 thomas test_done $testroot $ret
1181 ff7f34d3 2022-03-22 thomas return 1
1182 ff7f34d3 2022-03-22 thomas fi
1183 ff7f34d3 2022-03-22 thomas
1184 ff7f34d3 2022-03-22 thomas cat <<EOF > $testroot/wt/patch
1185 ff7f34d3 2022-03-22 thomas --- eta
1186 ff7f34d3 2022-03-22 thomas +++ eta
1187 ff7f34d3 2022-03-22 thomas @@ -1 +1 @@
1188 ff7f34d3 2022-03-22 thomas -ETA
1189 ff7f34d3 2022-03-22 thomas \ No newline at end of file
1190 ff7f34d3 2022-03-22 thomas +eta
1191 ff7f34d3 2022-03-22 thomas EOF
1192 ff7f34d3 2022-03-22 thomas
1193 ff7f34d3 2022-03-22 thomas (cd $testroot/wt && got patch patch) > $testroot/stdout
1194 ff7f34d3 2022-03-22 thomas ret=$?
1195 ff7f34d3 2022-03-22 thomas if [ $ret -ne 0 ]; then
1196 ff7f34d3 2022-03-22 thomas test_done $testroot $ret
1197 ff7f34d3 2022-03-22 thomas return 1
1198 ff7f34d3 2022-03-22 thomas fi
1199 ff7f34d3 2022-03-22 thomas
1200 ff7f34d3 2022-03-22 thomas echo "M eta" > $testroot/stdout.expected
1201 ff7f34d3 2022-03-22 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1202 ff7f34d3 2022-03-22 thomas ret=$?
1203 ff7f34d3 2022-03-22 thomas if [ $ret -ne 0 ]; then
1204 ff7f34d3 2022-03-22 thomas diff -u $testroot/stdout.expected $testroot/stdout
1205 ff7f34d3 2022-03-22 thomas test_done $testroot $ret
1206 ff7f34d3 2022-03-22 thomas return 1
1207 ff7f34d3 2022-03-22 thomas fi
1208 ff7f34d3 2022-03-22 thomas
1209 ff7f34d3 2022-03-22 thomas echo eta > $testroot/wt/eta.expected
1210 ff7f34d3 2022-03-22 thomas cmp -s $testroot/wt/eta.expected $testroot/wt/eta
1211 ff7f34d3 2022-03-22 thomas ret=$?
1212 ff7f34d3 2022-03-22 thomas if [ $ret -ne 0 ]; then
1213 ff7f34d3 2022-03-22 thomas diff -u $testroot/wt/eta.expected $testroot/wt/eta
1214 ff7f34d3 2022-03-22 thomas fi
1215 ff7f34d3 2022-03-22 thomas test_done $testroot $ret
1216 ff7f34d3 2022-03-22 thomas }
1217 ff7f34d3 2022-03-22 thomas
1218 d9db2ff9 2022-04-16 thomas test_patch_strip() {
1219 d9db2ff9 2022-04-16 thomas local testroot=`test_init patch_strip`
1220 d9db2ff9 2022-04-16 thomas
1221 d9db2ff9 2022-04-16 thomas got checkout $testroot/repo $testroot/wt > /dev/null
1222 d9db2ff9 2022-04-16 thomas ret=$?
1223 d9db2ff9 2022-04-16 thomas if [ $ret -ne 0 ]; then
1224 d9db2ff9 2022-04-16 thomas test_done $testroot $ret
1225 d9db2ff9 2022-04-16 thomas return 1
1226 d9db2ff9 2022-04-16 thomas fi
1227 d9db2ff9 2022-04-16 thomas
1228 d9db2ff9 2022-04-16 thomas cat <<EOF > $testroot/wt/patch
1229 d9db2ff9 2022-04-16 thomas --- foo/bar/alpha.orig
1230 d9db2ff9 2022-04-16 thomas +++ foo/bar/alpha
1231 d9db2ff9 2022-04-16 thomas @@ -1 +1 @@
1232 d9db2ff9 2022-04-16 thomas -alpha
1233 d9db2ff9 2022-04-16 thomas +ALPHA
1234 d9db2ff9 2022-04-16 thomas EOF
1235 d9db2ff9 2022-04-16 thomas
1236 d9db2ff9 2022-04-16 thomas (cd $testroot/wt && got patch -p2 patch) > $testroot/stdout
1237 d9db2ff9 2022-04-16 thomas ret=$?
1238 d9db2ff9 2022-04-16 thomas if [ $ret -ne 0 ]; then
1239 d9db2ff9 2022-04-16 thomas test_done $testroot $ret
1240 d9db2ff9 2022-04-16 thomas return 1
1241 d9db2ff9 2022-04-16 thomas fi
1242 d9db2ff9 2022-04-16 thomas
1243 d9db2ff9 2022-04-16 thomas echo "M alpha" >> $testroot/stdout.expected
1244 d9db2ff9 2022-04-16 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1245 d9db2ff9 2022-04-16 thomas ret=$?
1246 d9db2ff9 2022-04-16 thomas if [ $ret -ne 0 ]; then
1247 d9db2ff9 2022-04-16 thomas diff -u $testroot/stdout.expected $testroot/stdout
1248 d9db2ff9 2022-04-16 thomas test_done $testroot $ret
1249 d9db2ff9 2022-04-16 thomas return 1
1250 d9db2ff9 2022-04-16 thomas fi
1251 d9db2ff9 2022-04-16 thomas
1252 d9db2ff9 2022-04-16 thomas (cd $testroot/wt && got revert alpha) > /dev/null 2>&1
1253 d9db2ff9 2022-04-16 thomas ret=$?
1254 d9db2ff9 2022-04-16 thomas if [ $ret -ne 0 ]; then
1255 d9db2ff9 2022-04-16 thomas test_done $testroot $ret
1256 d9db2ff9 2022-04-16 thomas return 1
1257 d9db2ff9 2022-04-16 thomas fi
1258 d9db2ff9 2022-04-16 thomas
1259 d9db2ff9 2022-04-16 thomas (cd $testroot/wt && got patch -p3 patch) \
1260 d9db2ff9 2022-04-16 thomas 2> $testroot/stderr
1261 d9db2ff9 2022-04-16 thomas ret=$?
1262 d9db2ff9 2022-04-16 thomas if [ $ret -eq 0 ]; then
1263 d9db2ff9 2022-04-16 thomas echo "stripped more components than available!"
1264 d9db2ff9 2022-04-16 thomas test_done $testroot 1
1265 d9db2ff9 2022-04-16 thomas return 1
1266 d9db2ff9 2022-04-16 thomas fi
1267 d9db2ff9 2022-04-16 thomas
1268 d9db2ff9 2022-04-16 thomas cat <<EOF > $testroot/stderr.expected
1269 d9db2ff9 2022-04-16 thomas got: can't strip 1 path-components from foo/bar/alpha: bad path
1270 d9db2ff9 2022-04-16 thomas EOF
1271 d9db2ff9 2022-04-16 thomas
1272 d9db2ff9 2022-04-16 thomas cmp -s $testroot/stderr.expected $testroot/stderr
1273 d9db2ff9 2022-04-16 thomas ret=$?
1274 d9db2ff9 2022-04-16 thomas if [ $ret -ne 0 ]; then
1275 d9db2ff9 2022-04-16 thomas diff -u $testroot/stderr.expected $testroot/stderr
1276 d9db2ff9 2022-04-16 thomas fi
1277 d9db2ff9 2022-04-16 thomas test_done $testroot 0
1278 bb90ca7b 2022-07-03 thomas }
1279 bb90ca7b 2022-07-03 thomas
1280 bb90ca7b 2022-07-03 thomas test_patch_whitespace() {
1281 bb90ca7b 2022-07-03 thomas local testroot=`test_init patch_whitespace`
1282 bb90ca7b 2022-07-03 thomas
1283 bb90ca7b 2022-07-03 thomas got checkout $testroot/repo $testroot/wt > /dev/null
1284 bb90ca7b 2022-07-03 thomas ret=$?
1285 bb90ca7b 2022-07-03 thomas if [ $ret -ne 0 ]; then
1286 bb90ca7b 2022-07-03 thomas test_done $testroot $ret
1287 bb90ca7b 2022-07-03 thomas return 1
1288 bb90ca7b 2022-07-03 thomas fi
1289 bb90ca7b 2022-07-03 thomas
1290 bb90ca7b 2022-07-03 thomas trailing=" "
1291 bb90ca7b 2022-07-03 thomas
1292 bb90ca7b 2022-07-03 thomas cat <<EOF > $testroot/wt/hello.c
1293 bb90ca7b 2022-07-03 thomas #include <stdio.h>
1294 bb90ca7b 2022-07-03 thomas
1295 bb90ca7b 2022-07-03 thomas int
1296 bb90ca7b 2022-07-03 thomas main(void)
1297 bb90ca7b 2022-07-03 thomas {
1298 bb90ca7b 2022-07-03 thomas /* the trailing whitespace is on purpose */
1299 bb90ca7b 2022-07-03 thomas printf("hello, world\n");$trailing
1300 bb90ca7b 2022-07-03 thomas return 0;
1301 bb90ca7b 2022-07-03 thomas }
1302 bb90ca7b 2022-07-03 thomas EOF
1303 bb90ca7b 2022-07-03 thomas
1304 bb90ca7b 2022-07-03 thomas (cd $testroot/wt && got add hello.c && got ci -m '+hello.c') \
1305 bb90ca7b 2022-07-03 thomas > /dev/null
1306 bb90ca7b 2022-07-03 thomas ret=$?
1307 bb90ca7b 2022-07-03 thomas if [ $ret -ne 0 ]; then
1308 bb90ca7b 2022-07-03 thomas test_done $testroot $ret
1309 bb90ca7b 2022-07-03 thomas return 1
1310 bb90ca7b 2022-07-03 thomas fi
1311 bb90ca7b 2022-07-03 thomas
1312 bb90ca7b 2022-07-03 thomas # test with a diff with various whitespace corruptions
1313 bb90ca7b 2022-07-03 thomas cat <<EOF > $testroot/wt/patch
1314 bb90ca7b 2022-07-03 thomas --- hello.c
1315 bb90ca7b 2022-07-03 thomas +++ hello.c
1316 bb90ca7b 2022-07-03 thomas @@ -5,5 +5,5 @@
1317 bb90ca7b 2022-07-03 thomas {
1318 bb90ca7b 2022-07-03 thomas /* the trailing whitespace is on purpose */
1319 bb90ca7b 2022-07-03 thomas printf("hello, world\n");
1320 bb90ca7b 2022-07-03 thomas - return 0;
1321 bb90ca7b 2022-07-03 thomas + return 5; /* always fails */
1322 bb90ca7b 2022-07-03 thomas }
1323 bb90ca7b 2022-07-03 thomas EOF
1324 bb90ca7b 2022-07-03 thomas
1325 bb90ca7b 2022-07-03 thomas (cd $testroot/wt && got patch patch) \
1326 bb90ca7b 2022-07-03 thomas 2>$testroot/stderr >$testroot/stdout
1327 bb90ca7b 2022-07-03 thomas ret=$?
1328 bb90ca7b 2022-07-03 thomas if [ $ret -ne 0 ]; then
1329 bb90ca7b 2022-07-03 thomas echo "failed to apply diff" >&2
1330 bb90ca7b 2022-07-03 thomas test_done $testroot $ret
1331 bb90ca7b 2022-07-03 thomas return 1
1332 bb90ca7b 2022-07-03 thomas fi
1333 bb90ca7b 2022-07-03 thomas
1334 bb90ca7b 2022-07-03 thomas echo 'M hello.c' > $testroot/stdout.expected
1335 bb90ca7b 2022-07-03 thomas echo '@@ -5,5 +5,5 @@ hunk contains mangled whitespace' \
1336 bb90ca7b 2022-07-03 thomas >> $testroot/stdout.expected
1337 bb90ca7b 2022-07-03 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1338 bb90ca7b 2022-07-03 thomas ret=$?
1339 bb90ca7b 2022-07-03 thomas if [ $ret -ne 0 ]; then
1340 bb90ca7b 2022-07-03 thomas diff -u $testroot/stdout.expected $testroot/stdout
1341 bb90ca7b 2022-07-03 thomas test_done $testroot $ret
1342 bb90ca7b 2022-07-03 thomas return 1
1343 bb90ca7b 2022-07-03 thomas fi
1344 bb90ca7b 2022-07-03 thomas
1345 bb90ca7b 2022-07-03 thomas cat <<EOF > $testroot/wt/hello.c.expected
1346 bb90ca7b 2022-07-03 thomas #include <stdio.h>
1347 bb90ca7b 2022-07-03 thomas
1348 bb90ca7b 2022-07-03 thomas int
1349 bb90ca7b 2022-07-03 thomas main(void)
1350 bb90ca7b 2022-07-03 thomas {
1351 bb90ca7b 2022-07-03 thomas /* the trailing whitespace is on purpose */
1352 bb90ca7b 2022-07-03 thomas printf("hello, world\n");$trailing
1353 bb90ca7b 2022-07-03 thomas return 5; /* always fails */
1354 bb90ca7b 2022-07-03 thomas }
1355 bb90ca7b 2022-07-03 thomas EOF
1356 bb90ca7b 2022-07-03 thomas
1357 bb90ca7b 2022-07-03 thomas cmp -s $testroot/wt/hello.c.expected $testroot/wt/hello.c
1358 bb90ca7b 2022-07-03 thomas ret=$?
1359 bb90ca7b 2022-07-03 thomas if [ $ret -ne 0 ]; then
1360 bb90ca7b 2022-07-03 thomas diff -u $testroot/wt/hello.c.expected $testroot/wt/hello.c
1361 bb90ca7b 2022-07-03 thomas fi
1362 bb90ca7b 2022-07-03 thomas test_done $testroot $ret
1363 d9db2ff9 2022-04-16 thomas }
1364 72f46891 2022-04-23 thomas
1365 72f46891 2022-04-23 thomas test_patch_relative_paths() {
1366 9a49df74 2022-04-23 thomas local testroot=`test_init patch_relative_paths`
1367 72f46891 2022-04-23 thomas
1368 72f46891 2022-04-23 thomas got checkout $testroot/repo $testroot/wt > /dev/null
1369 72f46891 2022-04-23 thomas ret=$?
1370 72f46891 2022-04-23 thomas if [ $ret -ne 0 ]; then
1371 72f46891 2022-04-23 thomas test_done $testroot $ret
1372 72f46891 2022-04-23 thomas return 1
1373 72f46891 2022-04-23 thomas fi
1374 d9db2ff9 2022-04-16 thomas
1375 72f46891 2022-04-23 thomas cat <<EOF > $testroot/wt/gamma/patch
1376 72f46891 2022-04-23 thomas --- delta
1377 72f46891 2022-04-23 thomas +++ delta
1378 72f46891 2022-04-23 thomas @@ -1 +1 @@
1379 72f46891 2022-04-23 thomas -delta
1380 72f46891 2022-04-23 thomas +DELTA
1381 72f46891 2022-04-23 thomas --- /dev/null
1382 72f46891 2022-04-23 thomas +++ eta
1383 72f46891 2022-04-23 thomas @@ -0,0 +1 @@
1384 72f46891 2022-04-23 thomas +eta
1385 72f46891 2022-04-23 thomas EOF
1386 72f46891 2022-04-23 thomas
1387 72f46891 2022-04-23 thomas (cd $testroot/wt/gamma && got patch patch) > $testroot/stdout
1388 72f46891 2022-04-23 thomas ret=$?
1389 72f46891 2022-04-23 thomas if [ $ret -ne 0 ]; then
1390 72f46891 2022-04-23 thomas test_done $testroot $ret
1391 72f46891 2022-04-23 thomas return 1
1392 72f46891 2022-04-23 thomas fi
1393 72f46891 2022-04-23 thomas
1394 72f46891 2022-04-23 thomas echo 'M gamma/delta' > $testroot/stdout.expected
1395 72f46891 2022-04-23 thomas echo 'A gamma/eta' >> $testroot/stdout.expected
1396 cfbf5531 2022-04-23 thomas
1397 cfbf5531 2022-04-23 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1398 cfbf5531 2022-04-23 thomas ret=$?
1399 cfbf5531 2022-04-23 thomas if [ $ret -ne 0 ]; then
1400 cfbf5531 2022-04-23 thomas diff -u $testroot/stdout.expected $testroot/stdout
1401 cfbf5531 2022-04-23 thomas fi
1402 cfbf5531 2022-04-23 thomas test_done $testroot $ret
1403 cfbf5531 2022-04-23 thomas }
1404 cfbf5531 2022-04-23 thomas
1405 cfbf5531 2022-04-23 thomas test_patch_with_path_prefix() {
1406 cfbf5531 2022-04-23 thomas local testroot=`test_init patch_with_path_prefix`
1407 cfbf5531 2022-04-23 thomas
1408 cfbf5531 2022-04-23 thomas got checkout -p gamma $testroot/repo $testroot/wt > /dev/null
1409 cfbf5531 2022-04-23 thomas ret=$?
1410 cfbf5531 2022-04-23 thomas if [ $ret -ne 0 ]; then
1411 cfbf5531 2022-04-23 thomas test_done $testroot $ret
1412 cfbf5531 2022-04-23 thomas return 1
1413 cfbf5531 2022-04-23 thomas fi
1414 cfbf5531 2022-04-23 thomas
1415 cfbf5531 2022-04-23 thomas cat <<EOF > $testroot/wt/patch
1416 cfbf5531 2022-04-23 thomas --- delta
1417 cfbf5531 2022-04-23 thomas +++ delta
1418 cfbf5531 2022-04-23 thomas @@ -1 +1 @@
1419 cfbf5531 2022-04-23 thomas -delta
1420 cfbf5531 2022-04-23 thomas +DELTA
1421 cfbf5531 2022-04-23 thomas --- /dev/null
1422 cfbf5531 2022-04-23 thomas +++ eta
1423 cfbf5531 2022-04-23 thomas @@ -0,0 +1 @@
1424 cfbf5531 2022-04-23 thomas +eta
1425 cfbf5531 2022-04-23 thomas EOF
1426 cfbf5531 2022-04-23 thomas
1427 cfbf5531 2022-04-23 thomas (cd $testroot/wt && got patch patch) > $testroot/stdout
1428 cfbf5531 2022-04-23 thomas ret=$?
1429 cfbf5531 2022-04-23 thomas if [ $ret -ne 0 ]; then
1430 cfbf5531 2022-04-23 thomas test_done $testroot $ret
1431 cfbf5531 2022-04-23 thomas return 1
1432 cfbf5531 2022-04-23 thomas fi
1433 cfbf5531 2022-04-23 thomas
1434 cfbf5531 2022-04-23 thomas echo 'M delta' > $testroot/stdout.expected
1435 cfbf5531 2022-04-23 thomas echo 'A eta' >> $testroot/stdout.expected
1436 cfbf5531 2022-04-23 thomas
1437 cfbf5531 2022-04-23 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1438 cfbf5531 2022-04-23 thomas ret=$?
1439 cfbf5531 2022-04-23 thomas if [ $ret -ne 0 ]; then
1440 cfbf5531 2022-04-23 thomas diff -u $testroot/stdout.expected $testroot/stdout
1441 cfbf5531 2022-04-23 thomas fi
1442 cfbf5531 2022-04-23 thomas test_done $testroot $ret
1443 cfbf5531 2022-04-23 thomas }
1444 72f46891 2022-04-23 thomas
1445 cfbf5531 2022-04-23 thomas test_patch_relpath_with_path_prefix() {
1446 cfbf5531 2022-04-23 thomas local testroot=`test_init patch_relpaths_with_path_prefix`
1447 cfbf5531 2022-04-23 thomas
1448 cfbf5531 2022-04-23 thomas got checkout -p gamma $testroot/repo $testroot/wt > /dev/null
1449 cfbf5531 2022-04-23 thomas ret=$?
1450 cfbf5531 2022-04-23 thomas if [ $ret -ne 0 ]; then
1451 cfbf5531 2022-04-23 thomas test_done $testroot $ret
1452 cfbf5531 2022-04-23 thomas return 1
1453 cfbf5531 2022-04-23 thomas fi
1454 cfbf5531 2022-04-23 thomas
1455 cfbf5531 2022-04-23 thomas mkdir -p $testroot/wt/epsilon/zeta/
1456 cfbf5531 2022-04-23 thomas
1457 cfbf5531 2022-04-23 thomas cat <<EOF > $testroot/wt/patch
1458 cfbf5531 2022-04-23 thomas --- /dev/null
1459 cfbf5531 2022-04-23 thomas +++ zeta/theta
1460 cfbf5531 2022-04-23 thomas @@ -0,0 +1 @@
1461 cfbf5531 2022-04-23 thomas +theta
1462 cfbf5531 2022-04-23 thomas EOF
1463 cfbf5531 2022-04-23 thomas
1464 cfbf5531 2022-04-23 thomas (cd $testroot/wt/epsilon/zeta && got patch -p1 $testroot/wt/patch) \
1465 cfbf5531 2022-04-23 thomas > $testroot/stdout
1466 cfbf5531 2022-04-23 thomas ret=$?
1467 cfbf5531 2022-04-23 thomas if [ $ret -ne 0 ]; then
1468 cfbf5531 2022-04-23 thomas test_done $testroot $ret
1469 cfbf5531 2022-04-23 thomas return 1
1470 cfbf5531 2022-04-23 thomas fi
1471 cfbf5531 2022-04-23 thomas
1472 cfbf5531 2022-04-23 thomas echo 'A epsilon/zeta/theta' >> $testroot/stdout.expected
1473 cfbf5531 2022-04-23 thomas
1474 72f46891 2022-04-23 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1475 72f46891 2022-04-23 thomas ret=$?
1476 72f46891 2022-04-23 thomas if [ $ret -ne 0 ]; then
1477 72f46891 2022-04-23 thomas diff -u $testroot/stdout.expected $testroot/stdout
1478 cfbf5531 2022-04-23 thomas test_done $testroot $ret
1479 cfbf5531 2022-04-23 thomas return 1
1480 72f46891 2022-04-23 thomas fi
1481 cfbf5531 2022-04-23 thomas
1482 cfbf5531 2022-04-23 thomas echo 'theta' > $testroot/theta.expected
1483 cfbf5531 2022-04-23 thomas cmp -s $testroot/wt/epsilon/zeta/theta $testroot/theta.expected
1484 cfbf5531 2022-04-23 thomas ret=$?
1485 cfbf5531 2022-04-23 thomas if [ $ret -ne 0 ]; then
1486 cfbf5531 2022-04-23 thomas diff -u $testroot/wt/epsilon/zeta/theta $testroot/theta.expected
1487 cfbf5531 2022-04-23 thomas fi
1488 72f46891 2022-04-23 thomas test_done $testroot $ret
1489 72f46891 2022-04-23 thomas }
1490 eaef698f 2022-04-23 thomas
1491 eaef698f 2022-04-23 thomas test_patch_reverse() {
1492 eaef698f 2022-04-23 thomas local testroot=`test_init patch_reverse`
1493 eaef698f 2022-04-23 thomas
1494 eaef698f 2022-04-23 thomas got checkout $testroot/repo $testroot/wt > /dev/null
1495 eaef698f 2022-04-23 thomas ret=$?
1496 eaef698f 2022-04-23 thomas if [ $ret -ne 0 ]; then
1497 eaef698f 2022-04-23 thomas test_done $testroot $ret
1498 eaef698f 2022-04-23 thomas return 1
1499 eaef698f 2022-04-23 thomas fi
1500 eaef698f 2022-04-23 thomas
1501 eaef698f 2022-04-23 thomas cat <<EOF > $testroot/wt/patch
1502 eaef698f 2022-04-23 thomas --- alpha
1503 eaef698f 2022-04-23 thomas +++ alpha
1504 eaef698f 2022-04-23 thomas @@ -1 +1 @@
1505 eaef698f 2022-04-23 thomas -ALPHA
1506 eaef698f 2022-04-23 thomas \ No newline at end of file
1507 eaef698f 2022-04-23 thomas +alpha
1508 eaef698f 2022-04-23 thomas EOF
1509 72f46891 2022-04-23 thomas
1510 eaef698f 2022-04-23 thomas (cd $testroot/wt && got patch -R patch) > $testroot/stdout
1511 eaef698f 2022-04-23 thomas ret=$?
1512 eaef698f 2022-04-23 thomas if [ $ret -ne 0 ]; then
1513 eaef698f 2022-04-23 thomas test_done $testroot $ret
1514 eaef698f 2022-04-23 thomas return 1
1515 eaef698f 2022-04-23 thomas fi
1516 eaef698f 2022-04-23 thomas
1517 eaef698f 2022-04-23 thomas echo "M alpha" > $testroot/stdout.expected
1518 eaef698f 2022-04-23 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1519 eaef698f 2022-04-23 thomas ret=$?
1520 eaef698f 2022-04-23 thomas if [ $ret -ne 0 ]; then
1521 eaef698f 2022-04-23 thomas diff -u $testroot/stdout.expected $testroot/stdout
1522 eaef698f 2022-04-23 thomas test_done $testroot $ret
1523 eaef698f 2022-04-23 thomas return 1
1524 eaef698f 2022-04-23 thomas fi
1525 eaef698f 2022-04-23 thomas
1526 eaef698f 2022-04-23 thomas echo -n ALPHA > $testroot/wt/alpha.expected
1527 eaef698f 2022-04-23 thomas cmp -s $testroot/wt/alpha.expected $testroot/wt/alpha
1528 eaef698f 2022-04-23 thomas ret=$?
1529 eaef698f 2022-04-23 thomas if [ $ret -ne 0 ]; then
1530 eaef698f 2022-04-23 thomas diff -u $testroot/wt/alpha.expected $testroot/wt/alpha
1531 0f76ab83 2022-06-23 thomas fi
1532 0f76ab83 2022-06-23 thomas test_done $testroot $ret
1533 0f76ab83 2022-06-23 thomas }
1534 0f76ab83 2022-06-23 thomas
1535 0f76ab83 2022-06-23 thomas test_patch_merge_simple() {
1536 0f76ab83 2022-06-23 thomas local testroot=`test_init patch_merge_simple`
1537 0f76ab83 2022-06-23 thomas
1538 0f76ab83 2022-06-23 thomas got checkout $testroot/repo $testroot/wt > /dev/null
1539 0f76ab83 2022-06-23 thomas ret=$?
1540 0f76ab83 2022-06-23 thomas if [ $ret -ne 0 ]; then
1541 0f76ab83 2022-06-23 thomas test_done $testroot $ret
1542 0f76ab83 2022-06-23 thomas return 1
1543 0f76ab83 2022-06-23 thomas fi
1544 0f76ab83 2022-06-23 thomas
1545 0f76ab83 2022-06-23 thomas jot 10 > $testroot/wt/numbers
1546 25a880e1 2022-07-03 thomas chmod +x $testroot/wt/numbers
1547 0f76ab83 2022-06-23 thomas (cd $testroot/wt && got add numbers && got commit -m +numbers) \
1548 0f76ab83 2022-06-23 thomas > /dev/null
1549 0f76ab83 2022-06-23 thomas ret=$?
1550 0f76ab83 2022-06-23 thomas if [ $ret -ne 0 ]; then
1551 0f76ab83 2022-06-23 thomas test_done $testroot $ret
1552 0f76ab83 2022-06-23 thomas return 1
1553 0f76ab83 2022-06-23 thomas fi
1554 0f76ab83 2022-06-23 thomas
1555 0f76ab83 2022-06-23 thomas jot 10 | sed 's/4/four/g' > $testroot/wt/numbers
1556 0f76ab83 2022-06-23 thomas
1557 0f76ab83 2022-06-23 thomas (cd $testroot/wt && got diff > $testroot/old.diff \
1558 0f76ab83 2022-06-23 thomas && got revert numbers) >/dev/null
1559 0f76ab83 2022-06-23 thomas ret=$?
1560 0f76ab83 2022-06-23 thomas if [ $ret -ne 0 ]; then
1561 0f76ab83 2022-06-23 thomas test_done $testroot $ret
1562 0f76ab83 2022-06-23 thomas return 1
1563 0f76ab83 2022-06-23 thomas fi
1564 0f76ab83 2022-06-23 thomas
1565 0f76ab83 2022-06-23 thomas jot 10 | sed 's/6/six/g' > $testroot/wt/numbers
1566 0f76ab83 2022-06-23 thomas (cd $testroot/wt && got commit -m 'edit numbers') \
1567 0f76ab83 2022-06-23 thomas > /dev/null
1568 0f76ab83 2022-06-23 thomas ret=$?
1569 0f76ab83 2022-06-23 thomas if [ $ret -ne 0 ]; then
1570 0f76ab83 2022-06-23 thomas test_done $testroot $ret
1571 0f76ab83 2022-06-23 thomas return 1
1572 0f76ab83 2022-06-23 thomas fi
1573 0f76ab83 2022-06-23 thomas
1574 0f76ab83 2022-06-23 thomas (cd $testroot/wt && got patch $testroot/old.diff) \
1575 762b8e82 2022-06-23 thomas > $testroot/stdout
1576 0f76ab83 2022-06-23 thomas ret=$?
1577 0f76ab83 2022-06-23 thomas if [ $ret -ne 0 ]; then
1578 762b8e82 2022-06-23 thomas test_done $testroot $ret
1579 762b8e82 2022-06-23 thomas return 1
1580 762b8e82 2022-06-23 thomas fi
1581 762b8e82 2022-06-23 thomas
1582 762b8e82 2022-06-23 thomas echo 'G numbers' > $testroot/stdout.expected
1583 762b8e82 2022-06-23 thomas cmp -s $testroot/stdout $testroot/stdout.expected
1584 762b8e82 2022-06-23 thomas ret=$?
1585 762b8e82 2022-06-23 thomas if [ $ret -ne 0 ]; then
1586 762b8e82 2022-06-23 thomas diff -u $testroot/stdout $testroot/stdout.expected
1587 0f76ab83 2022-06-23 thomas test_done $testroot $ret
1588 0f76ab83 2022-06-23 thomas return 1
1589 0f76ab83 2022-06-23 thomas fi
1590 0f76ab83 2022-06-23 thomas
1591 0f76ab83 2022-06-23 thomas jot 10 | sed -e s/4/four/ -e s/6/six/ > $testroot/wt/numbers.expected
1592 0f76ab83 2022-06-23 thomas cmp -s $testroot/wt/numbers $testroot/wt/numbers.expected
1593 0f76ab83 2022-06-23 thomas ret=$?
1594 0f76ab83 2022-06-23 thomas if [ $ret -ne 0 ]; then
1595 0f76ab83 2022-06-23 thomas diff -u $testroot/wt/numbers $testroot/wt/numbers.expected
1596 25a880e1 2022-07-03 thomas test_done $testroot $ret
1597 25a880e1 2022-07-03 thomas return 1
1598 19dd85cb 2022-07-01 thomas fi
1599 25a880e1 2022-07-03 thomas
1600 25a880e1 2022-07-03 thomas test -x $testroot/wt/numbers
1601 25a880e1 2022-07-03 thomas ret=$?
1602 25a880e1 2022-07-03 thomas if [ $ret -ne 0 ]; then
1603 25a880e1 2022-07-03 thomas echo "numbers lost the executable bit" >&2
1604 25a880e1 2022-07-03 thomas fi
1605 19dd85cb 2022-07-01 thomas test_done $testroot $ret
1606 19dd85cb 2022-07-01 thomas }
1607 19dd85cb 2022-07-01 thomas
1608 19dd85cb 2022-07-01 thomas test_patch_merge_gitdiff() {
1609 19dd85cb 2022-07-01 thomas local testroot=`test_init patch_merge_gitdiff`
1610 19dd85cb 2022-07-01 thomas
1611 19dd85cb 2022-07-01 thomas jot 10 > $testroot/repo/numbers
1612 19dd85cb 2022-07-01 thomas (cd $testroot/repo && git add numbers && \
1613 19dd85cb 2022-07-01 thomas git_commit $testroot/repo -m "nums")
1614 19dd85cb 2022-07-01 thomas ret=$?
1615 19dd85cb 2022-07-01 thomas if [ $ret -ne 0 ]; then
1616 19dd85cb 2022-07-01 thomas test_done $testroot $ret
1617 19dd85cb 2022-07-01 thomas return 1
1618 19dd85cb 2022-07-01 thomas fi
1619 19dd85cb 2022-07-01 thomas
1620 19dd85cb 2022-07-01 thomas jot 10 | sed 's/4/four/g' > $testroot/repo/numbers
1621 19dd85cb 2022-07-01 thomas (cd $testroot/repo && git diff > $testroot/old.diff)
1622 19dd85cb 2022-07-01 thomas ret=$?
1623 19dd85cb 2022-07-01 thomas if [ $ret -ne 0 ]; then
1624 19dd85cb 2022-07-01 thomas test_done $testroot $ret
1625 19dd85cb 2022-07-01 thomas return 1
1626 19dd85cb 2022-07-01 thomas fi
1627 19dd85cb 2022-07-01 thomas
1628 19dd85cb 2022-07-01 thomas # restore numbers
1629 19dd85cb 2022-07-01 thomas jot 10 > $testroot/repo/numbers
1630 19dd85cb 2022-07-01 thomas
1631 19dd85cb 2022-07-01 thomas jot 10 | sed 's/6/six/g' > $testroot/repo/numbers
1632 19dd85cb 2022-07-01 thomas (cd $testroot/repo && git add numbers && \
1633 19dd85cb 2022-07-01 thomas git_commit $testroot/repo -m "edit")
1634 19dd85cb 2022-07-01 thomas ret=$?
1635 19dd85cb 2022-07-01 thomas if [ $ret -ne 0 ]; then
1636 19dd85cb 2022-07-01 thomas test_done $testroot $ret
1637 19dd85cb 2022-07-01 thomas return 1
1638 19dd85cb 2022-07-01 thomas fi
1639 19dd85cb 2022-07-01 thomas
1640 19dd85cb 2022-07-01 thomas # now work with got:
1641 19dd85cb 2022-07-01 thomas got checkout $testroot/repo $testroot/wt > /dev/null
1642 19dd85cb 2022-07-01 thomas ret=$?
1643 19dd85cb 2022-07-01 thomas if [ $ret -ne 0 ]; then
1644 19dd85cb 2022-07-01 thomas test_done $testroot $ret
1645 19dd85cb 2022-07-01 thomas return 1
1646 19dd85cb 2022-07-01 thomas fi
1647 19dd85cb 2022-07-01 thomas
1648 19dd85cb 2022-07-01 thomas (cd $testroot/wt && got patch $testroot/old.diff) > $testroot/stdout
1649 19dd85cb 2022-07-01 thomas ret=$?
1650 19dd85cb 2022-07-01 thomas if [ $ret -ne 0 ]; then
1651 19dd85cb 2022-07-01 thomas test_done $testroot $ret
1652 19dd85cb 2022-07-01 thomas return 1
1653 0f76ab83 2022-06-23 thomas fi
1654 19dd85cb 2022-07-01 thomas
1655 19dd85cb 2022-07-01 thomas echo 'G numbers' > $testroot/stdout.expected
1656 19dd85cb 2022-07-01 thomas cmp -s $testroot/stdout $testroot/stdout.expected
1657 19dd85cb 2022-07-01 thomas ret=$?
1658 19dd85cb 2022-07-01 thomas if [ $ret -ne 0 ]; then
1659 19dd85cb 2022-07-01 thomas diff -u $testroot/stdout $testroot/stdout.expected
1660 19dd85cb 2022-07-01 thomas fi
1661 0f76ab83 2022-06-23 thomas test_done $testroot $ret
1662 0f76ab83 2022-06-23 thomas }
1663 0f76ab83 2022-06-23 thomas
1664 0f76ab83 2022-06-23 thomas test_patch_merge_conflict() {
1665 0f76ab83 2022-06-23 thomas local testroot=`test_init patch_merge_conflict`
1666 0f76ab83 2022-06-23 thomas
1667 0f76ab83 2022-06-23 thomas got checkout $testroot/repo $testroot/wt > /dev/null
1668 0f76ab83 2022-06-23 thomas ret=$?
1669 0f76ab83 2022-06-23 thomas if [ $ret -ne 0 ]; then
1670 0f76ab83 2022-06-23 thomas test_done $testroot $ret
1671 0f76ab83 2022-06-23 thomas return 1
1672 0f76ab83 2022-06-23 thomas fi
1673 0f76ab83 2022-06-23 thomas
1674 0f76ab83 2022-06-23 thomas jot 10 > $testroot/wt/numbers
1675 0f76ab83 2022-06-23 thomas (cd $testroot/wt && got add numbers && got commit -m +numbers) \
1676 0f76ab83 2022-06-23 thomas > /dev/null
1677 0f76ab83 2022-06-23 thomas ret=$?
1678 0f76ab83 2022-06-23 thomas if [ $ret -ne 0 ]; then
1679 0f76ab83 2022-06-23 thomas test_done $testroot $ret
1680 0f76ab83 2022-06-23 thomas return 1
1681 0f76ab83 2022-06-23 thomas fi
1682 016bfe4b 2022-06-23 thomas
1683 016bfe4b 2022-06-23 thomas local commit_id=`git_show_head $testroot/repo`
1684 0f76ab83 2022-06-23 thomas
1685 0f76ab83 2022-06-23 thomas jot 10 | sed 's/6/six/g' > $testroot/wt/numbers
1686 68ceedb3 2022-07-03 thomas echo ALPHA > $testroot/wt/alpha
1687 0f76ab83 2022-06-23 thomas
1688 0f76ab83 2022-06-23 thomas (cd $testroot/wt && got diff > $testroot/old.diff \
1689 68ceedb3 2022-07-03 thomas && got revert alpha numbers) >/dev/null
1690 0f76ab83 2022-06-23 thomas ret=$?
1691 0f76ab83 2022-06-23 thomas if [ $ret -ne 0 ]; then
1692 0f76ab83 2022-06-23 thomas test_done $testroot $ret
1693 0f76ab83 2022-06-23 thomas return 1
1694 0f76ab83 2022-06-23 thomas fi
1695 0f76ab83 2022-06-23 thomas
1696 0f76ab83 2022-06-23 thomas jot 10 | sed 's/6/3+3/g' > $testroot/wt/numbers
1697 68ceedb3 2022-07-03 thomas jot -c 3 a > $testroot/wt/alpha
1698 68ceedb3 2022-07-03 thomas (cd $testroot/wt && got commit -m 'edit alpha and numbers') \
1699 0f76ab83 2022-06-23 thomas > /dev/null
1700 0f76ab83 2022-06-23 thomas ret=$?
1701 0f76ab83 2022-06-23 thomas if [ $ret -ne 0 ]; then
1702 0f76ab83 2022-06-23 thomas test_done $testroot $ret
1703 0f76ab83 2022-06-23 thomas return 1
1704 eaef698f 2022-04-23 thomas fi
1705 0f76ab83 2022-06-23 thomas
1706 0f76ab83 2022-06-23 thomas (cd $testroot/wt && got patch $testroot/old.diff) \
1707 762b8e82 2022-06-23 thomas > $testroot/stdout 2>/dev/null
1708 0f76ab83 2022-06-23 thomas ret=$?
1709 0f76ab83 2022-06-23 thomas if [ $ret -eq 0 ]; then
1710 0f76ab83 2022-06-23 thomas echo "got patch merged a diff that should conflict" >&2
1711 0f76ab83 2022-06-23 thomas test_done $testroot 0
1712 0f76ab83 2022-06-23 thomas return 1
1713 0f76ab83 2022-06-23 thomas fi
1714 0f76ab83 2022-06-23 thomas
1715 68ceedb3 2022-07-03 thomas echo 'C alpha' > $testroot/stdout.expected
1716 68ceedb3 2022-07-03 thomas echo 'C numbers' >> $testroot/stdout.expected
1717 762b8e82 2022-06-23 thomas cmp -s $testroot/stdout $testroot/stdout.expected
1718 762b8e82 2022-06-23 thomas ret=$?
1719 762b8e82 2022-06-23 thomas if [ $ret -ne 0 ]; then
1720 762b8e82 2022-06-23 thomas diff -u $testroot/stdout $testroot/stdout.expected
1721 762b8e82 2022-06-23 thomas test_done $testroot $ret
1722 762b8e82 2022-06-23 thomas return 1
1723 762b8e82 2022-06-23 thomas fi
1724 762b8e82 2022-06-23 thomas
1725 0f76ab83 2022-06-23 thomas # XXX: prefixing every line with a tab otherwise got thinks
1726 0f76ab83 2022-06-23 thomas # the file has conflicts in it.
1727 68ceedb3 2022-07-03 thomas cat <<-EOF > $testroot/wt/alpha.expected
1728 68ceedb3 2022-07-03 thomas <<<<<<< --- alpha
1729 68ceedb3 2022-07-03 thomas ALPHA
1730 68ceedb3 2022-07-03 thomas ||||||| commit $commit_id
1731 68ceedb3 2022-07-03 thomas alpha
1732 68ceedb3 2022-07-03 thomas =======
1733 68ceedb3 2022-07-03 thomas a
1734 68ceedb3 2022-07-03 thomas b
1735 68ceedb3 2022-07-03 thomas c
1736 68ceedb3 2022-07-03 thomas >>>>>>> +++ alpha
1737 68ceedb3 2022-07-03 thomas EOF
1738 68ceedb3 2022-07-03 thomas
1739 0f76ab83 2022-06-23 thomas cat <<-EOF > $testroot/wt/numbers.expected
1740 0f76ab83 2022-06-23 thomas 1
1741 0f76ab83 2022-06-23 thomas 2
1742 0f76ab83 2022-06-23 thomas 3
1743 0f76ab83 2022-06-23 thomas 4
1744 0f76ab83 2022-06-23 thomas 5
1745 0f76ab83 2022-06-23 thomas <<<<<<< --- numbers
1746 0f76ab83 2022-06-23 thomas six
1747 016bfe4b 2022-06-23 thomas ||||||| commit $commit_id
1748 0f76ab83 2022-06-23 thomas 6
1749 0f76ab83 2022-06-23 thomas =======
1750 0f76ab83 2022-06-23 thomas 3+3
1751 0f76ab83 2022-06-23 thomas >>>>>>> +++ numbers
1752 0f76ab83 2022-06-23 thomas 7
1753 0f76ab83 2022-06-23 thomas 8
1754 0f76ab83 2022-06-23 thomas 9
1755 0f76ab83 2022-06-23 thomas 10
1756 0f76ab83 2022-06-23 thomas EOF
1757 0f76ab83 2022-06-23 thomas
1758 68ceedb3 2022-07-03 thomas cmp -s $testroot/wt/alpha $testroot/wt/alpha.expected
1759 68ceedb3 2022-07-03 thomas ret=$?
1760 68ceedb3 2022-07-03 thomas if [ $ret -ne 0 ]; then
1761 68ceedb3 2022-07-03 thomas diff -u $testroot/wt/alpha $testroot/wt/alpha.expected
1762 68ceedb3 2022-07-03 thomas test_done $testroot $ret
1763 68ceedb3 2022-07-03 thomas return 1
1764 68ceedb3 2022-07-03 thomas fi
1765 68ceedb3 2022-07-03 thomas
1766 0f76ab83 2022-06-23 thomas cmp -s $testroot/wt/numbers $testroot/wt/numbers.expected
1767 0f76ab83 2022-06-23 thomas ret=$?
1768 0f76ab83 2022-06-23 thomas if [ $ret -ne 0 ]; then
1769 0f76ab83 2022-06-23 thomas diff -u $testroot/wt/numbers $testroot/wt/numbers.expected
1770 0f76ab83 2022-06-23 thomas fi
1771 eaef698f 2022-04-23 thomas test_done $testroot $ret
1772 eaef698f 2022-04-23 thomas }
1773 eaef698f 2022-04-23 thomas
1774 0f76ab83 2022-06-23 thomas test_patch_merge_unknown_blob() {
1775 0f76ab83 2022-06-23 thomas local testroot=`test_init patch_merge_unknown_blob`
1776 0f76ab83 2022-06-23 thomas
1777 0f76ab83 2022-06-23 thomas got checkout $testroot/repo $testroot/wt > /dev/null
1778 0f76ab83 2022-06-23 thomas ret=$?
1779 0f76ab83 2022-06-23 thomas if [ $ret -ne 0 ]; then
1780 0f76ab83 2022-06-23 thomas test_done $testroot $ret
1781 0f76ab83 2022-06-23 thomas return 1
1782 0f76ab83 2022-06-23 thomas fi
1783 0f76ab83 2022-06-23 thomas
1784 0f76ab83 2022-06-23 thomas cat <<EOF > $testroot/wt/patch
1785 0f76ab83 2022-06-23 thomas I've got a
1786 c9a4f4fa 2022-06-23 thomas diff aaaabbbbccccddddeeeeffff0000111122223333 foo/bar
1787 c9a4f4fa 2022-06-23 thomas with a
1788 0f76ab83 2022-06-23 thomas blob - aaaabbbbccccddddeeeeffff0000111122223333
1789 0f76ab83 2022-06-23 thomas and also a
1790 c9a4f4fa 2022-06-23 thomas blob + 0000111122223333444455556666777788889999
1791 0f76ab83 2022-06-23 thomas for this dummy diff
1792 0f76ab83 2022-06-23 thomas --- alpha
1793 0f76ab83 2022-06-23 thomas +++ alpha
1794 0f76ab83 2022-06-23 thomas @@ -1 +1 @@
1795 0f76ab83 2022-06-23 thomas -alpha
1796 0f76ab83 2022-06-23 thomas +ALPHA
1797 0f76ab83 2022-06-23 thomas will it work?
1798 0f76ab83 2022-06-23 thomas EOF
1799 0f76ab83 2022-06-23 thomas
1800 0f76ab83 2022-06-23 thomas (cd $testroot/wt/ && got patch patch) > $testroot/stdout
1801 0f76ab83 2022-06-23 thomas ret=$?
1802 0f76ab83 2022-06-23 thomas if [ $ret -ne 0 ]; then
1803 0f76ab83 2022-06-23 thomas test_done $testroot $ret
1804 0f76ab83 2022-06-23 thomas return 1
1805 0f76ab83 2022-06-23 thomas fi
1806 0f76ab83 2022-06-23 thomas
1807 0f76ab83 2022-06-23 thomas echo 'M alpha' > $testroot/stdout.expected
1808 0f76ab83 2022-06-23 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1809 0f76ab83 2022-06-23 thomas ret=$?
1810 0f76ab83 2022-06-23 thomas if [ $ret -ne 0 ]; then
1811 0f76ab83 2022-06-23 thomas diff -u $testroot/stdout.expected $testroot/stdout
1812 c9a4f4fa 2022-06-23 thomas test_done $testroot $ret
1813 c9a4f4fa 2022-06-23 thomas return 1
1814 0f76ab83 2022-06-23 thomas fi
1815 c9a4f4fa 2022-06-23 thomas
1816 c9a4f4fa 2022-06-23 thomas # try again without a `diff' header
1817 c9a4f4fa 2022-06-23 thomas
1818 c9a4f4fa 2022-06-23 thomas cat <<EOF > $testroot/wt/patch
1819 c9a4f4fa 2022-06-23 thomas I've got a
1820 c9a4f4fa 2022-06-23 thomas blob - aaaabbbbccccddddeeeeffff0000111122223333
1821 c9a4f4fa 2022-06-23 thomas and also a
1822 c9a4f4fa 2022-06-23 thomas blob + 0000111122223333444455556666777788889999
1823 c9a4f4fa 2022-06-23 thomas for this dummy diff
1824 c9a4f4fa 2022-06-23 thomas --- alpha
1825 c9a4f4fa 2022-06-23 thomas +++ alpha
1826 c9a4f4fa 2022-06-23 thomas @@ -1 +1 @@
1827 c9a4f4fa 2022-06-23 thomas -alpha
1828 c9a4f4fa 2022-06-23 thomas +ALPHA
1829 c9a4f4fa 2022-06-23 thomas will it work?
1830 c9a4f4fa 2022-06-23 thomas EOF
1831 c9a4f4fa 2022-06-23 thomas
1832 c9a4f4fa 2022-06-23 thomas (cd $testroot/wt && got revert alpha > /dev/null && got patch patch) \
1833 c9a4f4fa 2022-06-23 thomas > $testroot/stdout
1834 c9a4f4fa 2022-06-23 thomas ret=$?
1835 c9a4f4fa 2022-06-23 thomas if [ $ret -ne 0 ]; then
1836 c9a4f4fa 2022-06-23 thomas test_done $testroot $ret
1837 c9a4f4fa 2022-06-23 thomas return 1
1838 c9a4f4fa 2022-06-23 thomas fi
1839 c9a4f4fa 2022-06-23 thomas
1840 c9a4f4fa 2022-06-23 thomas echo 'M alpha' > $testroot/stdout.expected
1841 c9a4f4fa 2022-06-23 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1842 c9a4f4fa 2022-06-23 thomas ret=$?
1843 c9a4f4fa 2022-06-23 thomas if [ $ret -ne 0 ]; then
1844 c9a4f4fa 2022-06-23 thomas diff -u $testroot/stdout.expected $testroot/stdout
1845 19dd85cb 2022-07-01 thomas test_done $testroot $ret
1846 19dd85cb 2022-07-01 thomas return 1
1847 c9a4f4fa 2022-06-23 thomas fi
1848 19dd85cb 2022-07-01 thomas
1849 19dd85cb 2022-07-01 thomas # try again with a git-style diff
1850 19dd85cb 2022-07-01 thomas
1851 19dd85cb 2022-07-01 thomas cat <<EOF > $testroot/wt/patch
1852 19dd85cb 2022-07-01 thomas diff --git a/alpha b/alpha
1853 19dd85cb 2022-07-01 thomas index 0123456789ab..abcdef012345 100644
1854 19dd85cb 2022-07-01 thomas --- a/alpha
1855 19dd85cb 2022-07-01 thomas +++ b/alpha
1856 19dd85cb 2022-07-01 thomas @@ -1 +1 @@
1857 19dd85cb 2022-07-01 thomas -alpha
1858 19dd85cb 2022-07-01 thomas +ALPHA
1859 19dd85cb 2022-07-01 thomas EOF
1860 19dd85cb 2022-07-01 thomas
1861 19dd85cb 2022-07-01 thomas (cd $testroot/wt && got revert alpha > /dev/null && got patch patch) \
1862 19dd85cb 2022-07-01 thomas > $testroot/stdout
1863 19dd85cb 2022-07-01 thomas ret=$?
1864 19dd85cb 2022-07-01 thomas if [ $ret -ne 0 ]; then
1865 19dd85cb 2022-07-01 thomas test_done $testroot $ret
1866 19dd85cb 2022-07-01 thomas return 1
1867 19dd85cb 2022-07-01 thomas fi
1868 19dd85cb 2022-07-01 thomas
1869 19dd85cb 2022-07-01 thomas echo 'M alpha' > $testroot/stdout.expected
1870 19dd85cb 2022-07-01 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1871 19dd85cb 2022-07-01 thomas ret=$?
1872 19dd85cb 2022-07-01 thomas if [ $ret -ne 0 ]; then
1873 19dd85cb 2022-07-01 thomas diff -u $testroot/stdout.expected $testroot/stdout
1874 19dd85cb 2022-07-01 thomas fi
1875 0f76ab83 2022-06-23 thomas test_done $testroot $ret
1876 0f76ab83 2022-06-23 thomas }
1877 0f76ab83 2022-06-23 thomas
1878 069bbb86 2022-03-07 thomas test_parseargs "$@"
1879 8d8dc2a3 2022-07-03 thomas run_test test_patch_add_file
1880 762e07b8 2022-07-03 thomas run_test test_patch_rm_file
1881 069bbb86 2022-03-07 thomas run_test test_patch_simple_edit_file
1882 069bbb86 2022-03-07 thomas run_test test_patch_prepend_line
1883 069bbb86 2022-03-07 thomas run_test test_patch_replace_line
1884 069bbb86 2022-03-07 thomas run_test test_patch_multiple_hunks
1885 069bbb86 2022-03-07 thomas run_test test_patch_multiple_files
1886 069bbb86 2022-03-07 thomas run_test test_patch_dont_apply
1887 069bbb86 2022-03-07 thomas run_test test_patch_malformed
1888 069bbb86 2022-03-07 thomas run_test test_patch_no_patch
1889 069bbb86 2022-03-07 thomas run_test test_patch_equals_for_context
1890 bb2ad8ff 2022-03-13 thomas run_test test_patch_rename
1891 10e55613 2022-03-22 thomas run_test test_patch_illegal_status
1892 eaf99875 2022-03-22 thomas run_test test_patch_nop
1893 da09d8ed 2022-03-22 thomas run_test test_patch_preserve_perm
1894 e0c1f81c 2022-03-22 thomas run_test test_patch_create_dirs
1895 49114f01 2022-03-22 thomas run_test test_patch_with_offset
1896 be53ddb1 2022-03-22 thomas run_test test_patch_prefer_new_path
1897 ff7f34d3 2022-03-22 thomas run_test test_patch_no_newline
1898 d9db2ff9 2022-04-16 thomas run_test test_patch_strip
1899 bb90ca7b 2022-07-03 thomas run_test test_patch_whitespace
1900 72f46891 2022-04-23 thomas run_test test_patch_relative_paths
1901 cfbf5531 2022-04-23 thomas run_test test_patch_with_path_prefix
1902 cfbf5531 2022-04-23 thomas run_test test_patch_relpath_with_path_prefix
1903 eaef698f 2022-04-23 thomas run_test test_patch_reverse
1904 0f76ab83 2022-06-23 thomas run_test test_patch_merge_simple
1905 19dd85cb 2022-07-01 thomas run_test test_patch_merge_gitdiff
1906 0f76ab83 2022-06-23 thomas run_test test_patch_merge_conflict
1907 0f76ab83 2022-06-23 thomas run_test test_patch_merge_unknown_blob