aesthetic: rename regress to test_patch_rm_file
[got-portable.git] / regress / cmdline / patch.sh
bloba7ff83ea9847a8fa722fdbfda0cfc471da1d050d
1 #!/bin/sh
3 # Copyright (c) 2022 Omar Polo <op@openbsd.org>
5 # Permission to use, copy, modify, and distribute this software for any
6 # purpose with or without fee is hereby granted, provided that the above
7 # copyright notice and this permission notice appear in all copies.
9 # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 . ./common.sh
19 test_patch_add_file() {
20 local testroot=`test_init patch_add_file`
22 got checkout $testroot/repo $testroot/wt > /dev/null
23 ret=$?
24 if [ $ret -ne 0 ]; then
25 test_done $testroot $ret
26 return 1
29 cat <<EOF > $testroot/wt/patch
30 --- /dev/null
31 +++ eta
32 @@ -0,0 +5,5 @@
38 EOF
40 (cd $testroot/wt && got patch patch) > $testroot/stdout
41 ret=$?
42 if [ $ret -ne 0 ]; then
43 test_done $testroot $ret
44 return 1
47 echo "A eta" > $testroot/stdout.expected
48 cmp -s $testroot/stdout.expected $testroot/stdout
49 ret=$?
50 if [ $ret -ne 0 ]; then
51 diff -u $testroot/stdout.expected $testroot/stdout
52 test_done $testroot $ret
53 return 1
56 jot 5 > $testroot/wt/eta.expected
57 cmp -s $testroot/wt/eta.expected $testroot/wt/eta
58 ret=$?
59 if [ $ret -ne 0 ]; then
60 diff -u $testroot/wt/eta.expected $testroot/wt/eta
62 test_done $testroot $ret
65 test_patch_rm_file() {
66 local testroot=`test_init patch_rm_file`
68 got checkout $testroot/repo $testroot/wt > /dev/null
69 ret=$?
70 if [ $ret -ne 0 ]; then
71 test_done $testroot $ret
72 return 1
75 cat <<EOF > $testroot/wt/patch
76 --- alpha
77 +++ /dev/null
78 @@ -1 +0,0 @@
79 -alpha
80 EOF
82 echo "D alpha" > $testroot/stdout.expected
84 (cd $testroot/wt && got patch patch) > $testroot/stdout
85 ret=$?
86 if [ $ret -ne 0 ]; then
87 test_done $testroot $ret
88 return 1
91 cmp -s $testroot/stdout.expected $testroot/stdout
92 ret=$?
93 if [ $ret -ne 0 ]; then
94 diff -u $testroot/stdout.expected $testroot/stdout
95 test_done $testroot $ret
96 return 1
99 if [ -f $testroot/wt/alpha ]; then
100 ret=1
101 echo "alpha still exists!"
103 test_done $testroot $ret
106 test_patch_simple_edit_file() {
107 local testroot=`test_init patch_simple_edit_file`
109 got checkout $testroot/repo $testroot/wt > /dev/null
110 ret=$?
111 if [ $ret -ne 0 ]; then
112 test_done $testroot $ret
113 return 1
116 cat <<EOF > $testroot/wt/patch
117 --- alpha
118 +++ alpha
119 @@ -1 +1 @@
120 -alpha
121 +alpha is my favourite character
124 echo "M alpha" > $testroot/stdout.expected
126 (cd $testroot/wt && got patch patch) > $testroot/stdout
127 ret=$?
128 if [ $ret -ne 0 ]; then
129 test_done $testroot $ret
130 return 1
133 cmp -s $testroot/stdout.expected $testroot/stdout
134 ret=$?
135 if [ $ret -ne 0 ]; then
136 diff -u $testroot/stdout.expected $testroot/stdout
137 test_done $testroot $ret
138 return 1
141 echo 'alpha is my favourite character' > $testroot/wt/alpha.expected
142 cmp -s $testroot/wt/alpha.expected $testroot/wt/alpha
143 ret=$?
144 if [ $ret -ne 0 ]; then
145 diff -u $testroot/wt/alpha.expected $testroot/wt/alpha
147 test_done $testroot $ret
150 test_patch_prepend_line() {
151 local testroot=`test_init patch_prepend_line`
153 got checkout $testroot/repo $testroot/wt > /dev/null
154 ret=$?
155 if [ $ret -ne 0 ]; then
156 test_done $testroot $ret
157 return 1
160 cat <<EOF > $testroot/wt/patch
161 --- alpha
162 +++ alpha
163 @@ -1 +1,2 @@
164 +hatsuseno
165 alpha
168 echo "M alpha" > $testroot/stdout.expected
170 (cd $testroot/wt && got patch patch) > $testroot/stdout
171 ret=$?
172 if [ $ret -ne 0 ]; then
173 test_done $testroot $ret
174 return 1
177 cmp -s $testroot/stdout.expected $testroot/stdout
178 ret=$?
179 if [ $ret -ne 0 ]; then
180 diff -u $testroot/stdout.expected $testroot/stdout
181 test_done $testroot $ret
182 return 1
185 echo hatsuseno > $testroot/wt/alpha.expected
186 echo alpha >> $testroot/wt/alpha.expected
187 cmp -s $testroot/wt/alpha.expected $testroot/wt/alpha
188 ret=$?
189 if [ $ret -ne 0 ]; then
190 diff -u $testroot/wt/alpha.expected $testroot/wt/alpha
192 test_done $testroot $ret
195 test_patch_replace_line() {
196 local testroot=`test_init patch_replace_line`
198 got checkout $testroot/repo $testroot/wt > /dev/null
199 ret=$?
200 if [ $ret -ne 0 ]; then
201 test_done $testroot $ret
202 return 1
205 jot 10 > $testroot/wt/numbers
206 (cd $testroot/wt/ && got add numbers && got ci -m 'add numbers') \
207 >/dev/null
208 ret=$?
209 if [ $ret -ne 0 ]; then
210 test_done $testroot $ret
211 return 1
214 cat <<EOF > $testroot/wt/patch
215 --- numbers
216 +++ numbers
217 @@ -3,7 +3,7 @@
222 +foo
228 echo "M numbers" > $testroot/stdout.expected
230 (cd $testroot/wt && got patch patch) > $testroot/stdout
231 ret=$?
232 if [ $ret -ne 0 ]; then
233 test_done $testroot $ret
234 return 1
237 cmp -s $testroot/stdout.expected $testroot/stdout
238 ret=$?
239 if [ $ret -ne 0 ]; then
240 diff -u $testroot/stdout.expected $testroot/stdout
241 test_done $testroot $ret
242 return 1
245 jot 10 | sed 's/6/foo/' > $testroot/wt/numbers.expected
246 cmp -s $testroot/wt/numbers.expected $testroot/wt/numbers
247 ret=$?
248 if [ $ret -ne 0 ]; then
249 diff -u $testroot/wt/numbers.expected $testroot/wt/numbers
251 test_done $testroot $ret
254 test_patch_multiple_hunks() {
255 local testroot=`test_init patch_replace_multiple_hunks`
257 got checkout $testroot/repo $testroot/wt > /dev/null
258 ret=$?
259 if [ $ret -ne 0 ]; then
260 test_done $testroot $ret
261 return 1
264 jot 100 > $testroot/wt/numbers
265 (cd $testroot/wt/ && got add numbers && got ci -m 'add numbers') \
266 >/dev/null
267 ret=$?
268 if [ $ret -ne 0 ]; then
269 test_done $testroot $ret
270 return 1
273 cat <<EOF > $testroot/wt/patch
274 --- numbers
275 +++ numbers
276 @@ -3,7 +3,7 @@
281 +foo
285 @@ -57,7 +57,7 @@
290 +foo foo
294 @@ -98,3 +98,6 @@
298 +101
299 +102
300 +...
303 echo "M numbers" > $testroot/stdout.expected
305 (cd $testroot/wt && got patch patch) > $testroot/stdout
306 ret=$?
307 if [ $ret -ne 0 ]; then
308 test_done $testroot $ret
309 return 1
312 cmp -s $testroot/stdout.expected $testroot/stdout
313 ret=$?
314 if [ $ret -ne 0 ]; then
315 diff -u $testroot/stdout.expected $testroot/stdout
316 test_done $testroot $ret
317 return 1
320 jot 100 | sed -e 's/^6$/foo/' -e 's/^60$/foo foo/' \
321 > $testroot/wt/numbers.expected
322 echo "101" >> $testroot/wt/numbers.expected
323 echo "102" >> $testroot/wt/numbers.expected
324 echo "..." >> $testroot/wt/numbers.expected
326 cmp -s $testroot/wt/numbers.expected $testroot/wt/numbers
327 ret=$?
328 if [ $ret -ne 0 ]; then
329 diff -u $testroot/wt/numbers.expected $testroot/wt/numbers
331 test_done $testroot $ret
334 test_patch_multiple_files() {
335 local testroot=`test_init patch_multiple_files`
337 got checkout $testroot/repo $testroot/wt > /dev/null
338 ret=$?
339 if [ $ret -ne 0 ]; then
340 test_done $testroot $ret
341 return 1
344 cat <<EOF > $testroot/wt/patch
345 --- alpha Mon Mar 7 19:02:07 2022
346 +++ alpha Mon Mar 7 19:01:53 2022
347 @@ -1 +1,3 @@
348 +new
349 alpha
350 +available
351 --- beta Mon Mar 7 19:02:11 2022
352 +++ beta Mon Mar 7 19:01:46 2022
353 @@ -1 +1,3 @@
354 beta
355 +was
356 +improved
357 --- gamma/delta Mon Mar 7 19:02:17 2022
358 +++ gamma/delta Mon Mar 7 19:01:37 2022
359 @@ -1 +1 @@
360 -delta
361 +delta new
364 echo "M alpha" > $testroot/stdout.expected
365 echo "M beta" >> $testroot/stdout.expected
366 echo "M gamma/delta" >> $testroot/stdout.expected
368 (cd $testroot/wt && got patch patch) > $testroot/stdout
369 ret=$?
370 if [ $ret -ne 0 ]; then
371 test_done $testroot $ret
372 return 1
375 cmp -s $testroot/stdout.expected $testroot/stdout
376 ret=$?
377 if [ $ret -ne 0 ]; then
378 diff -u $testroot/stdout.expected $testroot/stdout
379 test_done $testroot $ret
380 return 1
383 printf 'new\nalpha\navailable\n' > $testroot/wt/alpha.expected
384 printf 'beta\nwas\nimproved\n' > $testroot/wt/beta.expected
385 printf 'delta new\n' > $testroot/wt/gamma/delta.expected
387 for f in alpha beta gamma/delta; do
388 cmp -s $testroot/wt/$f.expected $testroot/wt/$f
389 ret=$?
390 if [ $ret -ne 0 ]; then
391 diff -u $testroot/wt/$f.expected $testroot/wt/$f
392 test_done $testroot $ret
393 return 1
395 done
397 test_done $testroot 0
400 test_patch_dont_apply() {
401 local testroot=`test_init patch_dont_apply`
403 got checkout $testroot/repo $testroot/wt > /dev/null
404 ret=$?
405 if [ $ret -ne 0 ]; then
406 test_done $testroot $ret
407 return 1
410 jot 100 > $testroot/wt/numbers
411 (cd $testroot/wt && got add numbers && got commit -m 'add numbers') \
412 >/dev/null
413 ret=$?
414 if [ $ret -ne 0 ]; then
415 test_done $testroot $ret
416 return 1
419 cat <<EOF > $testroot/wt/patch
420 --- alpha
421 +++ alpha
422 @@ -1 +1,2 @@
423 +hatsuseno
424 alpha something
425 --- numbers
426 +++ /dev/null
427 @@ -1,9 +0,0 @@
439 (cd $testroot/wt && got patch patch) > $testroot/stdout 2> /dev/null
440 ret=$?
441 if [ $ret -eq 0 ]; then # should fail
442 test_done $testroot 1
443 return 1
446 cat <<EOF > $testroot/stdout.expected
447 # alpha
448 @@ -1,1 +1,2 @@ hunk failed to apply
449 # numbers
450 @@ -1,9 +0,0 @@ hunk failed to apply
453 cmp -s $testroot/stdout.expected $testroot/stdout
454 ret=$?
455 if [ $ret -ne 0 ]; then
456 diff -u $testroot/stdout.expected $testroot/stdout
458 test_done $testroot $ret
461 test_patch_malformed() {
462 local testroot=`test_init patch_malformed`
464 got checkout $testroot/repo $testroot/wt > /dev/null
465 ret=$?
466 if [ $ret -ne 0 ]; then
467 test_done $testroot $ret
468 return 1
471 # missing "@@"
472 cat <<EOF > $testroot/wt/patch
473 --- alpha
474 +++ alpha
475 @@ -1 +1,2
476 +hatsuseno
477 alpha
480 echo -n > $testroot/stdout.expected
481 echo "got: malformed patch" > $testroot/stderr.expected
483 (cd $testroot/wt && got patch patch) \
484 > $testroot/stdout \
485 2> $testroot/stderr
486 ret=$?
487 if [ $ret -eq 0 ]; then
488 echo "got managed to apply an invalid patch"
489 test_done $testroot 1
490 return 1
493 cmp -s $testroot/stdout.expected $testroot/stdout
494 ret=$?
495 if [ $ret -ne 0 ]; then
496 diff -u $testroot/stdout.expected $testroot/stdout
497 test_done $testroot $ret
498 return 1
501 cmp -s $testroot/stderr.expected $testroot/stderr
502 ret=$?
503 if [ $ret -ne 0 ]; then
504 diff -u $testroot/stderr.expected $testroot/stderr
505 test_done $testroot $ret
506 return 1
509 # wrong first character
510 cat <<EOF > $testroot/wt/patch
511 --- alpha
512 +++ alpha
513 @@ -1 +1,2 @@
514 +hatsuseno
515 alpha
518 (cd $testroot/wt && got patch patch) \
519 > $testroot/stdout \
520 2> $testroot/stderr
521 ret=$?
522 if [ $ret -eq 0 ]; then
523 echo "got managed to apply an invalid patch"
524 test_done $testroot 1
525 return 1
528 cmp -s $testroot/stdout.expected $testroot/stdout
529 ret=$?
530 if [ $ret -ne 0 ]; then
531 diff -u $testroot/stdout.expected $testroot/stdout
532 test_done $testroot $ret
533 return 1
536 cmp -s $testroot/stderr.expected $testroot/stderr
537 ret=$?
538 if [ $ret -ne 0 ]; then
539 diff -u $testroot/stderr.expected $testroot/stderr
540 test_done $testroot $ret
541 return 1
544 # empty hunk
545 cat <<EOF > $testroot/wt/patch
546 diff --git a/alpha b/iota
547 --- a/alpha
548 +++ b/iota
549 @@ -0,0 +0,0 @@
552 (cd $testroot/wt && got patch patch) \
553 > $testroot/stdout \
554 2> $testroot/stderr
555 ret=$?
556 if [ $ret -eq 0 ]; then
557 echo "got managed to apply an invalid patch"
558 test_done $testroot 1
559 return 1
562 cmp -s $testroot/stdout.expected $testroot/stdout
563 ret=$?
564 if [ $ret -ne 0 ]; then
565 diff -u $testroot/stdout.expected $testroot/stdout
566 test_done $testroot $ret
567 return 1
570 cmp -s $testroot/stderr.expected $testroot/stderr
571 ret=$?
572 if [ $ret -ne 0 ]; then
573 diff -u $testroot/stderr.expected $testroot/stderr
574 test_done $testroot $ret
575 return 1
578 test_done $testroot $ret
581 test_patch_no_patch() {
582 local testroot=`test_init patch_no_patch`
584 got checkout $testroot/repo $testroot/wt > /dev/null
585 ret=$?
586 if [ $ret -ne 0 ]; then
587 test_done $testroot $ret
588 return 1
591 cat <<EOF > $testroot/wt/patch
592 hello world!
595 some other nonsense
598 there's no patch in here!
601 echo -n > $testroot/stdout.expected
602 echo "got: no patch found" > $testroot/stderr.expected
604 (cd $testroot/wt && got patch patch) \
605 > $testroot/stdout \
606 2> $testroot/stderr
607 ret=$?
608 if [ $ret -eq 0 ]; then # should fail
609 test_done $testroot 1
610 return 1
613 cmp -s $testroot/stdout.expected $testroot/stdout
614 ret=$?
615 if [ $ret -ne 0 ]; then
616 diff -u $testroot/stdout.expected $testroot/stdout
617 test_done $testroot $ret
618 return 1
621 cmp -s $testroot/stderr.expected $testroot/stderr
622 ret=$?
623 if [ $ret -ne 0 ]; then
624 diff -u $testroot/stderr.expected $testroot/stderr
625 test_done $testroot $ret
626 return 1
629 test_done $testroot $ret
632 test_patch_equals_for_context() {
633 local testroot=`test_init patch_equals_for_context`
635 got checkout $testroot/repo $testroot/wt > /dev/null
636 ret=$?
637 if [ $ret -ne 0 ]; then
638 test_done $testroot $ret
639 return 1
642 cat <<EOF > $testroot/wt/patch
643 --- alpha
644 +++ alpha
645 @@ -1 +1,2 @@
646 +hatsuseno
647 =alpha
650 echo "M alpha" > $testroot/stdout.expected
652 (cd $testroot/wt && got patch patch) > $testroot/stdout
653 ret=$?
654 if [ $ret -ne 0 ]; then
655 test_done $testroot $ret
656 return 1
659 cmp -s $testroot/stdout.expected $testroot/stdout
660 ret=$?
661 if [ $ret -ne 0 ]; then
662 diff -u $testroot/stdout.expected $testroot/stdout
663 test_done $testroot $ret
664 return 1
667 echo hatsuseno > $testroot/wt/alpha.expected
668 echo alpha >> $testroot/wt/alpha.expected
669 cmp -s $testroot/wt/alpha.expected $testroot/wt/alpha
670 ret=$?
671 if [ $ret -ne 0 ]; then
672 diff -u $testroot/wt/alpha.expected $testroot/wt/alpha
674 test_done $testroot $ret
677 test_patch_rename() {
678 local testroot=`test_init patch_rename`
680 got checkout $testroot/repo $testroot/wt > /dev/null
681 ret=$?
682 if [ $ret -ne 0 ]; then
683 test_done $testroot $ret
684 return 1
687 cat <<EOF > $testroot/wt/patch
688 diff --git a/beta b/iota
689 similarity index 100%
690 rename from beta
691 rename to iota
692 diff --git a/alpha b/eta
693 --- a/alpha
694 +++ b/eta
695 @@ -1 +1 @@
696 -alpha
697 +eta
700 echo 'D beta' > $testroot/stdout.expected
701 echo 'A iota' >> $testroot/stdout.expected
702 echo 'D alpha' >> $testroot/stdout.expected
703 echo 'A eta' >> $testroot/stdout.expected
705 (cd $testroot/wt && got patch patch) > $testroot/stdout
706 ret=$?
707 if [ $ret -ne 0 ]; then
708 test_done $testroot $ret
709 return 1
712 cmp -s $testroot/stdout.expected $testroot/stdout
713 ret=$?
714 if [ $ret -ne 0 ]; then
715 diff -u $testroot/stdout.expected $testroot/stdout
716 test_done $testroot $ret
717 return 1
720 if [ -f $testroot/wt/alpha -o -f $testroot/wt/beta ]; then
721 echo "alpha or beta were not removed" >&2
722 test_done $testroot 1
723 return 1
725 if [ ! -f $testroot/wt/iota -o ! -f $testroot/wt/eta ]; then
726 echo "iota or eta were not created" >&2
727 test_done $testroot 1
728 return 1
731 echo beta > $testroot/wt/iota.expected
732 cmp -s $testroot/wt/iota.expected $testroot/wt/iota
733 ret=$?
734 if [ $ret -ne 0 ]; then
735 diff -u $testroot/wt/iota.expected $testroot/wt/iota
736 test_done $testroot $ret
737 return 1
740 echo eta > $testroot/wt/eta.expected
741 cmp -s $testroot/wt/eta.expected $testroot/wt/eta
742 ret=$?
743 if [ $ret -ne 0 ]; then
744 diff -u $testroot/wt/eta.expected $testroot/wt/eta
745 test_done $testroot $ret
746 return 1
749 test_done $testroot $ret
752 test_patch_illegal_status() {
753 local testroot=`test_init patch_illegal_status`
755 got checkout $testroot/repo $testroot/wt > /dev/null
756 ret=$?
757 if [ $ret -ne 0 ]; then
758 test_done $testroot $ret
759 return 1
762 # try to patch an obstructed file, add a versioned one, edit a
763 # non existent file and an unversioned one, and remove a
764 # non existent file.
765 cat <<EOF > $testroot/wt/patch
766 --- alpha
767 +++ alpha
768 @@ -1 +1,2 @@
769 alpha
770 +was edited
771 --- /dev/null
772 +++ beta
773 @@ -0,0 +1 @@
774 +beta
775 --- iota
776 +++ iota
777 @@ -1 +1 @@
778 -iota
779 +IOTA
780 --- kappa
781 +++ kappa
782 @@ -1 +1 @@
783 -kappa
784 +KAPPA
785 --- lambda
786 +++ /dev/null
787 @@ -1 +0,0 @@
788 -lambda
791 echo kappa > $testroot/wt/kappa
792 rm $testroot/wt/alpha
793 mkdir $testroot/wt/alpha
795 (cd $testroot/wt && got patch patch) > $testroot/stdout \
796 2> $testroot/stderr
797 ret=$?
798 if [ $ret -eq 0 ]; then
799 echo "edited a missing file" >&2
800 test_done $testroot 1
801 return 1
804 cat <<EOF > $testroot/stdout.expected
805 # alpha
806 # beta
807 # iota
808 # kappa
809 # lambda
812 cat <<EOF > $testroot/stderr.expected
813 got: alpha: file has unexpected status
814 got: beta: file has unexpected status
815 got: iota: No such file or directory
816 got: kappa: file has unexpected status
817 got: lambda: No such file or directory
818 got: patch failed to apply
821 cmp -s $testroot/stdout.expected $testroot/stdout
822 ret=$?
823 if [ $ret -ne 0 ]; then
824 diff -u $testroot/stdout.expected $testroot/stdout
825 test_done $testroot $ret
826 return 1
829 cmp -s $testroot/stderr.expected $testroot/stderr
830 ret=$?
831 if [ $ret -ne 0 ]; then
832 diff -u $testroot/stderr.expected $testroot/stderr
833 test_done $testroot $ret
834 return 1
837 (cd $testroot/wt && got status) > $testroot/stdout
838 cat <<EOF > $testroot/stdout.expected
839 ~ alpha
840 ? kappa
841 ? patch
844 cmp -s $testroot/stdout.expected $testroot/stdout
845 ret=$?
846 if [ $ret -ne 0 ]; then
847 diff -u $testroot/stdout.expected $testroot/stdout
849 test_done $testroot $ret
852 test_patch_nop() {
853 local testroot=`test_init patch_nop`
855 got checkout $testroot/repo $testroot/wt > /dev/null
856 ret=$?
857 if [ $ret -ne 0 ]; then
858 test_done $testroot $ret
859 return 1
862 cat <<EOF > $testroot/wt/patch
863 --- alpha
864 +++ alpha
865 @@ -1 +1 @@
866 -alpha
867 +cafe alpha
868 --- beta
869 +++ /dev/null
870 @@ -1 +0,0 @@
871 -beta
872 diff --git a/gamma/delta b/gamma/delta.new
873 --- gamma/delta
874 +++ gamma/delta.new
875 @@ -1 +1 @@
876 -delta
877 +delta updated and renamed!
880 (cd $testroot/wt && got patch -n patch)
881 ret=$?
882 if [ $ret -ne 0 ]; then
883 test_done $testroot $ret
884 return 1
887 # remove the patch to avoid the ? entry
888 rm $testroot/wt/patch
890 (cd $testroot/wt && got status) > $testroot/stdout
891 ret=$?
892 if [ $ret -ne 0 ]; then
893 test_done $testroot $ret
894 return 1
897 echo -n > $testroot/stdout.expected
898 cmp -s $testroot/stdout.expected $testroot/stdout
899 ret=$?
900 if [ $ret -ne 0 ]; then
901 diff -u $testroot/stdout.expected $testroot/stdout
903 test_done $testroot $ret
906 test_patch_preserve_perm() {
907 local testroot=`test_init patch_preserve_perm`
909 got checkout $testroot/repo $testroot/wt > /dev/null
910 ret=$?
911 if [ $ret -ne 0 ]; then
912 test_done $testroot $ret
913 return 1
916 chmod +x $testroot/wt/alpha
917 (cd $testroot/wt && got commit -m 'alpha executable') > /dev/null
918 ret=$?
919 if [ $ret -ne 0 ]; then
920 test_done $testroot $ret
921 return 1
924 cat <<EOF > $testroot/wt/patch
925 --- alpha
926 +++ alpha
927 @@ -1 +1,2 @@
928 alpha
929 +was edited
932 (cd $testroot/wt && got patch patch) > /dev/null
933 ret=$?
934 if [ $ret -ne 0 ]; then
935 test_done $testroot $ret
936 return 1
939 if [ ! -x $testroot/wt/alpha ]; then
940 echo "alpha is no more executable!" >&2
941 test_done $testroot 1
942 return 1
944 test_done $testroot 0
947 test_patch_create_dirs() {
948 local testroot=`test_init patch_create_dirs`
950 got checkout $testroot/repo $testroot/wt > /dev/null
951 ret=$?
952 if [ $ret -ne 0 ]; then
953 test_done $testroot $ret
954 return 1
957 cat <<EOF > $testroot/wt/patch
958 --- /dev/null
959 +++ iota/kappa/lambda
960 @@ -0,0 +1 @@
961 +lambda
964 (cd $testroot/wt && got patch patch) > $testroot/stdout
965 ret=$?
966 if [ $ret -ne 0 ]; then
967 test_done $testroot $ret
968 return 1
971 echo 'A iota/kappa/lambda' >> $testroot/stdout.expected
972 cmp -s $testroot/stdout.expected $testroot/stdout
973 ret=$?
974 if [ $ret -ne 0 ]; then
975 diff -u $testroot/stdout.expected $testroot/stdout
976 test_done $testroot $ret
977 return 1
980 if [ ! -f $testroot/wt/iota/kappa/lambda ]; then
981 echo "file not created!" >&2
982 test_done $testroot $ret
983 return 1
985 test_done $testroot 0
988 test_patch_with_offset() {
989 local testroot=`test_init patch_with_offset`
991 got checkout $testroot/repo $testroot/wt > /dev/null
992 ret=$?
993 if [ $ret -ne 0 ]; then
994 test_done $testroot $ret
995 return 1
998 cat <<EOF > $testroot/wt/patch
999 --- numbers
1000 +++ numbers
1001 @@ -47,7 +47,7 @@
1006 +midway tru it!
1010 @@ -87,7 +87,7 @@
1015 +almost there!
1021 jot 100 > $testroot/wt/numbers
1022 ed $testroot/wt/numbers <<EOF > /dev/null 2> /dev/null
1023 1,10d
1024 50r !jot 20
1029 (cd $testroot/wt && got add numbers && got commit -m '+numbers') \
1030 > /dev/null
1031 ret=$?
1032 if [ $ret -ne 0 ]; then
1033 test_done $testroot $ret
1034 return 1
1037 (cd $testroot/wt && got patch patch) > $testroot/stdout
1038 ret=$?
1039 if [ $ret -ne 0 ]; then
1040 test_done $testroot/wt $ret
1041 return 1
1044 cat <<EOF > $testroot/stdout.expected
1045 M numbers
1046 @@ -47,7 +47,7 @@ applied with offset -10
1047 @@ -87,7 +87,7 @@ applied with offset 10
1050 cmp -s $testroot/stdout.expected $testroot/stdout
1051 ret=$?
1052 if [ $ret -ne 0 ]; then
1053 diff -u $testroot/stdout.expected $testroot/stdout
1055 test_done $testroot $ret
1058 test_patch_prefer_new_path() {
1059 local testroot=`test_init patch_orig`
1061 got checkout $testroot/repo $testroot/wt > /dev/null
1062 ret=$?
1063 if [ $ret -ne 0 ]; then
1064 test_done $testroot $ret
1065 return 1
1068 cat <<EOF > $testroot/wt/patch
1069 --- alpha.orig
1070 +++ alpha
1071 @@ -1 +1,2 @@
1072 alpha
1073 +was edited
1076 (cd $testroot/wt && got patch patch) > $testroot/stdout
1077 ret=$?
1078 if [ $ret -ne 0 ]; then
1079 test_done $testroot $ret
1080 return 1
1083 echo 'M alpha' > $testroot/stdout.expected
1084 cmp -s $testroot/stdout.expected $testroot/stdout
1085 ret=$?
1086 if [ $ret -ne 0 ]; then
1087 diff -u $testroot/stdout.expected $testroot/stdout
1089 test_done $testroot $ret
1092 test_patch_no_newline() {
1093 local testroot=`test_init patch_no_newline`
1095 got checkout $testroot/repo $testroot/wt > /dev/null
1096 ret=$?
1097 if [ $ret -ne 0 ]; then
1098 test_done $testroot $ret
1099 return 1
1102 cat <<EOF > $testroot/wt/patch
1103 --- /dev/null
1104 +++ eta
1105 @@ -0,0 +1 @@
1106 +eta
1107 \ No newline at end of file
1110 (cd $testroot/wt && got patch patch) > $testroot/stdout
1111 ret=$?
1112 if [ $ret -ne 0 ]; then
1113 test_done $testroot $ret
1114 return 1
1117 echo "A eta" > $testroot/stdout.expected
1118 cmp -s $testroot/stdout.expected $testroot/stdout
1119 ret=$?
1120 if [ $ret -ne 0 ]; then
1121 diff -u $testroot/stdout.expected $testroot/stdout
1122 test_done $testroot $ret
1123 return 1
1126 echo -n eta > $testroot/wt/eta.expected
1127 cmp -s $testroot/wt/eta.expected $testroot/wt/eta
1128 ret=$?
1129 if [ $ret -ne 0 ]; then
1130 diff -u $testroot/wt/eta.expected $testroot/wt/eta
1131 test_done $testroot $ret
1132 return 1
1135 (cd $testroot/wt && got commit -m 'add eta') > /dev/null
1136 ret=$?
1137 if [ $ret -ne 0 ]; then
1138 test_done $testroot $ret
1139 return 1
1142 cat <<EOF > $testroot/wt/patch
1143 --- eta
1144 +++ eta
1145 @@ -1 +1 @@
1146 -eta
1147 \ No newline at end of file
1148 +ETA
1149 \ No newline at end of file
1152 (cd $testroot/wt && got patch patch) > $testroot/stdout
1153 ret=$?
1154 if [ $ret -ne 0 ]; then
1155 test_done $testroot $ret
1156 return 1
1159 echo "M eta" > $testroot/stdout.expected
1160 cmp -s $testroot/stdout.expected $testroot/stdout
1161 ret=$?
1162 if [ $ret -ne 0 ]; then
1163 diff -u $testroot/stdout.expected $testroot/stdout
1164 test_done $testroot $ret
1165 return 1
1168 echo -n ETA > $testroot/wt/eta.expected
1169 cmp -s $testroot/wt/eta.expected $testroot/wt/eta
1170 ret=$?
1171 if [ $ret -ne 0 ]; then
1172 diff -u $testroot/wt/eta.expected $testroot/wt/eta
1173 test_done $testroot $ret
1174 return 1
1177 (cd $testroot/wt && got commit -m 'edit eta') > /dev/null
1178 ret=$?
1179 if [ $ret -ne 0 ]; then
1180 test_done $testroot $ret
1181 return 1
1184 cat <<EOF > $testroot/wt/patch
1185 --- eta
1186 +++ eta
1187 @@ -1 +1 @@
1188 -ETA
1189 \ No newline at end of file
1190 +eta
1193 (cd $testroot/wt && got patch patch) > $testroot/stdout
1194 ret=$?
1195 if [ $ret -ne 0 ]; then
1196 test_done $testroot $ret
1197 return 1
1200 echo "M eta" > $testroot/stdout.expected
1201 cmp -s $testroot/stdout.expected $testroot/stdout
1202 ret=$?
1203 if [ $ret -ne 0 ]; then
1204 diff -u $testroot/stdout.expected $testroot/stdout
1205 test_done $testroot $ret
1206 return 1
1209 echo eta > $testroot/wt/eta.expected
1210 cmp -s $testroot/wt/eta.expected $testroot/wt/eta
1211 ret=$?
1212 if [ $ret -ne 0 ]; then
1213 diff -u $testroot/wt/eta.expected $testroot/wt/eta
1215 test_done $testroot $ret
1218 test_patch_strip() {
1219 local testroot=`test_init patch_strip`
1221 got checkout $testroot/repo $testroot/wt > /dev/null
1222 ret=$?
1223 if [ $ret -ne 0 ]; then
1224 test_done $testroot $ret
1225 return 1
1228 cat <<EOF > $testroot/wt/patch
1229 --- foo/bar/alpha.orig
1230 +++ foo/bar/alpha
1231 @@ -1 +1 @@
1232 -alpha
1233 +ALPHA
1236 (cd $testroot/wt && got patch -p2 patch) > $testroot/stdout
1237 ret=$?
1238 if [ $ret -ne 0 ]; then
1239 test_done $testroot $ret
1240 return 1
1243 echo "M alpha" >> $testroot/stdout.expected
1244 cmp -s $testroot/stdout.expected $testroot/stdout
1245 ret=$?
1246 if [ $ret -ne 0 ]; then
1247 diff -u $testroot/stdout.expected $testroot/stdout
1248 test_done $testroot $ret
1249 return 1
1252 (cd $testroot/wt && got revert alpha) > /dev/null 2>&1
1253 ret=$?
1254 if [ $ret -ne 0 ]; then
1255 test_done $testroot $ret
1256 return 1
1259 (cd $testroot/wt && got patch -p3 patch) \
1260 2> $testroot/stderr
1261 ret=$?
1262 if [ $ret -eq 0 ]; then
1263 echo "stripped more components than available!"
1264 test_done $testroot 1
1265 return 1
1268 cat <<EOF > $testroot/stderr.expected
1269 got: can't strip 1 path-components from foo/bar/alpha: bad path
1272 cmp -s $testroot/stderr.expected $testroot/stderr
1273 ret=$?
1274 if [ $ret -ne 0 ]; then
1275 diff -u $testroot/stderr.expected $testroot/stderr
1277 test_done $testroot 0
1280 test_patch_relative_paths() {
1281 local testroot=`test_init patch_relative_paths`
1283 got checkout $testroot/repo $testroot/wt > /dev/null
1284 ret=$?
1285 if [ $ret -ne 0 ]; then
1286 test_done $testroot $ret
1287 return 1
1290 cat <<EOF > $testroot/wt/gamma/patch
1291 --- delta
1292 +++ delta
1293 @@ -1 +1 @@
1294 -delta
1295 +DELTA
1296 --- /dev/null
1297 +++ eta
1298 @@ -0,0 +1 @@
1299 +eta
1302 (cd $testroot/wt/gamma && got patch patch) > $testroot/stdout
1303 ret=$?
1304 if [ $ret -ne 0 ]; then
1305 test_done $testroot $ret
1306 return 1
1309 echo 'M gamma/delta' > $testroot/stdout.expected
1310 echo 'A gamma/eta' >> $testroot/stdout.expected
1312 cmp -s $testroot/stdout.expected $testroot/stdout
1313 ret=$?
1314 if [ $ret -ne 0 ]; then
1315 diff -u $testroot/stdout.expected $testroot/stdout
1317 test_done $testroot $ret
1320 test_patch_with_path_prefix() {
1321 local testroot=`test_init patch_with_path_prefix`
1323 got checkout -p gamma $testroot/repo $testroot/wt > /dev/null
1324 ret=$?
1325 if [ $ret -ne 0 ]; then
1326 test_done $testroot $ret
1327 return 1
1330 cat <<EOF > $testroot/wt/patch
1331 --- delta
1332 +++ delta
1333 @@ -1 +1 @@
1334 -delta
1335 +DELTA
1336 --- /dev/null
1337 +++ eta
1338 @@ -0,0 +1 @@
1339 +eta
1342 (cd $testroot/wt && got patch patch) > $testroot/stdout
1343 ret=$?
1344 if [ $ret -ne 0 ]; then
1345 test_done $testroot $ret
1346 return 1
1349 echo 'M delta' > $testroot/stdout.expected
1350 echo 'A eta' >> $testroot/stdout.expected
1352 cmp -s $testroot/stdout.expected $testroot/stdout
1353 ret=$?
1354 if [ $ret -ne 0 ]; then
1355 diff -u $testroot/stdout.expected $testroot/stdout
1357 test_done $testroot $ret
1360 test_patch_relpath_with_path_prefix() {
1361 local testroot=`test_init patch_relpaths_with_path_prefix`
1363 got checkout -p gamma $testroot/repo $testroot/wt > /dev/null
1364 ret=$?
1365 if [ $ret -ne 0 ]; then
1366 test_done $testroot $ret
1367 return 1
1370 mkdir -p $testroot/wt/epsilon/zeta/
1372 cat <<EOF > $testroot/wt/patch
1373 --- /dev/null
1374 +++ zeta/theta
1375 @@ -0,0 +1 @@
1376 +theta
1379 (cd $testroot/wt/epsilon/zeta && got patch -p1 $testroot/wt/patch) \
1380 > $testroot/stdout
1381 ret=$?
1382 if [ $ret -ne 0 ]; then
1383 test_done $testroot $ret
1384 return 1
1387 echo 'A epsilon/zeta/theta' >> $testroot/stdout.expected
1389 cmp -s $testroot/stdout.expected $testroot/stdout
1390 ret=$?
1391 if [ $ret -ne 0 ]; then
1392 diff -u $testroot/stdout.expected $testroot/stdout
1393 test_done $testroot $ret
1394 return 1
1397 echo 'theta' > $testroot/theta.expected
1398 cmp -s $testroot/wt/epsilon/zeta/theta $testroot/theta.expected
1399 ret=$?
1400 if [ $ret -ne 0 ]; then
1401 diff -u $testroot/wt/epsilon/zeta/theta $testroot/theta.expected
1403 test_done $testroot $ret
1406 test_patch_reverse() {
1407 local testroot=`test_init patch_reverse`
1409 got checkout $testroot/repo $testroot/wt > /dev/null
1410 ret=$?
1411 if [ $ret -ne 0 ]; then
1412 test_done $testroot $ret
1413 return 1
1416 cat <<EOF > $testroot/wt/patch
1417 --- alpha
1418 +++ alpha
1419 @@ -1 +1 @@
1420 -ALPHA
1421 \ No newline at end of file
1422 +alpha
1425 (cd $testroot/wt && got patch -R patch) > $testroot/stdout
1426 ret=$?
1427 if [ $ret -ne 0 ]; then
1428 test_done $testroot $ret
1429 return 1
1432 echo "M alpha" > $testroot/stdout.expected
1433 cmp -s $testroot/stdout.expected $testroot/stdout
1434 ret=$?
1435 if [ $ret -ne 0 ]; then
1436 diff -u $testroot/stdout.expected $testroot/stdout
1437 test_done $testroot $ret
1438 return 1
1441 echo -n ALPHA > $testroot/wt/alpha.expected
1442 cmp -s $testroot/wt/alpha.expected $testroot/wt/alpha
1443 ret=$?
1444 if [ $ret -ne 0 ]; then
1445 diff -u $testroot/wt/alpha.expected $testroot/wt/alpha
1447 test_done $testroot $ret
1450 test_patch_merge_simple() {
1451 local testroot=`test_init patch_merge_simple`
1453 got checkout $testroot/repo $testroot/wt > /dev/null
1454 ret=$?
1455 if [ $ret -ne 0 ]; then
1456 test_done $testroot $ret
1457 return 1
1460 jot 10 > $testroot/wt/numbers
1461 (cd $testroot/wt && got add numbers && got commit -m +numbers) \
1462 > /dev/null
1463 ret=$?
1464 if [ $ret -ne 0 ]; then
1465 test_done $testroot $ret
1466 return 1
1469 jot 10 | sed 's/4/four/g' > $testroot/wt/numbers
1471 (cd $testroot/wt && got diff > $testroot/old.diff \
1472 && got revert numbers) >/dev/null
1473 ret=$?
1474 if [ $ret -ne 0 ]; then
1475 test_done $testroot $ret
1476 return 1
1479 jot 10 | sed 's/6/six/g' > $testroot/wt/numbers
1480 (cd $testroot/wt && got commit -m 'edit numbers') \
1481 > /dev/null
1482 ret=$?
1483 if [ $ret -ne 0 ]; then
1484 test_done $testroot $ret
1485 return 1
1488 (cd $testroot/wt && got patch $testroot/old.diff) \
1489 > $testroot/stdout
1490 ret=$?
1491 if [ $ret -ne 0 ]; then
1492 test_done $testroot $ret
1493 return 1
1496 echo 'G numbers' > $testroot/stdout.expected
1497 cmp -s $testroot/stdout $testroot/stdout.expected
1498 ret=$?
1499 if [ $ret -ne 0 ]; then
1500 diff -u $testroot/stdout $testroot/stdout.expected
1501 test_done $testroot $ret
1502 return 1
1505 jot 10 | sed -e s/4/four/ -e s/6/six/ > $testroot/wt/numbers.expected
1506 cmp -s $testroot/wt/numbers $testroot/wt/numbers.expected
1507 ret=$?
1508 if [ $ret -ne 0 ]; then
1509 diff -u $testroot/wt/numbers $testroot/wt/numbers.expected
1511 test_done $testroot $ret
1514 test_patch_merge_gitdiff() {
1515 local testroot=`test_init patch_merge_gitdiff`
1517 jot 10 > $testroot/repo/numbers
1518 (cd $testroot/repo && git add numbers && \
1519 git_commit $testroot/repo -m "nums")
1520 ret=$?
1521 if [ $ret -ne 0 ]; then
1522 test_done $testroot $ret
1523 return 1
1526 jot 10 | sed 's/4/four/g' > $testroot/repo/numbers
1527 (cd $testroot/repo && git diff > $testroot/old.diff)
1528 ret=$?
1529 if [ $ret -ne 0 ]; then
1530 test_done $testroot $ret
1531 return 1
1534 # restore numbers
1535 jot 10 > $testroot/repo/numbers
1537 jot 10 | sed 's/6/six/g' > $testroot/repo/numbers
1538 (cd $testroot/repo && git add numbers && \
1539 git_commit $testroot/repo -m "edit")
1540 ret=$?
1541 if [ $ret -ne 0 ]; then
1542 test_done $testroot $ret
1543 return 1
1546 # now work with got:
1547 got checkout $testroot/repo $testroot/wt > /dev/null
1548 ret=$?
1549 if [ $ret -ne 0 ]; then
1550 test_done $testroot $ret
1551 return 1
1554 (cd $testroot/wt && got patch $testroot/old.diff) > $testroot/stdout
1555 ret=$?
1556 if [ $ret -ne 0 ]; then
1557 test_done $testroot $ret
1558 return 1
1561 echo 'G numbers' > $testroot/stdout.expected
1562 cmp -s $testroot/stdout $testroot/stdout.expected
1563 ret=$?
1564 if [ $ret -ne 0 ]; then
1565 diff -u $testroot/stdout $testroot/stdout.expected
1567 test_done $testroot $ret
1570 test_patch_merge_conflict() {
1571 local testroot=`test_init patch_merge_conflict`
1573 got checkout $testroot/repo $testroot/wt > /dev/null
1574 ret=$?
1575 if [ $ret -ne 0 ]; then
1576 test_done $testroot $ret
1577 return 1
1580 jot 10 > $testroot/wt/numbers
1581 (cd $testroot/wt && got add numbers && got commit -m +numbers) \
1582 > /dev/null
1583 ret=$?
1584 if [ $ret -ne 0 ]; then
1585 test_done $testroot $ret
1586 return 1
1589 local commit_id=`git_show_head $testroot/repo`
1591 jot 10 | sed 's/6/six/g' > $testroot/wt/numbers
1592 echo ALPHA > $testroot/wt/alpha
1594 (cd $testroot/wt && got diff > $testroot/old.diff \
1595 && got revert alpha numbers) >/dev/null
1596 ret=$?
1597 if [ $ret -ne 0 ]; then
1598 test_done $testroot $ret
1599 return 1
1602 jot 10 | sed 's/6/3+3/g' > $testroot/wt/numbers
1603 jot -c 3 a > $testroot/wt/alpha
1604 (cd $testroot/wt && got commit -m 'edit alpha and numbers') \
1605 > /dev/null
1606 ret=$?
1607 if [ $ret -ne 0 ]; then
1608 test_done $testroot $ret
1609 return 1
1612 (cd $testroot/wt && got patch $testroot/old.diff) \
1613 > $testroot/stdout 2>/dev/null
1614 ret=$?
1615 if [ $ret -eq 0 ]; then
1616 echo "got patch merged a diff that should conflict" >&2
1617 test_done $testroot 0
1618 return 1
1621 echo 'C alpha' > $testroot/stdout.expected
1622 echo 'C numbers' >> $testroot/stdout.expected
1623 cmp -s $testroot/stdout $testroot/stdout.expected
1624 ret=$?
1625 if [ $ret -ne 0 ]; then
1626 diff -u $testroot/stdout $testroot/stdout.expected
1627 test_done $testroot $ret
1628 return 1
1631 # XXX: prefixing every line with a tab otherwise got thinks
1632 # the file has conflicts in it.
1633 cat <<-EOF > $testroot/wt/alpha.expected
1634 <<<<<<< --- alpha
1635 ALPHA
1636 ||||||| commit $commit_id
1637 alpha
1638 =======
1642 >>>>>>> +++ alpha
1645 cat <<-EOF > $testroot/wt/numbers.expected
1651 <<<<<<< --- numbers
1653 ||||||| commit $commit_id
1655 =======
1657 >>>>>>> +++ numbers
1664 cmp -s $testroot/wt/alpha $testroot/wt/alpha.expected
1665 ret=$?
1666 if [ $ret -ne 0 ]; then
1667 diff -u $testroot/wt/alpha $testroot/wt/alpha.expected
1668 test_done $testroot $ret
1669 return 1
1672 cmp -s $testroot/wt/numbers $testroot/wt/numbers.expected
1673 ret=$?
1674 if [ $ret -ne 0 ]; then
1675 diff -u $testroot/wt/numbers $testroot/wt/numbers.expected
1677 test_done $testroot $ret
1680 test_patch_merge_unknown_blob() {
1681 local testroot=`test_init patch_merge_unknown_blob`
1683 got checkout $testroot/repo $testroot/wt > /dev/null
1684 ret=$?
1685 if [ $ret -ne 0 ]; then
1686 test_done $testroot $ret
1687 return 1
1690 cat <<EOF > $testroot/wt/patch
1691 I've got a
1692 diff aaaabbbbccccddddeeeeffff0000111122223333 foo/bar
1693 with a
1694 blob - aaaabbbbccccddddeeeeffff0000111122223333
1695 and also a
1696 blob + 0000111122223333444455556666777788889999
1697 for this dummy diff
1698 --- alpha
1699 +++ alpha
1700 @@ -1 +1 @@
1701 -alpha
1702 +ALPHA
1703 will it work?
1706 (cd $testroot/wt/ && got patch patch) > $testroot/stdout
1707 ret=$?
1708 if [ $ret -ne 0 ]; then
1709 test_done $testroot $ret
1710 return 1
1713 echo 'M alpha' > $testroot/stdout.expected
1714 cmp -s $testroot/stdout.expected $testroot/stdout
1715 ret=$?
1716 if [ $ret -ne 0 ]; then
1717 diff -u $testroot/stdout.expected $testroot/stdout
1718 test_done $testroot $ret
1719 return 1
1722 # try again without a `diff' header
1724 cat <<EOF > $testroot/wt/patch
1725 I've got a
1726 blob - aaaabbbbccccddddeeeeffff0000111122223333
1727 and also a
1728 blob + 0000111122223333444455556666777788889999
1729 for this dummy diff
1730 --- alpha
1731 +++ alpha
1732 @@ -1 +1 @@
1733 -alpha
1734 +ALPHA
1735 will it work?
1738 (cd $testroot/wt && got revert alpha > /dev/null && got patch patch) \
1739 > $testroot/stdout
1740 ret=$?
1741 if [ $ret -ne 0 ]; then
1742 test_done $testroot $ret
1743 return 1
1746 echo 'M alpha' > $testroot/stdout.expected
1747 cmp -s $testroot/stdout.expected $testroot/stdout
1748 ret=$?
1749 if [ $ret -ne 0 ]; then
1750 diff -u $testroot/stdout.expected $testroot/stdout
1751 test_done $testroot $ret
1752 return 1
1755 # try again with a git-style diff
1757 cat <<EOF > $testroot/wt/patch
1758 diff --git a/alpha b/alpha
1759 index 0123456789ab..abcdef012345 100644
1760 --- a/alpha
1761 +++ b/alpha
1762 @@ -1 +1 @@
1763 -alpha
1764 +ALPHA
1767 (cd $testroot/wt && got revert alpha > /dev/null && got patch patch) \
1768 > $testroot/stdout
1769 ret=$?
1770 if [ $ret -ne 0 ]; then
1771 test_done $testroot $ret
1772 return 1
1775 echo 'M alpha' > $testroot/stdout.expected
1776 cmp -s $testroot/stdout.expected $testroot/stdout
1777 ret=$?
1778 if [ $ret -ne 0 ]; then
1779 diff -u $testroot/stdout.expected $testroot/stdout
1781 test_done $testroot $ret
1784 test_parseargs "$@"
1785 run_test test_patch_add_file
1786 run_test test_patch_rm_file
1787 run_test test_patch_simple_edit_file
1788 run_test test_patch_prepend_line
1789 run_test test_patch_replace_line
1790 run_test test_patch_multiple_hunks
1791 run_test test_patch_multiple_files
1792 run_test test_patch_dont_apply
1793 run_test test_patch_malformed
1794 run_test test_patch_no_patch
1795 run_test test_patch_equals_for_context
1796 run_test test_patch_rename
1797 run_test test_patch_illegal_status
1798 run_test test_patch_nop
1799 run_test test_patch_preserve_perm
1800 run_test test_patch_create_dirs
1801 run_test test_patch_with_offset
1802 run_test test_patch_prefer_new_path
1803 run_test test_patch_no_newline
1804 run_test test_patch_strip
1805 run_test test_patch_relative_paths
1806 run_test test_patch_with_path_prefix
1807 run_test test_patch_relpath_with_path_prefix
1808 run_test test_patch_reverse
1809 run_test test_patch_merge_simple
1810 run_test test_patch_merge_gitdiff
1811 run_test test_patch_merge_conflict
1812 run_test test_patch_merge_unknown_blob