3 e9ce266e 2022-03-07 op # Copyright (c) 2022 Omar Polo <op@openbsd.org>
5 e9ce266e 2022-03-07 op # Permission to use, copy, modify, and distribute this software for any
6 e9ce266e 2022-03-07 op # purpose with or without fee is hereby granted, provided that the above
7 e9ce266e 2022-03-07 op # copyright notice and this permission notice appear in all copies.
9 e9ce266e 2022-03-07 op # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 e9ce266e 2022-03-07 op # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 e9ce266e 2022-03-07 op # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 e9ce266e 2022-03-07 op # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 e9ce266e 2022-03-07 op # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 e9ce266e 2022-03-07 op # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 e9ce266e 2022-03-07 op # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 57b1c3f2 2022-08-01 op test_patch_basic() {
20 57b1c3f2 2022-08-01 op local testroot=`test_init patch_basic`
22 e9ce266e 2022-03-07 op got checkout $testroot/repo $testroot/wt > /dev/null
24 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
25 e9ce266e 2022-03-07 op test_done $testroot $ret
29 57b1c3f2 2022-08-01 op jot 100 > $testroot/wt/numbers
30 57b1c3f2 2022-08-01 op (cd $testroot/wt && got add numbers && got commit -m +numbers) \
33 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
34 57b1c3f2 2022-08-01 op test_done "$testroot" $ret
38 e9ce266e 2022-03-07 op cat <<EOF > $testroot/wt/patch
43 e9ce266e 2022-03-07 op +alpha is my favourite character
48 57b1c3f2 2022-08-01 op --- gamma/delta
49 57b1c3f2 2022-08-01 op +++ gamma/delta
55 57b1c3f2 2022-08-01 op @@ -0,0 +5,5 @@
63 e9ce266e 2022-03-07 op @@ -3,7 +3,7 @@
72 e9ce266e 2022-03-07 op @@ -57,7 +57,7 @@
81 e9ce266e 2022-03-07 op @@ -98,3 +98,6 @@
90 9cda65e5 2022-10-15 stsp (cd $testroot/wt && got patch < patch) > $testroot/stdout
91 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
92 57b1c3f2 2022-08-01 op test_done "$testroot" $ret
96 57b1c3f2 2022-08-01 op echo 'M alpha' > $testroot/stdout.expected
97 57b1c3f2 2022-08-01 op echo 'D beta' >> $testroot/stdout.expected
98 57b1c3f2 2022-08-01 op echo 'M gamma/delta' >> $testroot/stdout.expected
99 57b1c3f2 2022-08-01 op echo 'A eta' >> $testroot/stdout.expected
100 57b1c3f2 2022-08-01 op echo 'M numbers' >> $testroot/stdout.expected
102 e9ce266e 2022-03-07 op cmp -s $testroot/stdout.expected $testroot/stdout
104 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
105 e9ce266e 2022-03-07 op diff -u $testroot/stdout.expected $testroot/stdout
106 e9ce266e 2022-03-07 op test_done $testroot $ret
110 57b1c3f2 2022-08-01 op echo 'alpha is my favourite character' > $testroot/wt/alpha.expected
111 57b1c3f2 2022-08-01 op cmp -s $testroot/wt/alpha.expected $testroot/wt/alpha
113 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
114 57b1c3f2 2022-08-01 op diff -u $testroot/wt/alpha.expected $testroot/wt/alpha
115 57b1c3f2 2022-08-01 op test_done "$testroot" $ret
119 57b1c3f2 2022-08-01 op if [ -f "$testroot/wt/beta" ]; then
120 57b1c3f2 2022-08-01 op echo "beta was not deleted!" >&2
121 57b1c3f2 2022-08-01 op test_done "$testroot" 1
125 57b1c3f2 2022-08-01 op echo 'this is:' > $testroot/wt/gamma/delta.expected
126 57b1c3f2 2022-08-01 op echo 'delta' >> $testroot/wt/gamma/delta.expected
127 57b1c3f2 2022-08-01 op cmp -s $testroot/wt/gamma/delta.expected $testroot/wt/gamma/delta
129 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
130 57b1c3f2 2022-08-01 op diff -u $testroot/wt/gamma/delta.expected $testroot/wt/gamma/delta
131 57b1c3f2 2022-08-01 op test_done "$testroot" $ret
135 57b1c3f2 2022-08-01 op jot 5 > $testroot/wt/eta.expected
136 57b1c3f2 2022-08-01 op cmp -s $testroot/wt/eta.expected $testroot/wt/eta
138 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
139 57b1c3f2 2022-08-01 op diff -u $testroot/wt/eta.expected $testroot/wt/eta
140 57b1c3f2 2022-08-01 op test_done "$testroot" $ret
144 57b1c3f2 2022-08-01 op jot 103 | sed -e 's/^6$/six/' -e 's/60/sixty/' \
145 57b1c3f2 2022-08-01 op > $testroot/wt/numbers.expected
146 57b1c3f2 2022-08-01 op cmp -s $testroot/wt/numbers.expected $testroot/wt/numbers
148 57b1c3f2 2022-08-01 op if [ $ret -ne 0 ]; then
149 57b1c3f2 2022-08-01 op diff -u $testroot/wt/numbers.expected $testroot/wt/numbers
151 57b1c3f2 2022-08-01 op test_done $testroot $ret
154 e9ce266e 2022-03-07 op test_patch_dont_apply() {
155 e9ce266e 2022-03-07 op local testroot=`test_init patch_dont_apply`
157 e9ce266e 2022-03-07 op got checkout $testroot/repo $testroot/wt > /dev/null
159 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
160 e9ce266e 2022-03-07 op test_done $testroot $ret
164 5b67f96e 2022-03-13 op jot 100 > $testroot/wt/numbers
165 5b67f96e 2022-03-13 op (cd $testroot/wt && got add numbers && got commit -m 'add numbers') \
168 5b67f96e 2022-03-13 op if [ $ret -ne 0 ]; then
169 5b67f96e 2022-03-13 op test_done $testroot $ret
173 5b67f96e 2022-03-13 op cat <<EOF > $testroot/wt/patch
176 60aa1fa0 2022-03-17 op @@ -1 +1,2 @@
178 60aa1fa0 2022-03-17 op alpha something
180 5b67f96e 2022-03-13 op +++ /dev/null
181 5b67f96e 2022-03-13 op @@ -1,9 +0,0 @@
193 60aa1fa0 2022-03-17 op (cd $testroot/wt && got patch patch) > $testroot/stdout 2> /dev/null
195 5b67f96e 2022-03-13 op if [ $ret -eq 0 ]; then # should fail
196 5b67f96e 2022-03-13 op test_done $testroot 1
200 60aa1fa0 2022-03-17 op cat <<EOF > $testroot/stdout.expected
202 60aa1fa0 2022-03-17 op @@ -1,1 +1,2 @@ hunk failed to apply
204 60aa1fa0 2022-03-17 op @@ -1,9 +0,0 @@ hunk failed to apply
205 bfcdc9e9 2023-05-11 stsp Files where patch failed to apply: 2
208 60aa1fa0 2022-03-17 op cmp -s $testroot/stdout.expected $testroot/stdout
210 5b67f96e 2022-03-13 op if [ $ret -ne 0 ]; then
211 60aa1fa0 2022-03-17 op diff -u $testroot/stdout.expected $testroot/stdout
213 e9ce266e 2022-03-07 op test_done $testroot $ret
216 e9ce266e 2022-03-07 op test_patch_malformed() {
217 e9ce266e 2022-03-07 op local testroot=`test_init patch_malformed`
219 e9ce266e 2022-03-07 op got checkout $testroot/repo $testroot/wt > /dev/null
221 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
222 e9ce266e 2022-03-07 op test_done $testroot $ret
226 e9ce266e 2022-03-07 op # missing "@@"
227 e9ce266e 2022-03-07 op cat <<EOF > $testroot/wt/patch
235 e9ce266e 2022-03-07 op echo -n > $testroot/stdout.expected
236 e9ce266e 2022-03-07 op echo "got: malformed patch" > $testroot/stderr.expected
238 e9ce266e 2022-03-07 op (cd $testroot/wt && got patch patch) \
239 e9ce266e 2022-03-07 op > $testroot/stdout \
240 e9ce266e 2022-03-07 op 2> $testroot/stderr
242 bfbccd0a 2022-03-08 op if [ $ret -eq 0 ]; then
243 e9ce266e 2022-03-07 op echo "got managed to apply an invalid patch"
244 e9ce266e 2022-03-07 op test_done $testroot 1
248 e9ce266e 2022-03-07 op cmp -s $testroot/stdout.expected $testroot/stdout
250 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
251 e9ce266e 2022-03-07 op diff -u $testroot/stdout.expected $testroot/stdout
252 e9ce266e 2022-03-07 op test_done $testroot $ret
256 e9ce266e 2022-03-07 op cmp -s $testroot/stderr.expected $testroot/stderr
258 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
259 e9ce266e 2022-03-07 op diff -u $testroot/stderr.expected $testroot/stderr
260 e9ce266e 2022-03-07 op test_done $testroot $ret
264 e9ce266e 2022-03-07 op # wrong first character
265 e9ce266e 2022-03-07 op cat <<EOF > $testroot/wt/patch
268 e9ce266e 2022-03-07 op @@ -1 +1,2 @@
273 be33dff7 2022-05-13 op (cd $testroot/wt && got patch patch) \
274 be33dff7 2022-05-13 op > $testroot/stdout \
275 be33dff7 2022-05-13 op 2> $testroot/stderr
277 be33dff7 2022-05-13 op if [ $ret -eq 0 ]; then
278 be33dff7 2022-05-13 op echo "got managed to apply an invalid patch"
279 be33dff7 2022-05-13 op test_done $testroot 1
283 be33dff7 2022-05-13 op cmp -s $testroot/stdout.expected $testroot/stdout
285 be33dff7 2022-05-13 op if [ $ret -ne 0 ]; then
286 be33dff7 2022-05-13 op diff -u $testroot/stdout.expected $testroot/stdout
287 be33dff7 2022-05-13 op test_done $testroot $ret
291 be33dff7 2022-05-13 op cmp -s $testroot/stderr.expected $testroot/stderr
293 be33dff7 2022-05-13 op if [ $ret -ne 0 ]; then
294 be33dff7 2022-05-13 op diff -u $testroot/stderr.expected $testroot/stderr
295 be33dff7 2022-05-13 op test_done $testroot $ret
300 be33dff7 2022-05-13 op cat <<EOF > $testroot/wt/patch
301 be33dff7 2022-05-13 op diff --git a/alpha b/iota
304 be33dff7 2022-05-13 op @@ -0,0 +0,0 @@
307 e9ce266e 2022-03-07 op (cd $testroot/wt && got patch patch) \
308 e9ce266e 2022-03-07 op > $testroot/stdout \
309 e9ce266e 2022-03-07 op 2> $testroot/stderr
311 bfbccd0a 2022-03-08 op if [ $ret -eq 0 ]; then
312 e9ce266e 2022-03-07 op echo "got managed to apply an invalid patch"
313 e9ce266e 2022-03-07 op test_done $testroot 1
317 e9ce266e 2022-03-07 op cmp -s $testroot/stdout.expected $testroot/stdout
319 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
320 e9ce266e 2022-03-07 op diff -u $testroot/stdout.expected $testroot/stdout
321 e9ce266e 2022-03-07 op test_done $testroot $ret
325 e9ce266e 2022-03-07 op cmp -s $testroot/stderr.expected $testroot/stderr
327 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
328 e9ce266e 2022-03-07 op diff -u $testroot/stderr.expected $testroot/stderr
329 e9ce266e 2022-03-07 op test_done $testroot $ret
333 e9ce266e 2022-03-07 op test_done $testroot $ret
336 e9ce266e 2022-03-07 op test_patch_no_patch() {
337 e9ce266e 2022-03-07 op local testroot=`test_init patch_no_patch`
339 e9ce266e 2022-03-07 op got checkout $testroot/repo $testroot/wt > /dev/null
341 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
342 e9ce266e 2022-03-07 op test_done $testroot $ret
346 e9ce266e 2022-03-07 op cat <<EOF > $testroot/wt/patch
350 e9ce266e 2022-03-07 op some other nonsense
353 e9ce266e 2022-03-07 op there's no patch in here!
356 e9ce266e 2022-03-07 op echo -n > $testroot/stdout.expected
357 e9ce266e 2022-03-07 op echo "got: no patch found" > $testroot/stderr.expected
359 e9ce266e 2022-03-07 op (cd $testroot/wt && got patch patch) \
360 e9ce266e 2022-03-07 op > $testroot/stdout \
361 e9ce266e 2022-03-07 op 2> $testroot/stderr
363 bfbccd0a 2022-03-08 op if [ $ret -eq 0 ]; then # should fail
364 e9ce266e 2022-03-07 op test_done $testroot 1
368 e9ce266e 2022-03-07 op cmp -s $testroot/stdout.expected $testroot/stdout
370 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
371 e9ce266e 2022-03-07 op diff -u $testroot/stdout.expected $testroot/stdout
372 e9ce266e 2022-03-07 op test_done $testroot $ret
376 e9ce266e 2022-03-07 op cmp -s $testroot/stderr.expected $testroot/stderr
378 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
379 e9ce266e 2022-03-07 op diff -u $testroot/stderr.expected $testroot/stderr
380 e9ce266e 2022-03-07 op test_done $testroot $ret
384 e9ce266e 2022-03-07 op test_done $testroot $ret
387 e9ce266e 2022-03-07 op test_patch_equals_for_context() {
388 f1d6cebb 2022-04-23 op local testroot=`test_init patch_equals_for_context`
390 e9ce266e 2022-03-07 op got checkout $testroot/repo $testroot/wt > /dev/null
392 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
393 e9ce266e 2022-03-07 op test_done $testroot $ret
397 e9ce266e 2022-03-07 op cat <<EOF > $testroot/wt/patch
400 e9ce266e 2022-03-07 op @@ -1 +1,2 @@
405 e9ce266e 2022-03-07 op echo "M alpha" > $testroot/stdout.expected
407 e9ce266e 2022-03-07 op (cd $testroot/wt && got patch patch) > $testroot/stdout
409 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
410 e9ce266e 2022-03-07 op test_done $testroot $ret
414 e9ce266e 2022-03-07 op cmp -s $testroot/stdout.expected $testroot/stdout
416 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
417 e9ce266e 2022-03-07 op diff -u $testroot/stdout.expected $testroot/stdout
418 e9ce266e 2022-03-07 op test_done $testroot $ret
422 e9ce266e 2022-03-07 op echo hatsuseno > $testroot/wt/alpha.expected
423 e9ce266e 2022-03-07 op echo alpha >> $testroot/wt/alpha.expected
424 e9ce266e 2022-03-07 op cmp -s $testroot/wt/alpha.expected $testroot/wt/alpha
426 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
427 e9ce266e 2022-03-07 op diff -u $testroot/wt/alpha.expected $testroot/wt/alpha
429 e9ce266e 2022-03-07 op test_done $testroot $ret
432 6e96b326 2022-03-12 op test_patch_rename() {
433 6e96b326 2022-03-12 op local testroot=`test_init patch_rename`
435 6e96b326 2022-03-12 op got checkout $testroot/repo $testroot/wt > /dev/null
437 6e96b326 2022-03-12 op if [ $ret -ne 0 ]; then
438 6e96b326 2022-03-12 op test_done $testroot $ret
442 6e96b326 2022-03-12 op cat <<EOF > $testroot/wt/patch
443 4379a9aa 2022-05-02 op diff --git a/beta b/iota
444 4379a9aa 2022-05-02 op similarity index 100%
445 4379a9aa 2022-05-02 op rename from beta
446 4379a9aa 2022-05-02 op rename to iota
447 7a30b5cb 2022-03-20 op diff --git a/alpha b/eta
455 4379a9aa 2022-05-02 op echo 'D beta' > $testroot/stdout.expected
456 4379a9aa 2022-05-02 op echo 'A iota' >> $testroot/stdout.expected
457 4379a9aa 2022-05-02 op echo 'D alpha' >> $testroot/stdout.expected
458 4379a9aa 2022-05-02 op echo 'A eta' >> $testroot/stdout.expected
460 6e96b326 2022-03-12 op (cd $testroot/wt && got patch patch) > $testroot/stdout
462 6e96b326 2022-03-12 op if [ $ret -ne 0 ]; then
463 6e96b326 2022-03-12 op test_done $testroot $ret
467 6e96b326 2022-03-12 op cmp -s $testroot/stdout.expected $testroot/stdout
469 6e96b326 2022-03-12 op if [ $ret -ne 0 ]; then
470 6e96b326 2022-03-12 op diff -u $testroot/stdout.expected $testroot/stdout
471 6e96b326 2022-03-12 op test_done $testroot $ret
475 4379a9aa 2022-05-02 op if [ -f $testroot/wt/alpha -o -f $testroot/wt/beta ]; then
476 4379a9aa 2022-05-02 op echo "alpha or beta were not removed" >&2
477 6e96b326 2022-03-12 op test_done $testroot 1
480 4379a9aa 2022-05-02 op if [ ! -f $testroot/wt/iota -o ! -f $testroot/wt/eta ]; then
481 4379a9aa 2022-05-02 op echo "iota or eta were not created" >&2
482 6e96b326 2022-03-12 op test_done $testroot 1
486 4379a9aa 2022-05-02 op echo beta > $testroot/wt/iota.expected
487 4379a9aa 2022-05-02 op cmp -s $testroot/wt/iota.expected $testroot/wt/iota
489 6e96b326 2022-03-12 op if [ $ret -ne 0 ]; then
490 4379a9aa 2022-05-02 op diff -u $testroot/wt/iota.expected $testroot/wt/iota
491 6e96b326 2022-03-12 op test_done $testroot $ret
495 4379a9aa 2022-05-02 op echo eta > $testroot/wt/eta.expected
496 4379a9aa 2022-05-02 op cmp -s $testroot/wt/eta.expected $testroot/wt/eta
498 6e96b326 2022-03-12 op if [ $ret -ne 0 ]; then
499 4379a9aa 2022-05-02 op diff -u $testroot/wt/eta.expected $testroot/wt/eta
500 6e96b326 2022-03-12 op test_done $testroot $ret
504 6e96b326 2022-03-12 op test_done $testroot $ret
507 dbda770b 2022-03-13 op test_patch_illegal_status() {
508 dbda770b 2022-03-13 op local testroot=`test_init patch_illegal_status`
510 dbda770b 2022-03-13 op got checkout $testroot/repo $testroot/wt > /dev/null
512 dbda770b 2022-03-13 op if [ $ret -ne 0 ]; then
513 dbda770b 2022-03-13 op test_done $testroot $ret
517 60aa1fa0 2022-03-17 op # try to patch an obstructed file, add a versioned one, edit a
518 60aa1fa0 2022-03-17 op # non existent file and an unversioned one, and remove a
519 60aa1fa0 2022-03-17 op # non existent file.
520 dbda770b 2022-03-13 op cat <<EOF > $testroot/wt/patch
523 60aa1fa0 2022-03-17 op @@ -1 +1,2 @@
526 60aa1fa0 2022-03-17 op --- /dev/null
528 60aa1fa0 2022-03-17 op @@ -0,0 +1 @@
541 60aa1fa0 2022-03-17 op +++ /dev/null
542 60aa1fa0 2022-03-17 op @@ -1 +0,0 @@
546 60aa1fa0 2022-03-17 op echo kappa > $testroot/wt/kappa
547 dbda770b 2022-03-13 op rm $testroot/wt/alpha
548 dbda770b 2022-03-13 op mkdir $testroot/wt/alpha
550 60aa1fa0 2022-03-17 op (cd $testroot/wt && got patch patch) > $testroot/stdout \
551 dbda770b 2022-03-13 op 2> $testroot/stderr
553 dbda770b 2022-03-13 op if [ $ret -eq 0 ]; then
554 dbda770b 2022-03-13 op echo "edited a missing file" >&2
555 a19f439c 2022-06-03 op test_done $testroot 1
559 60aa1fa0 2022-03-17 op cat <<EOF > $testroot/stdout.expected
565 bfcdc9e9 2023-05-11 stsp Files where patch failed to apply: 5
568 60aa1fa0 2022-03-17 op cat <<EOF > $testroot/stderr.expected
569 60aa1fa0 2022-03-17 op got: alpha: file has unexpected status
570 60aa1fa0 2022-03-17 op got: beta: file has unexpected status
571 60aa1fa0 2022-03-17 op got: iota: No such file or directory
572 60aa1fa0 2022-03-17 op got: kappa: file has unexpected status
573 60aa1fa0 2022-03-17 op got: lambda: No such file or directory
574 60aa1fa0 2022-03-17 op got: patch failed to apply
577 60aa1fa0 2022-03-17 op cmp -s $testroot/stdout.expected $testroot/stdout
579 60aa1fa0 2022-03-17 op if [ $ret -ne 0 ]; then
580 60aa1fa0 2022-03-17 op diff -u $testroot/stdout.expected $testroot/stdout
581 dbda770b 2022-03-13 op test_done $testroot $ret
585 dbda770b 2022-03-13 op cmp -s $testroot/stderr.expected $testroot/stderr
587 60aa1fa0 2022-03-17 op if [ $ret -ne 0 ]; then
588 dbda770b 2022-03-13 op diff -u $testroot/stderr.expected $testroot/stderr
589 78f5ac24 2022-03-19 op test_done $testroot $ret
593 78f5ac24 2022-03-19 op (cd $testroot/wt && got status) > $testroot/stdout
594 78f5ac24 2022-03-19 op cat <<EOF > $testroot/stdout.expected
600 78f5ac24 2022-03-19 op cmp -s $testroot/stdout.expected $testroot/stdout
602 78f5ac24 2022-03-19 op if [ $ret -ne 0 ]; then
603 78f5ac24 2022-03-19 op diff -u $testroot/stdout.expected $testroot/stdout
605 899fcfdf 2022-03-13 op test_done $testroot $ret
608 899fcfdf 2022-03-13 op test_patch_nop() {
609 899fcfdf 2022-03-13 op local testroot=`test_init patch_nop`
611 899fcfdf 2022-03-13 op got checkout $testroot/repo $testroot/wt > /dev/null
613 899fcfdf 2022-03-13 op if [ $ret -ne 0 ]; then
614 899fcfdf 2022-03-13 op test_done $testroot $ret
618 899fcfdf 2022-03-13 op cat <<EOF > $testroot/wt/patch
625 899fcfdf 2022-03-13 op +++ /dev/null
626 899fcfdf 2022-03-13 op @@ -1 +0,0 @@
628 7a30b5cb 2022-03-20 op diff --git a/gamma/delta b/gamma/delta.new
629 899fcfdf 2022-03-13 op --- gamma/delta
630 899fcfdf 2022-03-13 op +++ gamma/delta.new
633 899fcfdf 2022-03-13 op +delta updated and renamed!
636 899fcfdf 2022-03-13 op (cd $testroot/wt && got patch -n patch)
638 899fcfdf 2022-03-13 op if [ $ret -ne 0 ]; then
639 899fcfdf 2022-03-13 op test_done $testroot $ret
643 899fcfdf 2022-03-13 op # remove the patch to avoid the ? entry
644 899fcfdf 2022-03-13 op rm $testroot/wt/patch
646 899fcfdf 2022-03-13 op (cd $testroot/wt && got status) > $testroot/stdout
648 899fcfdf 2022-03-13 op if [ $ret -ne 0 ]; then
649 899fcfdf 2022-03-13 op test_done $testroot $ret
653 899fcfdf 2022-03-13 op echo -n > $testroot/stdout.expected
654 899fcfdf 2022-03-13 op cmp -s $testroot/stdout.expected $testroot/stdout
656 899fcfdf 2022-03-13 op if [ $ret -ne 0 ]; then
657 899fcfdf 2022-03-13 op diff -u $testroot/stdout.expected $testroot/stdout
659 dbda770b 2022-03-13 op test_done $testroot $ret
662 2be5e1a2 2022-03-16 op test_patch_preserve_perm() {
663 2be5e1a2 2022-03-16 op local testroot=`test_init patch_preserve_perm`
665 2be5e1a2 2022-03-16 op got checkout $testroot/repo $testroot/wt > /dev/null
667 2be5e1a2 2022-03-16 op if [ $ret -ne 0 ]; then
668 2be5e1a2 2022-03-16 op test_done $testroot $ret
672 2be5e1a2 2022-03-16 op chmod +x $testroot/wt/alpha
673 2be5e1a2 2022-03-16 op (cd $testroot/wt && got commit -m 'alpha executable') > /dev/null
675 2be5e1a2 2022-03-16 op if [ $ret -ne 0 ]; then
676 2be5e1a2 2022-03-16 op test_done $testroot $ret
680 2be5e1a2 2022-03-16 op cat <<EOF > $testroot/wt/patch
683 2be5e1a2 2022-03-16 op @@ -1 +1,2 @@
688 2be5e1a2 2022-03-16 op (cd $testroot/wt && got patch patch) > /dev/null
690 2be5e1a2 2022-03-16 op if [ $ret -ne 0 ]; then
691 2be5e1a2 2022-03-16 op test_done $testroot $ret
695 2be5e1a2 2022-03-16 op if [ ! -x $testroot/wt/alpha ]; then
696 2be5e1a2 2022-03-16 op echo "alpha is no more executable!" >&2
697 2be5e1a2 2022-03-16 op test_done $testroot 1
700 95d68340 2022-03-16 op test_done $testroot 0
703 95d68340 2022-03-16 op test_patch_create_dirs() {
704 95d68340 2022-03-16 op local testroot=`test_init patch_create_dirs`
706 95d68340 2022-03-16 op got checkout $testroot/repo $testroot/wt > /dev/null
708 95d68340 2022-03-16 op if [ $ret -ne 0 ]; then
709 95d68340 2022-03-16 op test_done $testroot $ret
713 95d68340 2022-03-16 op cat <<EOF > $testroot/wt/patch
714 95d68340 2022-03-16 op --- /dev/null
715 95d68340 2022-03-16 op +++ iota/kappa/lambda
716 95d68340 2022-03-16 op @@ -0,0 +1 @@
720 95d68340 2022-03-16 op (cd $testroot/wt && got patch patch) > $testroot/stdout
722 95d68340 2022-03-16 op if [ $ret -ne 0 ]; then
723 95d68340 2022-03-16 op test_done $testroot $ret
727 95d68340 2022-03-16 op echo 'A iota/kappa/lambda' >> $testroot/stdout.expected
728 95d68340 2022-03-16 op cmp -s $testroot/stdout.expected $testroot/stdout
730 95d68340 2022-03-16 op if [ $ret -ne 0 ]; then
731 95d68340 2022-03-16 op diff -u $testroot/stdout.expected $testroot/stdout
732 95d68340 2022-03-16 op test_done $testroot $ret
736 95d68340 2022-03-16 op if [ ! -f $testroot/wt/iota/kappa/lambda ]; then
737 95d68340 2022-03-16 op echo "file not created!" >&2
738 95d68340 2022-03-16 op test_done $testroot $ret
741 2be5e1a2 2022-03-16 op test_done $testroot 0
744 60aa1fa0 2022-03-17 op test_patch_with_offset() {
745 60aa1fa0 2022-03-17 op local testroot=`test_init patch_with_offset`
747 60aa1fa0 2022-03-17 op got checkout $testroot/repo $testroot/wt > /dev/null
749 60aa1fa0 2022-03-17 op if [ $ret -ne 0 ]; then
750 60aa1fa0 2022-03-17 op test_done $testroot $ret
754 60aa1fa0 2022-03-17 op cat <<EOF > $testroot/wt/patch
757 60aa1fa0 2022-03-17 op @@ -47,7 +47,7 @@
762 60aa1fa0 2022-03-17 op +midway tru it!
766 60aa1fa0 2022-03-17 op @@ -87,7 +87,7 @@
771 60aa1fa0 2022-03-17 op +almost there!
777 60aa1fa0 2022-03-17 op jot 100 > $testroot/wt/numbers
778 5f94a4e0 2022-11-18 op ed -s "$testroot/wt/numbers" <<EOF
785 60aa1fa0 2022-03-17 op (cd $testroot/wt && got add numbers && got commit -m '+numbers') \
788 60aa1fa0 2022-03-17 op if [ $ret -ne 0 ]; then
789 60aa1fa0 2022-03-17 op test_done $testroot $ret
793 60aa1fa0 2022-03-17 op (cd $testroot/wt && got patch patch) > $testroot/stdout
795 60aa1fa0 2022-03-17 op if [ $ret -ne 0 ]; then
796 60aa1fa0 2022-03-17 op test_done $testroot/wt $ret
800 60aa1fa0 2022-03-17 op cat <<EOF > $testroot/stdout.expected
802 60aa1fa0 2022-03-17 op @@ -47,7 +47,7 @@ applied with offset -10
803 60aa1fa0 2022-03-17 op @@ -87,7 +87,7 @@ applied with offset 10
806 7a30b5cb 2022-03-20 op cmp -s $testroot/stdout.expected $testroot/stdout
808 7a30b5cb 2022-03-20 op if [ $ret -ne 0 ]; then
809 7a30b5cb 2022-03-20 op diff -u $testroot/stdout.expected $testroot/stdout
811 7a30b5cb 2022-03-20 op test_done $testroot $ret
814 7a30b5cb 2022-03-20 op test_patch_prefer_new_path() {
815 7a30b5cb 2022-03-20 op local testroot=`test_init patch_orig`
817 7a30b5cb 2022-03-20 op got checkout $testroot/repo $testroot/wt > /dev/null
819 7a30b5cb 2022-03-20 op if [ $ret -ne 0 ]; then
820 7a30b5cb 2022-03-20 op test_done $testroot $ret
824 7a30b5cb 2022-03-20 op cat <<EOF > $testroot/wt/patch
825 7a30b5cb 2022-03-20 op --- alpha.orig
827 7a30b5cb 2022-03-20 op @@ -1 +1,2 @@
832 7a30b5cb 2022-03-20 op (cd $testroot/wt && got patch patch) > $testroot/stdout
834 7a30b5cb 2022-03-20 op if [ $ret -ne 0 ]; then
835 7a30b5cb 2022-03-20 op test_done $testroot $ret
839 3313bcd8 2022-04-19 op echo 'M alpha' > $testroot/stdout.expected
840 60aa1fa0 2022-03-17 op cmp -s $testroot/stdout.expected $testroot/stdout
842 60aa1fa0 2022-03-17 op if [ $ret -ne 0 ]; then
843 60aa1fa0 2022-03-17 op diff -u $testroot/stdout.expected $testroot/stdout
845 60aa1fa0 2022-03-17 op test_done $testroot $ret
848 b3c57ab2 2022-03-22 op test_patch_no_newline() {
849 b3c57ab2 2022-03-22 op local testroot=`test_init patch_no_newline`
851 b3c57ab2 2022-03-22 op got checkout $testroot/repo $testroot/wt > /dev/null
853 b3c57ab2 2022-03-22 op if [ $ret -ne 0 ]; then
854 b3c57ab2 2022-03-22 op test_done $testroot $ret
858 b3c57ab2 2022-03-22 op cat <<EOF > $testroot/wt/patch
859 b3c57ab2 2022-03-22 op --- /dev/null
861 b3c57ab2 2022-03-22 op @@ -0,0 +1 @@
863 b3c57ab2 2022-03-22 op \ No newline at end of file
866 b3c57ab2 2022-03-22 op (cd $testroot/wt && got patch patch) > $testroot/stdout
868 b3c57ab2 2022-03-22 op if [ $ret -ne 0 ]; then
869 b3c57ab2 2022-03-22 op test_done $testroot $ret
873 b3c57ab2 2022-03-22 op echo "A eta" > $testroot/stdout.expected
874 b3c57ab2 2022-03-22 op cmp -s $testroot/stdout.expected $testroot/stdout
876 b3c57ab2 2022-03-22 op if [ $ret -ne 0 ]; then
877 b3c57ab2 2022-03-22 op diff -u $testroot/stdout.expected $testroot/stdout
878 b3c57ab2 2022-03-22 op test_done $testroot $ret
882 b3c57ab2 2022-03-22 op echo -n eta > $testroot/wt/eta.expected
883 b3c57ab2 2022-03-22 op cmp -s $testroot/wt/eta.expected $testroot/wt/eta
885 b3c57ab2 2022-03-22 op if [ $ret -ne 0 ]; then
886 b3c57ab2 2022-03-22 op diff -u $testroot/wt/eta.expected $testroot/wt/eta
887 b3c57ab2 2022-03-22 op test_done $testroot $ret
891 b3c57ab2 2022-03-22 op (cd $testroot/wt && got commit -m 'add eta') > /dev/null
893 b3c57ab2 2022-03-22 op if [ $ret -ne 0 ]; then
894 b3c57ab2 2022-03-22 op test_done $testroot $ret
898 b3c57ab2 2022-03-22 op cat <<EOF > $testroot/wt/patch
903 b3c57ab2 2022-03-22 op \ No newline at end of file
905 b3c57ab2 2022-03-22 op \ No newline at end of file
908 b3c57ab2 2022-03-22 op (cd $testroot/wt && got patch patch) > $testroot/stdout
910 b3c57ab2 2022-03-22 op if [ $ret -ne 0 ]; then
911 b3c57ab2 2022-03-22 op test_done $testroot $ret
915 b3c57ab2 2022-03-22 op echo "M eta" > $testroot/stdout.expected
916 b3c57ab2 2022-03-22 op cmp -s $testroot/stdout.expected $testroot/stdout
918 b3c57ab2 2022-03-22 op if [ $ret -ne 0 ]; then
919 b3c57ab2 2022-03-22 op diff -u $testroot/stdout.expected $testroot/stdout
920 b3c57ab2 2022-03-22 op test_done $testroot $ret
924 b3c57ab2 2022-03-22 op echo -n ETA > $testroot/wt/eta.expected
925 b3c57ab2 2022-03-22 op cmp -s $testroot/wt/eta.expected $testroot/wt/eta
927 b3c57ab2 2022-03-22 op if [ $ret -ne 0 ]; then
928 b3c57ab2 2022-03-22 op diff -u $testroot/wt/eta.expected $testroot/wt/eta
929 b3c57ab2 2022-03-22 op test_done $testroot $ret
933 b3c57ab2 2022-03-22 op (cd $testroot/wt && got commit -m 'edit eta') > /dev/null
935 b3c57ab2 2022-03-22 op if [ $ret -ne 0 ]; then
936 b3c57ab2 2022-03-22 op test_done $testroot $ret
940 b3c57ab2 2022-03-22 op cat <<EOF > $testroot/wt/patch
945 b3c57ab2 2022-03-22 op \ No newline at end of file
949 b3c57ab2 2022-03-22 op (cd $testroot/wt && got patch patch) > $testroot/stdout
951 b3c57ab2 2022-03-22 op if [ $ret -ne 0 ]; then
952 b3c57ab2 2022-03-22 op test_done $testroot $ret
956 b3c57ab2 2022-03-22 op echo "M eta" > $testroot/stdout.expected
957 b3c57ab2 2022-03-22 op cmp -s $testroot/stdout.expected $testroot/stdout
959 b3c57ab2 2022-03-22 op if [ $ret -ne 0 ]; then
960 b3c57ab2 2022-03-22 op diff -u $testroot/stdout.expected $testroot/stdout
961 b3c57ab2 2022-03-22 op test_done $testroot $ret
965 b3c57ab2 2022-03-22 op echo eta > $testroot/wt/eta.expected
966 b3c57ab2 2022-03-22 op cmp -s $testroot/wt/eta.expected $testroot/wt/eta
968 b3c57ab2 2022-03-22 op if [ $ret -ne 0 ]; then
969 b3c57ab2 2022-03-22 op diff -u $testroot/wt/eta.expected $testroot/wt/eta
971 b3c57ab2 2022-03-22 op test_done $testroot $ret
974 9d6cabd5 2022-04-07 op test_patch_strip() {
975 9d6cabd5 2022-04-07 op local testroot=`test_init patch_strip`
977 9d6cabd5 2022-04-07 op got checkout $testroot/repo $testroot/wt > /dev/null
979 9d6cabd5 2022-04-07 op if [ $ret -ne 0 ]; then
980 9d6cabd5 2022-04-07 op test_done $testroot $ret
984 9d6cabd5 2022-04-07 op cat <<EOF > $testroot/wt/patch
985 9d6cabd5 2022-04-07 op --- foo/bar/alpha.orig
986 9d6cabd5 2022-04-07 op +++ foo/bar/alpha
992 9d6cabd5 2022-04-07 op (cd $testroot/wt && got patch -p2 patch) > $testroot/stdout
994 9d6cabd5 2022-04-07 op if [ $ret -ne 0 ]; then
995 9d6cabd5 2022-04-07 op test_done $testroot $ret
999 9d6cabd5 2022-04-07 op echo "M alpha" >> $testroot/stdout.expected
1000 9d6cabd5 2022-04-07 op cmp -s $testroot/stdout.expected $testroot/stdout
1002 9d6cabd5 2022-04-07 op if [ $ret -ne 0 ]; then
1003 9d6cabd5 2022-04-07 op diff -u $testroot/stdout.expected $testroot/stdout
1004 9d6cabd5 2022-04-07 op test_done $testroot $ret
1008 9d6cabd5 2022-04-07 op (cd $testroot/wt && got revert alpha) > /dev/null 2>&1
1010 9d6cabd5 2022-04-07 op if [ $ret -ne 0 ]; then
1011 9d6cabd5 2022-04-07 op test_done $testroot $ret
1015 9d6cabd5 2022-04-07 op (cd $testroot/wt && got patch -p3 patch) \
1016 9d6cabd5 2022-04-07 op 2> $testroot/stderr
1018 9d6cabd5 2022-04-07 op if [ $ret -eq 0 ]; then
1019 9d6cabd5 2022-04-07 op echo "stripped more components than available!"
1020 9d6cabd5 2022-04-07 op test_done $testroot 1
1024 9d6cabd5 2022-04-07 op cat <<EOF > $testroot/stderr.expected
1025 9d6cabd5 2022-04-07 op got: can't strip 1 path-components from foo/bar/alpha: bad path
1028 9d6cabd5 2022-04-07 op cmp -s $testroot/stderr.expected $testroot/stderr
1030 9d6cabd5 2022-04-07 op if [ $ret -ne 0 ]; then
1031 9d6cabd5 2022-04-07 op diff -u $testroot/stderr.expected $testroot/stderr
1033 9d6cabd5 2022-04-07 op test_done $testroot 0
1036 a92a2042 2022-07-02 op test_patch_whitespace() {
1037 a92a2042 2022-07-02 op local testroot=`test_init patch_whitespace`
1039 a92a2042 2022-07-02 op got checkout $testroot/repo $testroot/wt > /dev/null
1041 a92a2042 2022-07-02 op if [ $ret -ne 0 ]; then
1042 a92a2042 2022-07-02 op test_done $testroot $ret
1046 a92a2042 2022-07-02 op trailing=" "
1048 a92a2042 2022-07-02 op cat <<EOF > $testroot/wt/hello.c
1049 a92a2042 2022-07-02 op #include <stdio.h>
1054 a92a2042 2022-07-02 op /* the trailing whitespace is on purpose */
1055 a92a2042 2022-07-02 op printf("hello, world\n");$trailing
1060 a92a2042 2022-07-02 op (cd $testroot/wt && got add hello.c && got ci -m '+hello.c') \
1063 a92a2042 2022-07-02 op if [ $ret -ne 0 ]; then
1064 a92a2042 2022-07-02 op test_done $testroot $ret
1068 a92a2042 2022-07-02 op # test with a diff with various whitespace corruptions
1069 a92a2042 2022-07-02 op cat <<EOF > $testroot/wt/patch
1072 a92a2042 2022-07-02 op @@ -5,5 +5,5 @@
1074 a92a2042 2022-07-02 op /* the trailing whitespace is on purpose */
1075 a92a2042 2022-07-02 op printf("hello, world\n");
1077 a92a2042 2022-07-02 op + return 5; /* always fails */
1081 a92a2042 2022-07-02 op (cd $testroot/wt && got patch patch) \
1082 a92a2042 2022-07-02 op 2>$testroot/stderr >$testroot/stdout
1084 a92a2042 2022-07-02 op if [ $ret -ne 0 ]; then
1085 a92a2042 2022-07-02 op echo "failed to apply diff" >&2
1086 a92a2042 2022-07-02 op test_done $testroot $ret
1090 a92a2042 2022-07-02 op echo 'M hello.c' > $testroot/stdout.expected
1091 a92a2042 2022-07-02 op echo '@@ -5,5 +5,5 @@ hunk contains mangled whitespace' \
1092 a92a2042 2022-07-02 op >> $testroot/stdout.expected
1093 a92a2042 2022-07-02 op cmp -s $testroot/stdout.expected $testroot/stdout
1095 a92a2042 2022-07-02 op if [ $ret -ne 0 ]; then
1096 a92a2042 2022-07-02 op diff -u $testroot/stdout.expected $testroot/stdout
1097 a92a2042 2022-07-02 op test_done $testroot $ret
1101 a92a2042 2022-07-02 op cat <<EOF > $testroot/wt/hello.c.expected
1102 a92a2042 2022-07-02 op #include <stdio.h>
1107 a92a2042 2022-07-02 op /* the trailing whitespace is on purpose */
1108 a92a2042 2022-07-02 op printf("hello, world\n");$trailing
1109 a92a2042 2022-07-02 op return 5; /* always fails */
1113 a92a2042 2022-07-02 op cmp -s $testroot/wt/hello.c.expected $testroot/wt/hello.c
1115 a92a2042 2022-07-02 op if [ $ret -ne 0 ]; then
1116 a92a2042 2022-07-02 op diff -u $testroot/wt/hello.c.expected $testroot/wt/hello.c
1118 a92a2042 2022-07-02 op test_done $testroot $ret
1121 ed3bff83 2022-04-23 op test_patch_relative_paths() {
1122 f1d6cebb 2022-04-23 op local testroot=`test_init patch_relative_paths`
1124 ed3bff83 2022-04-23 op got checkout $testroot/repo $testroot/wt > /dev/null
1126 ed3bff83 2022-04-23 op if [ $ret -ne 0 ]; then
1127 ed3bff83 2022-04-23 op test_done $testroot $ret
1131 ed3bff83 2022-04-23 op cat <<EOF > $testroot/wt/gamma/patch
1137 ed3bff83 2022-04-23 op --- /dev/null
1139 ed3bff83 2022-04-23 op @@ -0,0 +1 @@
1143 ed3bff83 2022-04-23 op (cd $testroot/wt/gamma && got patch patch) > $testroot/stdout
1145 ed3bff83 2022-04-23 op if [ $ret -ne 0 ]; then
1146 ed3bff83 2022-04-23 op test_done $testroot $ret
1150 ed3bff83 2022-04-23 op echo 'M gamma/delta' > $testroot/stdout.expected
1151 ed3bff83 2022-04-23 op echo 'A gamma/eta' >> $testroot/stdout.expected
1153 15e1bda6 2022-04-23 op cmp -s $testroot/stdout.expected $testroot/stdout
1155 15e1bda6 2022-04-23 op if [ $ret -ne 0 ]; then
1156 15e1bda6 2022-04-23 op diff -u $testroot/stdout.expected $testroot/stdout
1158 15e1bda6 2022-04-23 op test_done $testroot $ret
1161 15e1bda6 2022-04-23 op test_patch_with_path_prefix() {
1162 15e1bda6 2022-04-23 op local testroot=`test_init patch_with_path_prefix`
1164 15e1bda6 2022-04-23 op got checkout -p gamma $testroot/repo $testroot/wt > /dev/null
1166 15e1bda6 2022-04-23 op if [ $ret -ne 0 ]; then
1167 15e1bda6 2022-04-23 op test_done $testroot $ret
1171 15e1bda6 2022-04-23 op cat <<EOF > $testroot/wt/patch
1177 15e1bda6 2022-04-23 op --- /dev/null
1179 15e1bda6 2022-04-23 op @@ -0,0 +1 @@
1183 15e1bda6 2022-04-23 op (cd $testroot/wt && got patch patch) > $testroot/stdout
1185 15e1bda6 2022-04-23 op if [ $ret -ne 0 ]; then
1186 15e1bda6 2022-04-23 op test_done $testroot $ret
1190 15e1bda6 2022-04-23 op echo 'M delta' > $testroot/stdout.expected
1191 15e1bda6 2022-04-23 op echo 'A eta' >> $testroot/stdout.expected
1193 15e1bda6 2022-04-23 op cmp -s $testroot/stdout.expected $testroot/stdout
1195 15e1bda6 2022-04-23 op if [ $ret -ne 0 ]; then
1196 15e1bda6 2022-04-23 op diff -u $testroot/stdout.expected $testroot/stdout
1198 15e1bda6 2022-04-23 op test_done $testroot $ret
1201 15e1bda6 2022-04-23 op test_patch_relpath_with_path_prefix() {
1202 15e1bda6 2022-04-23 op local testroot=`test_init patch_relpaths_with_path_prefix`
1204 15e1bda6 2022-04-23 op got checkout -p gamma $testroot/repo $testroot/wt > /dev/null
1206 15e1bda6 2022-04-23 op if [ $ret -ne 0 ]; then
1207 15e1bda6 2022-04-23 op test_done $testroot $ret
1211 15e1bda6 2022-04-23 op mkdir -p $testroot/wt/epsilon/zeta/
1213 15e1bda6 2022-04-23 op cat <<EOF > $testroot/wt/patch
1214 15e1bda6 2022-04-23 op --- /dev/null
1215 15e1bda6 2022-04-23 op +++ zeta/theta
1216 15e1bda6 2022-04-23 op @@ -0,0 +1 @@
1220 15e1bda6 2022-04-23 op (cd $testroot/wt/epsilon/zeta && got patch -p1 $testroot/wt/patch) \
1221 15e1bda6 2022-04-23 op > $testroot/stdout
1223 15e1bda6 2022-04-23 op if [ $ret -ne 0 ]; then
1224 15e1bda6 2022-04-23 op test_done $testroot $ret
1228 15e1bda6 2022-04-23 op echo 'A epsilon/zeta/theta' >> $testroot/stdout.expected
1230 ed3bff83 2022-04-23 op cmp -s $testroot/stdout.expected $testroot/stdout
1232 ed3bff83 2022-04-23 op if [ $ret -ne 0 ]; then
1233 ed3bff83 2022-04-23 op diff -u $testroot/stdout.expected $testroot/stdout
1234 15e1bda6 2022-04-23 op test_done $testroot $ret
1238 15e1bda6 2022-04-23 op echo 'theta' > $testroot/theta.expected
1239 15e1bda6 2022-04-23 op cmp -s $testroot/wt/epsilon/zeta/theta $testroot/theta.expected
1241 15e1bda6 2022-04-23 op if [ $ret -ne 0 ]; then
1242 15e1bda6 2022-04-23 op diff -u $testroot/wt/epsilon/zeta/theta $testroot/theta.expected
1244 ed3bff83 2022-04-23 op test_done $testroot $ret
1247 bad961bf 2022-04-23 op test_patch_reverse() {
1248 bad961bf 2022-04-23 op local testroot=`test_init patch_reverse`
1250 bad961bf 2022-04-23 op got checkout $testroot/repo $testroot/wt > /dev/null
1252 bad961bf 2022-04-23 op if [ $ret -ne 0 ]; then
1253 bad961bf 2022-04-23 op test_done $testroot $ret
1257 bad961bf 2022-04-23 op cat <<EOF > $testroot/wt/patch
1262 bad961bf 2022-04-23 op \ No newline at end of file
1266 bad961bf 2022-04-23 op (cd $testroot/wt && got patch -R patch) > $testroot/stdout
1268 bad961bf 2022-04-23 op if [ $ret -ne 0 ]; then
1269 bad961bf 2022-04-23 op test_done $testroot $ret
1273 bad961bf 2022-04-23 op echo "M alpha" > $testroot/stdout.expected
1274 bad961bf 2022-04-23 op cmp -s $testroot/stdout.expected $testroot/stdout
1276 bad961bf 2022-04-23 op if [ $ret -ne 0 ]; then
1277 bad961bf 2022-04-23 op diff -u $testroot/stdout.expected $testroot/stdout
1278 bad961bf 2022-04-23 op test_done $testroot $ret
1282 bad961bf 2022-04-23 op echo -n ALPHA > $testroot/wt/alpha.expected
1283 bad961bf 2022-04-23 op cmp -s $testroot/wt/alpha.expected $testroot/wt/alpha
1285 bad961bf 2022-04-23 op if [ $ret -ne 0 ]; then
1286 bad961bf 2022-04-23 op diff -u $testroot/wt/alpha.expected $testroot/wt/alpha
1288 55e9459f 2022-06-19 op test_done $testroot $ret
1291 55e9459f 2022-06-19 op test_patch_merge_simple() {
1292 55e9459f 2022-06-19 op local testroot=`test_init patch_merge_simple`
1294 55e9459f 2022-06-19 op got checkout $testroot/repo $testroot/wt > /dev/null
1296 55e9459f 2022-06-19 op if [ $ret -ne 0 ]; then
1297 55e9459f 2022-06-19 op test_done $testroot $ret
1301 55e9459f 2022-06-19 op jot 10 > $testroot/wt/numbers
1302 5dffb1a1 2022-07-02 op chmod +x $testroot/wt/numbers
1303 55e9459f 2022-06-19 op (cd $testroot/wt && got add numbers && got commit -m +numbers) \
1306 55e9459f 2022-06-19 op if [ $ret -ne 0 ]; then
1307 55e9459f 2022-06-19 op test_done $testroot $ret
1311 55e9459f 2022-06-19 op jot 10 | sed 's/4/four/g' > $testroot/wt/numbers
1313 55e9459f 2022-06-19 op (cd $testroot/wt && got diff > $testroot/old.diff \
1314 55e9459f 2022-06-19 op && got revert numbers) >/dev/null
1316 55e9459f 2022-06-19 op if [ $ret -ne 0 ]; then
1317 55e9459f 2022-06-19 op test_done $testroot $ret
1321 55e9459f 2022-06-19 op jot 10 | sed 's/6/six/g' > $testroot/wt/numbers
1322 55e9459f 2022-06-19 op (cd $testroot/wt && got commit -m 'edit numbers') \
1325 55e9459f 2022-06-19 op if [ $ret -ne 0 ]; then
1326 55e9459f 2022-06-19 op test_done $testroot $ret
1330 55e9459f 2022-06-19 op (cd $testroot/wt && got patch $testroot/old.diff) \
1331 9802c41c 2022-06-21 op > $testroot/stdout
1333 55e9459f 2022-06-19 op if [ $ret -ne 0 ]; then
1334 9802c41c 2022-06-21 op test_done $testroot $ret
1338 9802c41c 2022-06-21 op echo 'G numbers' > $testroot/stdout.expected
1339 9802c41c 2022-06-21 op cmp -s $testroot/stdout $testroot/stdout.expected
1341 9802c41c 2022-06-21 op if [ $ret -ne 0 ]; then
1342 9802c41c 2022-06-21 op diff -u $testroot/stdout $testroot/stdout.expected
1343 55e9459f 2022-06-19 op test_done $testroot $ret
1347 55e9459f 2022-06-19 op jot 10 | sed -e s/4/four/ -e s/6/six/ > $testroot/wt/numbers.expected
1348 55e9459f 2022-06-19 op cmp -s $testroot/wt/numbers $testroot/wt/numbers.expected
1350 55e9459f 2022-06-19 op if [ $ret -ne 0 ]; then
1351 55e9459f 2022-06-19 op diff -u $testroot/wt/numbers $testroot/wt/numbers.expected
1352 5dffb1a1 2022-07-02 op test_done $testroot $ret
1356 5dffb1a1 2022-07-02 op test -x $testroot/wt/numbers
1358 5dffb1a1 2022-07-02 op if [ $ret -ne 0 ]; then
1359 5dffb1a1 2022-07-02 op echo "numbers lost the executable bit" >&2
1361 db0dfdd7 2022-06-27 op test_done $testroot $ret
1364 db0dfdd7 2022-06-27 op test_patch_merge_gitdiff() {
1365 db0dfdd7 2022-06-27 op local testroot=`test_init patch_merge_gitdiff`
1367 db0dfdd7 2022-06-27 op jot 10 > $testroot/repo/numbers
1368 f73bf5bd 2023-10-01 naddy git -C $testroot/repo add numbers && \
1369 f73bf5bd 2023-10-01 naddy git_commit $testroot/repo -m "nums"
1371 db0dfdd7 2022-06-27 op if [ $ret -ne 0 ]; then
1372 db0dfdd7 2022-06-27 op test_done $testroot $ret
1376 db0dfdd7 2022-06-27 op jot 10 | sed 's/4/four/g' > $testroot/repo/numbers
1377 f73bf5bd 2023-10-01 naddy git -C $testroot/repo diff > $testroot/old.diff
1379 db0dfdd7 2022-06-27 op if [ $ret -ne 0 ]; then
1380 db0dfdd7 2022-06-27 op test_done $testroot $ret
1384 db0dfdd7 2022-06-27 op # restore numbers
1385 db0dfdd7 2022-06-27 op jot 10 > $testroot/repo/numbers
1387 db0dfdd7 2022-06-27 op jot 10 | sed 's/6/six/g' > $testroot/repo/numbers
1388 f73bf5bd 2023-10-01 naddy git -C $testroot/repo add numbers && \
1389 f73bf5bd 2023-10-01 naddy git_commit $testroot/repo -m "edit"
1391 db0dfdd7 2022-06-27 op if [ $ret -ne 0 ]; then
1392 db0dfdd7 2022-06-27 op test_done $testroot $ret
1396 db0dfdd7 2022-06-27 op # now work with got:
1397 db0dfdd7 2022-06-27 op got checkout $testroot/repo $testroot/wt > /dev/null
1399 db0dfdd7 2022-06-27 op if [ $ret -ne 0 ]; then
1400 db0dfdd7 2022-06-27 op test_done $testroot $ret
1404 db0dfdd7 2022-06-27 op (cd $testroot/wt && got patch $testroot/old.diff) > $testroot/stdout
1406 db0dfdd7 2022-06-27 op if [ $ret -ne 0 ]; then
1407 db0dfdd7 2022-06-27 op test_done $testroot $ret
1411 db0dfdd7 2022-06-27 op echo 'G numbers' > $testroot/stdout.expected
1412 db0dfdd7 2022-06-27 op cmp -s $testroot/stdout $testroot/stdout.expected
1414 db0dfdd7 2022-06-27 op if [ $ret -ne 0 ]; then
1415 db0dfdd7 2022-06-27 op diff -u $testroot/stdout $testroot/stdout.expected
1417 55e9459f 2022-06-19 op test_done $testroot $ret
1420 5f56d41e 2022-07-28 op test_patch_merge_base_provided() {
1421 5f56d41e 2022-07-28 op local testroot=`test_init patch_merge_base_provided`
1423 5f56d41e 2022-07-28 op got checkout $testroot/repo $testroot/wt >/dev/null
1425 5f56d41e 2022-07-28 op if [ $ret -ne 0 ]; then
1426 5f56d41e 2022-07-28 op test_done $testroot $ret
1430 5f56d41e 2022-07-28 op jot 10 > $testroot/wt/numbers
1431 5f56d41e 2022-07-28 op (cd $testroot/wt && got add numbers && got commit -m +numbers) \
1434 5f56d41e 2022-07-28 op if [ $ret -ne 0 ]; then
1435 5f56d41e 2022-07-28 op test_done $testroot $ret
1439 5f56d41e 2022-07-28 op local commit_id=`git_show_head $testroot/repo`
1441 5f56d41e 2022-07-28 op jot 10 | sed s/4/four/ > $testroot/wt/numbers
1443 5f56d41e 2022-07-28 op # get rid of the metadata
1444 5f56d41e 2022-07-28 op (cd $testroot/wt && got diff | sed -n '/^---/,$p' > patch) \
1447 5f56d41e 2022-07-28 op jot 10 | sed s/6/six/ > $testroot/wt/numbers
1448 5f56d41e 2022-07-28 op (cd $testroot/wt && got commit -m 'edit numbers') >/dev/null
1450 5f56d41e 2022-07-28 op if [ $ret -ne 0 ]; then
1451 5f56d41e 2022-07-28 op test_done $testroot $ret
1455 5f56d41e 2022-07-28 op (cd $testroot/wt && got patch -c $commit_id patch) >$testroot/stdout
1457 5f56d41e 2022-07-28 op if [ $ret -ne 0 ]; then
1458 5f56d41e 2022-07-28 op test_done $testroot $ret
1462 5f56d41e 2022-07-28 op echo 'G numbers' > $testroot/stdout.expected
1463 5f56d41e 2022-07-28 op cmp -s $testroot/stdout $testroot/stdout.expected
1465 5f56d41e 2022-07-28 op if [ $ret -ne 0 ]; then
1466 5f56d41e 2022-07-28 op diff -u $testroot/stdout $testroot/stdout.expected
1467 5f56d41e 2022-07-28 op test_done $testroot $ret
1471 5f56d41e 2022-07-28 op jot 10 | sed -e s/4/four/ -e s/6/six/ > $testroot/wt/numbers.expected
1472 5f56d41e 2022-07-28 op cmp -s $testroot/wt/numbers $testroot/wt/numbers.expected
1474 5f56d41e 2022-07-28 op if [ $ret -ne 0 ]; then
1475 5f56d41e 2022-07-28 op diff -u $testroot/wt/numbers $testroot/wt/numbers.expected
1477 5f56d41e 2022-07-28 op test_done $testroot $ret
1480 55e9459f 2022-06-19 op test_patch_merge_conflict() {
1481 55e9459f 2022-06-19 op local testroot=`test_init patch_merge_conflict`
1483 55e9459f 2022-06-19 op got checkout $testroot/repo $testroot/wt > /dev/null
1485 55e9459f 2022-06-19 op if [ $ret -ne 0 ]; then
1486 55e9459f 2022-06-19 op test_done $testroot $ret
1490 55e9459f 2022-06-19 op jot 10 > $testroot/wt/numbers
1491 55e9459f 2022-06-19 op (cd $testroot/wt && got add numbers && got commit -m +numbers) \
1494 55e9459f 2022-06-19 op if [ $ret -ne 0 ]; then
1495 55e9459f 2022-06-19 op test_done $testroot $ret
1499 d8b5af43 2022-06-19 op local commit_id=`git_show_head $testroot/repo`
1501 55e9459f 2022-06-19 op jot 10 | sed 's/6/six/g' > $testroot/wt/numbers
1502 acf749fc 2022-07-02 op echo ALPHA > $testroot/wt/alpha
1504 55e9459f 2022-06-19 op (cd $testroot/wt && got diff > $testroot/old.diff \
1505 acf749fc 2022-07-02 op && got revert alpha numbers) >/dev/null
1507 55e9459f 2022-06-19 op if [ $ret -ne 0 ]; then
1508 55e9459f 2022-06-19 op test_done $testroot $ret
1512 55e9459f 2022-06-19 op jot 10 | sed 's/6/3+3/g' > $testroot/wt/numbers
1513 acf749fc 2022-07-02 op jot -c 3 a > $testroot/wt/alpha
1514 acf749fc 2022-07-02 op (cd $testroot/wt && got commit -m 'edit alpha and numbers') \
1517 55e9459f 2022-06-19 op if [ $ret -ne 0 ]; then
1518 55e9459f 2022-06-19 op test_done $testroot $ret
1522 55e9459f 2022-06-19 op (cd $testroot/wt && got patch $testroot/old.diff) \
1523 9802c41c 2022-06-21 op > $testroot/stdout 2>/dev/null
1525 55e9459f 2022-06-19 op if [ $ret -eq 0 ]; then
1526 55e9459f 2022-06-19 op echo "got patch merged a diff that should conflict" >&2
1527 e423877d 2023-05-11 stsp test_done $testroot 1
1531 acf749fc 2022-07-02 op echo 'C alpha' > $testroot/stdout.expected
1532 acf749fc 2022-07-02 op echo 'C numbers' >> $testroot/stdout.expected
1533 bfcdc9e9 2023-05-11 stsp echo 'Files with merge conflicts: 2' >> $testroot/stdout.expected
1534 9802c41c 2022-06-21 op cmp -s $testroot/stdout $testroot/stdout.expected
1536 9802c41c 2022-06-21 op if [ $ret -ne 0 ]; then
1537 9802c41c 2022-06-21 op diff -u $testroot/stdout $testroot/stdout.expected
1538 9802c41c 2022-06-21 op test_done $testroot $ret
1542 55e9459f 2022-06-19 op # XXX: prefixing every line with a tab otherwise got thinks
1543 55e9459f 2022-06-19 op # the file has conflicts in it.
1544 acf749fc 2022-07-02 op cat <<-EOF > $testroot/wt/alpha.expected
1545 acf749fc 2022-07-02 op <<<<<<< --- alpha
1547 acf749fc 2022-07-02 op ||||||| commit $commit_id
1553 acf749fc 2022-07-02 op >>>>>>> +++ alpha
1556 55e9459f 2022-06-19 op cat <<-EOF > $testroot/wt/numbers.expected
1562 55e9459f 2022-06-19 op <<<<<<< --- numbers
1564 d8b5af43 2022-06-19 op ||||||| commit $commit_id
1568 55e9459f 2022-06-19 op >>>>>>> +++ numbers
1575 acf749fc 2022-07-02 op cmp -s $testroot/wt/alpha $testroot/wt/alpha.expected
1577 acf749fc 2022-07-02 op if [ $ret -ne 0 ]; then
1578 acf749fc 2022-07-02 op diff -u $testroot/wt/alpha $testroot/wt/alpha.expected
1579 acf749fc 2022-07-02 op test_done $testroot $ret
1583 55e9459f 2022-06-19 op cmp -s $testroot/wt/numbers $testroot/wt/numbers.expected
1585 55e9459f 2022-06-19 op if [ $ret -ne 0 ]; then
1586 55e9459f 2022-06-19 op diff -u $testroot/wt/numbers $testroot/wt/numbers.expected
1588 bad961bf 2022-04-23 op test_done $testroot $ret
1591 55e9459f 2022-06-19 op test_patch_merge_unknown_blob() {
1592 55e9459f 2022-06-19 op local testroot=`test_init patch_merge_unknown_blob`
1594 55e9459f 2022-06-19 op got checkout $testroot/repo $testroot/wt > /dev/null
1596 55e9459f 2022-06-19 op if [ $ret -ne 0 ]; then
1597 55e9459f 2022-06-19 op test_done $testroot $ret
1601 55e9459f 2022-06-19 op cat <<EOF > $testroot/wt/patch
1603 dbc68eed 2022-06-21 op diff aaaabbbbccccddddeeeeffff0000111122223333 foo/bar
1605 55e9459f 2022-06-19 op blob - aaaabbbbccccddddeeeeffff0000111122223333
1607 dbc68eed 2022-06-21 op blob + 0000111122223333444455556666777788889999
1608 55e9459f 2022-06-19 op for this dummy diff
1614 55e9459f 2022-06-19 op will it work?
1617 55e9459f 2022-06-19 op (cd $testroot/wt/ && got patch patch) > $testroot/stdout
1619 55e9459f 2022-06-19 op if [ $ret -ne 0 ]; then
1620 55e9459f 2022-06-19 op test_done $testroot $ret
1624 55e9459f 2022-06-19 op echo 'M alpha' > $testroot/stdout.expected
1625 55e9459f 2022-06-19 op cmp -s $testroot/stdout.expected $testroot/stdout
1627 55e9459f 2022-06-19 op if [ $ret -ne 0 ]; then
1628 55e9459f 2022-06-19 op diff -u $testroot/stdout.expected $testroot/stdout
1629 dbc68eed 2022-06-21 op test_done $testroot $ret
1633 dbc68eed 2022-06-21 op # try again without a `diff' header
1635 dbc68eed 2022-06-21 op cat <<EOF > $testroot/wt/patch
1637 dbc68eed 2022-06-21 op blob - aaaabbbbccccddddeeeeffff0000111122223333
1639 dbc68eed 2022-06-21 op blob + 0000111122223333444455556666777788889999
1640 dbc68eed 2022-06-21 op for this dummy diff
1646 dbc68eed 2022-06-21 op will it work?
1649 dbc68eed 2022-06-21 op (cd $testroot/wt && got revert alpha > /dev/null && got patch patch) \
1650 dbc68eed 2022-06-21 op > $testroot/stdout
1652 dbc68eed 2022-06-21 op if [ $ret -ne 0 ]; then
1653 dbc68eed 2022-06-21 op test_done $testroot $ret
1657 dbc68eed 2022-06-21 op echo 'M alpha' > $testroot/stdout.expected
1658 dbc68eed 2022-06-21 op cmp -s $testroot/stdout.expected $testroot/stdout
1660 dbc68eed 2022-06-21 op if [ $ret -ne 0 ]; then
1661 dbc68eed 2022-06-21 op diff -u $testroot/stdout.expected $testroot/stdout
1662 db0dfdd7 2022-06-27 op test_done $testroot $ret
1666 db0dfdd7 2022-06-27 op # try again with a git-style diff
1668 db0dfdd7 2022-06-27 op cat <<EOF > $testroot/wt/patch
1669 db0dfdd7 2022-06-27 op diff --git a/alpha b/alpha
1670 db0dfdd7 2022-06-27 op index 0123456789ab..abcdef012345 100644
1678 db0dfdd7 2022-06-27 op (cd $testroot/wt && got revert alpha > /dev/null && got patch patch) \
1679 db0dfdd7 2022-06-27 op > $testroot/stdout
1681 db0dfdd7 2022-06-27 op if [ $ret -ne 0 ]; then
1682 db0dfdd7 2022-06-27 op test_done $testroot $ret
1686 db0dfdd7 2022-06-27 op echo 'M alpha' > $testroot/stdout.expected
1687 db0dfdd7 2022-06-27 op cmp -s $testroot/stdout.expected $testroot/stdout
1689 db0dfdd7 2022-06-27 op if [ $ret -ne 0 ]; then
1690 db0dfdd7 2022-06-27 op diff -u $testroot/stdout.expected $testroot/stdout
1692 55e9459f 2022-06-19 op test_done $testroot $ret
1695 38d61ead 2022-07-23 op test_patch_merge_reverse() {
1696 38d61ead 2022-07-23 op local testroot=`test_init patch_merge_simple`
1698 38d61ead 2022-07-23 op got checkout $testroot/repo $testroot/wt > /dev/null
1700 38d61ead 2022-07-23 op if [ $ret -ne 0 ]; then
1701 38d61ead 2022-07-23 op test_done $testroot $ret
1705 38d61ead 2022-07-23 op jot 10 > $testroot/wt/numbers
1706 38d61ead 2022-07-23 op (cd $testroot/wt && got add numbers && got commit -m +numbers) \
1709 38d61ead 2022-07-23 op if [ $ret -ne 0 ]; then
1710 38d61ead 2022-07-23 op test_done $testroot $ret
1714 38d61ead 2022-07-23 op local commit_id=`git_show_head $testroot/repo`
1716 38d61ead 2022-07-23 op jot 10 | sed s/5/five/g > $testroot/wt/numbers
1717 38d61ead 2022-07-23 op (cd $testroot/wt && got diff > $testroot/wt/patch \
1718 38d61ead 2022-07-23 op && got commit -m 'edit numbers') > /dev/null
1720 38d61ead 2022-07-23 op if [ $ret -ne 0 ]; then
1721 38d61ead 2022-07-23 op test_done $testroot $ret
1725 38d61ead 2022-07-23 op jot 10 | sed -e s/5/five/g -e s/6/six/g > $testroot/wt/numbers
1726 38d61ead 2022-07-23 op (cd $testroot/wt && got commit -m 'edit numbers again') >/dev/null
1728 38d61ead 2022-07-23 op if [ $ret -ne 0 ]; then
1729 38d61ead 2022-07-23 op test_done $testroot $ret
1733 38d61ead 2022-07-23 op (cd $testroot/wt && got patch -R patch) >/dev/null 2>&1
1735 38d61ead 2022-07-23 op if [ $ret -eq 0 ]; then
1736 38d61ead 2022-07-23 op echo "unexpectedly reverted the patch" >&2
1737 38d61ead 2022-07-23 op test_done $testroot 1
1741 38d61ead 2022-07-23 op cat <<-EOF > $testroot/wt/numbers.expected
1746 38d61ead 2022-07-23 op <<<<<<< --- numbers
1749 38d61ead 2022-07-23 op ||||||| +++ numbers
1754 38d61ead 2022-07-23 op >>>>>>> commit $commit_id
1761 38d61ead 2022-07-23 op cmp -s $testroot/wt/numbers $testroot/wt/numbers.expected
1763 38d61ead 2022-07-23 op if [ $ret -ne 0 ]; then
1764 38d61ead 2022-07-23 op diff -u $testroot/wt/numbers $testroot/wt/numbers.expected
1766 611e5fc2 2022-09-21 mark test_done $testroot $ret
1769 611e5fc2 2022-09-21 mark test_patch_newfile_xbit_got_diff() {
1770 611e5fc2 2022-09-21 mark local testroot=`test_init patch_newfile_xbit`
1772 611e5fc2 2022-09-21 mark got checkout $testroot/repo $testroot/wt > /dev/null
1774 611e5fc2 2022-09-21 mark if [ $ret -ne 0 ]; then
1775 611e5fc2 2022-09-21 mark test_done $testroot $ret
1779 611e5fc2 2022-09-21 mark cat <<EOF > $testroot/wt/patch
1780 611e5fc2 2022-09-21 mark blob - /dev/null
1781 611e5fc2 2022-09-21 mark blob + abcdef0123456789abcdef012345678901234567 (mode 755)
1782 611e5fc2 2022-09-21 mark --- /dev/null
1784 611e5fc2 2022-09-21 mark @@ -0,0 +1,1 @@
1788 611e5fc2 2022-09-21 mark (cd $testroot/wt && got patch patch) > /dev/null
1790 611e5fc2 2022-09-21 mark if [ $ret -ne 0 ]; then
1791 611e5fc2 2022-09-21 mark test_done $testroot $ret
1795 611e5fc2 2022-09-21 mark if [ ! -x $testroot/wt/xfile ]; then
1796 611e5fc2 2022-09-21 mark echo "failed to set xbit on newfile" >&2
1797 611e5fc2 2022-09-21 mark test_done $testroot 1
1801 611e5fc2 2022-09-21 mark echo xfile > $testroot/wt/xfile.expected
1802 611e5fc2 2022-09-21 mark cmp -s $testroot/wt/xfile $testroot/wt/xfile.expected
1804 611e5fc2 2022-09-21 mark if [ $ret -ne 0 ]; then
1805 611e5fc2 2022-09-21 mark echo "fail"
1806 611e5fc2 2022-09-21 mark diff -u $testroot/wt/xfile $testroot/wt/xfile.expected
1809 38d61ead 2022-07-23 op test_done $testroot $ret
1812 611e5fc2 2022-09-21 mark test_patch_newfile_xbit_git_diff() {
1813 611e5fc2 2022-09-21 mark local testroot=`test_init patch_newfile_xbit`
1815 611e5fc2 2022-09-21 mark got checkout $testroot/repo $testroot/wt > /dev/null
1817 611e5fc2 2022-09-21 mark if [ $ret -ne 0 ]; then
1818 611e5fc2 2022-09-21 mark test_done $testroot $ret
1822 611e5fc2 2022-09-21 mark cat <<EOF > $testroot/wt/patch
1823 611e5fc2 2022-09-21 mark diff --git a/xfile b/xfile
1824 611e5fc2 2022-09-21 mark new file mode 100755
1825 611e5fc2 2022-09-21 mark index 00000000..abcdef01
1826 611e5fc2 2022-09-21 mark --- /dev/null
1827 611e5fc2 2022-09-21 mark +++ b/xfile
1828 611e5fc2 2022-09-21 mark @@ -0,0 +1,1 @@
1832 611e5fc2 2022-09-21 mark (cd $testroot/wt && got patch patch) > /dev/null
1834 611e5fc2 2022-09-21 mark if [ $ret -ne 0 ]; then
1835 611e5fc2 2022-09-21 mark test_done $testroot $ret
1839 611e5fc2 2022-09-21 mark if [ ! -x $testroot/wt/xfile ]; then
1840 611e5fc2 2022-09-21 mark echo "failed to set xbit on newfile" >&2
1841 611e5fc2 2022-09-21 mark test_done $testroot 1
1845 611e5fc2 2022-09-21 mark echo xfile > $testroot/wt/xfile.expected
1846 611e5fc2 2022-09-21 mark cmp -s $testroot/wt/xfile $testroot/wt/xfile.expected
1848 611e5fc2 2022-09-21 mark if [ $ret -ne 0 ]; then
1849 611e5fc2 2022-09-21 mark echo "fail"
1850 611e5fc2 2022-09-21 mark diff -u $testroot/wt/xfile $testroot/wt/xfile.expected
1853 611e5fc2 2022-09-21 mark test_done $testroot $ret
1856 b2b3fce1 2022-10-29 op test_patch_umask() {
1857 b2b3fce1 2022-10-29 op local testroot=`test_init patch_umask`
1859 b2b3fce1 2022-10-29 op got checkout "$testroot/repo" "$testroot/wt" >/dev/null
1861 b2b3fce1 2022-10-29 op cat <<EOF >$testroot/wt/patch
1866 b2b3fce1 2022-10-29 op +modified alpha
1869 b2b3fce1 2022-10-29 op # using a subshell to avoid clobbering global umask
1870 b2b3fce1 2022-10-29 op (umask 077 && cd "$testroot/wt" && got patch <patch) >/dev/null
1872 b2b3fce1 2022-10-29 op if [ $ret -ne 0 ]; then
1873 b2b3fce1 2022-10-29 op test_done "$testroot" $ret
1877 b2b3fce1 2022-10-29 op if ! ls -l "$testroot/wt/alpha" | grep -q ^-rw-------; then
1878 b2b3fce1 2022-10-29 op echo "alpha is not 0600 after patch" >&2
1879 b2b3fce1 2022-10-29 op ls -l "$testroot/wt/alpha" >&2
1880 b2b3fce1 2022-10-29 op test_done "$testroot" 1
1884 b2b3fce1 2022-10-29 op test_done "$testroot" 0
1887 684a9a6c 2022-12-31 op test_patch_remove_binary_file() {
1888 684a9a6c 2022-12-31 op local testroot=`test_init patch_remove_binary_file`
1890 684a9a6c 2022-12-31 op if ! got checkout $testroot/repo $testroot/wt >/dev/null; then
1891 684a9a6c 2022-12-31 op test_done $testroot $ret
1895 684a9a6c 2022-12-31 op dd if=/dev/zero of=$testroot/wt/x bs=1 count=16 2>/dev/null >&2
1896 684a9a6c 2022-12-31 op (cd $testroot/wt && got add x && got commit -m +x) >/dev/null
1898 684a9a6c 2022-12-31 op (cd $testroot/wt && \
1899 684a9a6c 2022-12-31 op got branch demo && \
1900 684a9a6c 2022-12-31 op got rm x && \
1901 684a9a6c 2022-12-31 op got ci -m -x &&
1902 684a9a6c 2022-12-31 op got up -b master) >/dev/null
1904 684a9a6c 2022-12-31 op echo 'D x' > $testroot/stdout.expected
1906 684a9a6c 2022-12-31 op (cd $testroot/wt && got log -c demo -l 1 -p >patch)
1908 684a9a6c 2022-12-31 op (cd $testroot/wt && got patch <patch) > $testroot/stdout
1909 684a9a6c 2022-12-31 op if [ $? -ne 0 ]; then
1910 684a9a6c 2022-12-31 op echo 'patch failed' >&2
1911 684a9a6c 2022-12-31 op test_done $testroot 1
1915 684a9a6c 2022-12-31 op if ! cmp -s $testroot/stdout.expected $testroot/stdout; then
1916 684a9a6c 2022-12-31 op diff -u $testroot/stdout.expected $testroot/stdout
1917 684a9a6c 2022-12-31 op test_done $testroot 1
1921 684a9a6c 2022-12-31 op # try again using a git produced diff
1922 684a9a6c 2022-12-31 op (cd $testroot/wt && got revert x) >/dev/null
1924 f73bf5bd 2023-10-01 naddy git -C $testroot/repo show demo >$testroot/wt/patch
1926 684a9a6c 2022-12-31 op (cd $testroot/wt && got patch <patch) > $testroot/stdout
1927 684a9a6c 2022-12-31 op if [ $? -ne 0 ]; then
1928 684a9a6c 2022-12-31 op echo 'patch failed' >&2
1929 684a9a6c 2022-12-31 op test_done $testroot 1
1933 684a9a6c 2022-12-31 op if ! cmp -s $testroot/stdout.expected $testroot/stdout; then
1934 684a9a6c 2022-12-31 op diff -u $testroot/stdout.expected $testroot/stdout
1935 684a9a6c 2022-12-31 op test_done $testroot 1
1939 684a9a6c 2022-12-31 op # try again using a diff(1) style patch
1940 684a9a6c 2022-12-31 op (cd $testroot/wt && got revert x) >/dev/null
1942 684a9a6c 2022-12-31 op echo "Binary files x and /dev/null differ" >$testroot/wt/patch
1943 684a9a6c 2022-12-31 op (cd $testroot/wt && got patch <patch) >$testroot/stdout
1944 684a9a6c 2022-12-31 op if [ $? -ne 0 ]; then
1945 684a9a6c 2022-12-31 op echo 'patch failed' >&2
1946 684a9a6c 2022-12-31 op test_done $testroot 1
1950 684a9a6c 2022-12-31 op if ! cmp -s $testroot/stdout.expected $testroot/stdout; then
1951 684a9a6c 2022-12-31 op diff -u $testroot/stdout.expected $testroot/stdout
1952 684a9a6c 2022-12-31 op test_done $testroot 1
1956 684a9a6c 2022-12-31 op test_done $testroot 0
1959 c8d1a97c 2023-07-17 mark test_patch_commit_keywords() {
1960 c8d1a97c 2023-07-17 mark local testroot=`test_init patch_commit_keywords`
1962 c8d1a97c 2023-07-17 mark got checkout $testroot/repo $testroot/wt >/dev/null
1964 c8d1a97c 2023-07-17 mark if [ $ret -ne 0 ]; then
1965 c8d1a97c 2023-07-17 mark test_done $testroot $ret
1969 c8d1a97c 2023-07-17 mark jot 10 > $testroot/wt/numbers
1970 c8d1a97c 2023-07-17 mark (cd $testroot/wt && got add numbers && got commit -m +numbers) \
1971 c8d1a97c 2023-07-17 mark >/dev/null
1973 c8d1a97c 2023-07-17 mark if [ $ret -ne 0 ]; then
1974 c8d1a97c 2023-07-17 mark test_done $testroot $ret
1978 c8d1a97c 2023-07-17 mark jot 10 | sed s/4/four/ > $testroot/wt/numbers
1980 c8d1a97c 2023-07-17 mark # get rid of the metadata
1981 c8d1a97c 2023-07-17 mark (cd $testroot/wt && got diff | sed -n '/^---/,$p' > patch) \
1982 c8d1a97c 2023-07-17 mark >/dev/null
1984 c8d1a97c 2023-07-17 mark jot 10 | sed s/6/six/ > $testroot/wt/numbers
1985 c8d1a97c 2023-07-17 mark (cd $testroot/wt && got commit -m 'edit numbers') >/dev/null
1987 c8d1a97c 2023-07-17 mark if [ $ret -ne 0 ]; then
1988 c8d1a97c 2023-07-17 mark test_done $testroot $ret
1992 c8d1a97c 2023-07-17 mark (cd $testroot/wt && got patch -c :head:- patch) >$testroot/stdout
1994 c8d1a97c 2023-07-17 mark if [ $ret -ne 0 ]; then
1995 c8d1a97c 2023-07-17 mark test_done $testroot $ret
1999 c8d1a97c 2023-07-17 mark echo 'G numbers' > $testroot/stdout.expected
2000 c8d1a97c 2023-07-17 mark cmp -s $testroot/stdout $testroot/stdout.expected
2002 c8d1a97c 2023-07-17 mark if [ $ret -ne 0 ]; then
2003 c8d1a97c 2023-07-17 mark diff -u $testroot/stdout $testroot/stdout.expected
2004 c8d1a97c 2023-07-17 mark test_done $testroot $ret
2008 c8d1a97c 2023-07-17 mark jot 10 | sed -e s/4/four/ -e s/6/six/ > $testroot/wt/numbers.expected
2009 c8d1a97c 2023-07-17 mark cmp -s $testroot/wt/numbers $testroot/wt/numbers.expected
2011 c8d1a97c 2023-07-17 mark if [ $ret -ne 0 ]; then
2012 c8d1a97c 2023-07-17 mark diff -u $testroot/wt/numbers $testroot/wt/numbers.expected
2015 c8d1a97c 2023-07-17 mark (cd "$testroot/wt" && got rv numbers > /dev/null)
2017 c8d1a97c 2023-07-17 mark (cd $testroot/wt && got patch -c :base:- patch) >$testroot/stdout
2019 c8d1a97c 2023-07-17 mark if [ $ret -ne 0 ]; then
2020 c8d1a97c 2023-07-17 mark test_done $testroot $ret
2024 c8d1a97c 2023-07-17 mark echo 'G numbers' > $testroot/stdout.expected
2025 c8d1a97c 2023-07-17 mark cmp -s $testroot/stdout $testroot/stdout.expected
2027 c8d1a97c 2023-07-17 mark if [ $ret -ne 0 ]; then
2028 c8d1a97c 2023-07-17 mark diff -u $testroot/stdout $testroot/stdout.expected
2029 c8d1a97c 2023-07-17 mark test_done $testroot $ret
2033 c8d1a97c 2023-07-17 mark jot 10 | sed -e s/4/four/ -e s/6/six/ > $testroot/wt/numbers.expected
2034 c8d1a97c 2023-07-17 mark cmp -s $testroot/wt/numbers $testroot/wt/numbers.expected
2036 c8d1a97c 2023-07-17 mark if [ $ret -ne 0 ]; then
2037 c8d1a97c 2023-07-17 mark diff -u $testroot/wt/numbers $testroot/wt/numbers.expected
2040 c8d1a97c 2023-07-17 mark test_done $testroot $ret
2043 e9ce266e 2022-03-07 op test_parseargs "$@"
2044 57b1c3f2 2022-08-01 op run_test test_patch_basic
2045 e9ce266e 2022-03-07 op run_test test_patch_dont_apply
2046 e9ce266e 2022-03-07 op run_test test_patch_malformed
2047 e9ce266e 2022-03-07 op run_test test_patch_no_patch
2048 e9ce266e 2022-03-07 op run_test test_patch_equals_for_context
2049 6e96b326 2022-03-12 op run_test test_patch_rename
2050 dbda770b 2022-03-13 op run_test test_patch_illegal_status
2051 899fcfdf 2022-03-13 op run_test test_patch_nop
2052 2be5e1a2 2022-03-16 op run_test test_patch_preserve_perm
2053 95d68340 2022-03-16 op run_test test_patch_create_dirs
2054 60aa1fa0 2022-03-17 op run_test test_patch_with_offset
2055 7a30b5cb 2022-03-20 op run_test test_patch_prefer_new_path
2056 b3c57ab2 2022-03-22 op run_test test_patch_no_newline
2057 9d6cabd5 2022-04-07 op run_test test_patch_strip
2058 a92a2042 2022-07-02 op run_test test_patch_whitespace
2059 ed3bff83 2022-04-23 op run_test test_patch_relative_paths
2060 15e1bda6 2022-04-23 op run_test test_patch_with_path_prefix
2061 15e1bda6 2022-04-23 op run_test test_patch_relpath_with_path_prefix
2062 bad961bf 2022-04-23 op run_test test_patch_reverse
2063 55e9459f 2022-06-19 op run_test test_patch_merge_simple
2064 db0dfdd7 2022-06-27 op run_test test_patch_merge_gitdiff
2065 5f56d41e 2022-07-28 op run_test test_patch_merge_base_provided
2066 55e9459f 2022-06-19 op run_test test_patch_merge_conflict
2067 55e9459f 2022-06-19 op run_test test_patch_merge_unknown_blob
2068 38d61ead 2022-07-23 op run_test test_patch_merge_reverse
2069 611e5fc2 2022-09-21 mark run_test test_patch_newfile_xbit_got_diff
2070 611e5fc2 2022-09-21 mark run_test test_patch_newfile_xbit_git_diff
2071 b2b3fce1 2022-10-29 op run_test test_patch_umask
2072 684a9a6c 2022-12-31 op run_test test_patch_remove_binary_file
2073 c8d1a97c 2023-07-17 mark run_test test_patch_commit_keywords