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