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.
20 local testroot
=`test_init patch_basic`
22 got checkout
$testroot/repo
$testroot/wt
> /dev
/null
24 if [ $ret -ne 0 ]; then
25 test_done
$testroot $ret
29 seq 100 > $testroot/wt
/numbers
30 (cd $testroot/wt
&& got add numbers
&& got commit
-m +numbers
) \
33 if [ $ret -ne 0 ]; then
34 test_done
"$testroot" $ret
38 cat <<EOF > $testroot/wt/patch
43 +alpha is my favourite character
90 (cd $testroot/wt
&& got
patch < patch) > $testroot/stdout
91 if [ $ret -ne 0 ]; then
92 test_done
"$testroot" $ret
96 echo 'M alpha' > $testroot/stdout.expected
97 echo 'D beta' >> $testroot/stdout.expected
98 echo 'M gamma/delta' >> $testroot/stdout.expected
99 echo 'A eta' >> $testroot/stdout.expected
100 echo 'M numbers' >> $testroot/stdout.expected
102 cmp -s $testroot/stdout.expected
$testroot/stdout
104 if [ $ret -ne 0 ]; then
105 diff -u $testroot/stdout.expected
$testroot/stdout
106 test_done
$testroot $ret
110 echo 'alpha is my favourite character' > $testroot/wt
/alpha.expected
111 cmp -s $testroot/wt
/alpha.expected
$testroot/wt
/alpha
113 if [ $ret -ne 0 ]; then
114 diff -u $testroot/wt
/alpha.expected
$testroot/wt
/alpha
115 test_done
"$testroot" $ret
119 if [ -f "$testroot/wt/beta" ]; then
120 echo "beta was not deleted!" >&2
121 test_done
"$testroot" 1
125 echo 'this is:' > $testroot/wt
/gamma
/delta.expected
126 echo 'delta' >> $testroot/wt
/gamma
/delta.expected
127 cmp -s $testroot/wt
/gamma
/delta.expected
$testroot/wt
/gamma
/delta
129 if [ $ret -ne 0 ]; then
130 diff -u $testroot/wt
/gamma
/delta.expected
$testroot/wt
/gamma
/delta
131 test_done
"$testroot" $ret
135 seq 5 > $testroot/wt
/eta.expected
136 cmp -s $testroot/wt
/eta.expected
$testroot/wt
/eta
138 if [ $ret -ne 0 ]; then
139 diff -u $testroot/wt
/eta.expected
$testroot/wt
/eta
140 test_done
"$testroot" $ret
144 seq 103 |
sed -e 's/^6$/six/' -e 's/60/sixty/' \
145 > $testroot/wt
/numbers.expected
146 cmp -s $testroot/wt
/numbers.expected
$testroot/wt
/numbers
148 if [ $ret -ne 0 ]; then
149 diff -u $testroot/wt
/numbers.expected
$testroot/wt
/numbers
151 test_done
$testroot $ret
154 test_patch_dont_apply
() {
155 local testroot
=`test_init patch_dont_apply`
157 got checkout
$testroot/repo
$testroot/wt
> /dev
/null
159 if [ $ret -ne 0 ]; then
160 test_done
$testroot $ret
164 seq 100 > $testroot/wt
/numbers
165 (cd $testroot/wt
&& got add numbers
&& got commit
-m 'add numbers') \
168 if [ $ret -ne 0 ]; then
169 test_done
$testroot $ret
173 cat <<EOF > $testroot/wt/patch
193 (cd $testroot/wt
&& got
patch patch) > $testroot/stdout
2> /dev
/null
195 if [ $ret -eq 0 ]; then # should fail
196 test_done
$testroot 1
200 cat <<EOF > $testroot/stdout.expected
202 @@ -1,1 +1,2 @@ hunk failed to apply
204 @@ -1,9 +0,0 @@ hunk failed to apply
205 Files where patch failed to apply: 2
208 cmp -s $testroot/stdout.expected
$testroot/stdout
210 if [ $ret -ne 0 ]; then
211 diff -u $testroot/stdout.expected
$testroot/stdout
213 test_done
$testroot $ret
216 test_patch_malformed
() {
217 local testroot
=`test_init patch_malformed`
219 got checkout
$testroot/repo
$testroot/wt
> /dev
/null
221 if [ $ret -ne 0 ]; then
222 test_done
$testroot $ret
227 cat <<EOF > $testroot/wt/patch
235 echo -n > $testroot/stdout.expected
236 echo "got-read-patch: @@ -1 +1,2: malformed patch" \
237 > $testroot/stderr.expected
238 echo "got: malformed patch" >> $testroot/stderr.expected
240 (cd $testroot/wt
&& got
patch patch) \
244 if [ $ret -eq 0 ]; then
245 echo "got managed to apply an invalid patch"
246 test_done
$testroot 1
250 cmp -s $testroot/stdout.expected
$testroot/stdout
252 if [ $ret -ne 0 ]; then
253 diff -u $testroot/stdout.expected
$testroot/stdout
254 test_done
$testroot $ret
258 echo -n > $testroot/stdout.expected
259 echo "got-read-patch: @@ -1 +1,2: malformed patch" \
260 > $testroot/stderr.expected
261 echo "got: malformed patch" >> $testroot/stderr.expected
262 cmp -s $testroot/stderr.expected
$testroot/stderr
264 if [ $ret -ne 0 ]; then
265 diff -u $testroot/stderr.expected
$testroot/stderr
266 test_done
$testroot $ret
270 # wrong first character
271 cat <<EOF > $testroot/wt/patch
279 (cd $testroot/wt
&& got
patch patch) \
283 if [ $ret -eq 0 ]; then
284 echo "got managed to apply an invalid patch"
285 test_done
$testroot 1
289 cmp -s $testroot/stdout.expected
$testroot/stdout
291 if [ $ret -ne 0 ]; then
292 diff -u $testroot/stdout.expected
$testroot/stdout
293 test_done
$testroot $ret
297 echo "got-read-patch: alpha: malformed patch" \
298 > $testroot/stderr.expected
299 echo "got: malformed patch" >> $testroot/stderr.expected
301 cmp -s $testroot/stderr.expected
$testroot/stderr
303 if [ $ret -ne 0 ]; then
304 diff -u $testroot/stderr.expected
$testroot/stderr
305 test_done
$testroot $ret
310 cat <<EOF > $testroot/wt/patch
311 diff --git a/alpha b/iota
317 (cd $testroot/wt
&& got
patch patch) \
321 if [ $ret -eq 0 ]; then
322 echo "got managed to apply an invalid patch"
323 test_done
$testroot 1
327 cmp -s $testroot/stdout.expected
$testroot/stdout
329 if [ $ret -ne 0 ]; then
330 diff -u $testroot/stdout.expected
$testroot/stdout
331 test_done
$testroot $ret
335 echo "got-read-patch: @@ -0,0 +0,0 @@: malformed patch" \
336 > $testroot/stderr.expected
337 echo "got: malformed patch" >> $testroot/stderr.expected
339 cmp -s $testroot/stderr.expected
$testroot/stderr
341 if [ $ret -ne 0 ]; then
342 diff -u $testroot/stderr.expected
$testroot/stderr
343 test_done
$testroot $ret
347 test_done
$testroot $ret
350 test_patch_no_patch
() {
351 local testroot
=`test_init patch_no_patch`
353 got checkout
$testroot/repo
$testroot/wt
> /dev
/null
355 if [ $ret -ne 0 ]; then
356 test_done
$testroot $ret
360 cat <<EOF > $testroot/wt/patch
367 there's no patch in here!
370 echo -n > $testroot/stdout.expected
371 echo "got-read-patch: no patch found" > $testroot/stderr.expected
372 echo "got: no patch found" >> $testroot/stderr.expected
374 (cd $testroot/wt
&& got
patch patch) \
378 if [ $ret -eq 0 ]; then # should fail
379 test_done
$testroot 1
383 cmp -s $testroot/stdout.expected
$testroot/stdout
385 if [ $ret -ne 0 ]; then
386 diff -u $testroot/stdout.expected
$testroot/stdout
387 test_done
$testroot $ret
391 cmp -s $testroot/stderr.expected
$testroot/stderr
393 if [ $ret -ne 0 ]; then
394 diff -u $testroot/stderr.expected
$testroot/stderr
395 test_done
$testroot $ret
399 test_done
$testroot $ret
402 test_patch_equals_for_context
() {
403 local testroot
=`test_init patch_equals_for_context`
405 got checkout
$testroot/repo
$testroot/wt
> /dev
/null
407 if [ $ret -ne 0 ]; then
408 test_done
$testroot $ret
412 cat <<EOF > $testroot/wt/patch
420 echo "M alpha" > $testroot/stdout.expected
422 (cd $testroot/wt
&& got
patch patch) > $testroot/stdout
424 if [ $ret -ne 0 ]; then
425 test_done
$testroot $ret
429 cmp -s $testroot/stdout.expected
$testroot/stdout
431 if [ $ret -ne 0 ]; then
432 diff -u $testroot/stdout.expected
$testroot/stdout
433 test_done
$testroot $ret
437 echo hatsuseno
> $testroot/wt
/alpha.expected
438 echo alpha
>> $testroot/wt
/alpha.expected
439 cmp -s $testroot/wt
/alpha.expected
$testroot/wt
/alpha
441 if [ $ret -ne 0 ]; then
442 diff -u $testroot/wt
/alpha.expected
$testroot/wt
/alpha
444 test_done
$testroot $ret
447 test_patch_rename
() {
448 local testroot
=`test_init patch_rename`
450 got checkout
$testroot/repo
$testroot/wt
> /dev
/null
452 if [ $ret -ne 0 ]; then
453 test_done
$testroot $ret
457 cat <<EOF > $testroot/wt/patch
458 diff --git a/beta b/iota
459 similarity index 100%
462 diff --git a/alpha b/eta
470 echo 'D beta' > $testroot/stdout.expected
471 echo 'A iota' >> $testroot/stdout.expected
472 echo 'D alpha' >> $testroot/stdout.expected
473 echo 'A eta' >> $testroot/stdout.expected
475 (cd $testroot/wt
&& got
patch patch) > $testroot/stdout
477 if [ $ret -ne 0 ]; then
478 test_done
$testroot $ret
482 cmp -s $testroot/stdout.expected
$testroot/stdout
484 if [ $ret -ne 0 ]; then
485 diff -u $testroot/stdout.expected
$testroot/stdout
486 test_done
$testroot $ret
490 if [ -f $testroot/wt
/alpha
-o -f $testroot/wt
/beta
]; then
491 echo "alpha or beta were not removed" >&2
492 test_done
$testroot 1
495 if [ ! -f $testroot/wt
/iota
-o ! -f $testroot/wt
/eta
]; then
496 echo "iota or eta were not created" >&2
497 test_done
$testroot 1
501 echo beta
> $testroot/wt
/iota.expected
502 cmp -s $testroot/wt
/iota.expected
$testroot/wt
/iota
504 if [ $ret -ne 0 ]; then
505 diff -u $testroot/wt
/iota.expected
$testroot/wt
/iota
506 test_done
$testroot $ret
510 echo eta
> $testroot/wt
/eta.expected
511 cmp -s $testroot/wt
/eta.expected
$testroot/wt
/eta
513 if [ $ret -ne 0 ]; then
514 diff -u $testroot/wt
/eta.expected
$testroot/wt
/eta
515 test_done
$testroot $ret
519 test_done
$testroot $ret
522 test_patch_illegal_status
() {
523 local testroot
=`test_init patch_illegal_status`
525 got checkout
$testroot/repo
$testroot/wt
> /dev
/null
527 if [ $ret -ne 0 ]; then
528 test_done
$testroot $ret
532 # try to patch an obstructed file, add a versioned one, edit a
533 # non existent file and an unversioned one, and remove a
535 cat <<EOF > $testroot/wt/patch
561 echo kappa
> $testroot/wt
/kappa
562 rm $testroot/wt
/alpha
563 mkdir
$testroot/wt
/alpha
565 (cd $testroot/wt
&& got
patch patch) > $testroot/stdout \
568 if [ $ret -eq 0 ]; then
569 echo "edited a missing file" >&2
570 test_done
$testroot 1
574 cat <<EOF > $testroot/stdout.expected
580 Files where patch failed to apply: 5
583 cat <<EOF > $testroot/stderr.expected
584 got: alpha: file has unexpected status
585 got: beta: file has unexpected status
586 got: iota: No such file or directory
587 got: kappa: file has unexpected status
588 got: lambda: No such file or directory
589 got: patch failed to apply
592 cmp -s $testroot/stdout.expected
$testroot/stdout
594 if [ $ret -ne 0 ]; then
595 diff -u $testroot/stdout.expected
$testroot/stdout
596 test_done
$testroot $ret
600 cmp -s $testroot/stderr.expected
$testroot/stderr
602 if [ $ret -ne 0 ]; then
603 diff -u $testroot/stderr.expected
$testroot/stderr
604 test_done
$testroot $ret
608 (cd $testroot/wt
&& got status
) > $testroot/stdout
609 cat <<EOF > $testroot/stdout.expected
615 cmp -s $testroot/stdout.expected
$testroot/stdout
617 if [ $ret -ne 0 ]; then
618 diff -u $testroot/stdout.expected
$testroot/stdout
620 test_done
$testroot $ret
624 local testroot
=`test_init patch_nop`
626 got checkout
$testroot/repo
$testroot/wt
> /dev
/null
628 if [ $ret -ne 0 ]; then
629 test_done
$testroot $ret
633 cat <<EOF > $testroot/wt/patch
643 diff --git a/gamma/delta b/gamma/delta.new
648 +delta updated and renamed!
651 (cd $testroot/wt
&& got
patch -n patch)
653 if [ $ret -ne 0 ]; then
654 test_done
$testroot $ret
658 # remove the patch to avoid the ? entry
659 rm $testroot/wt
/patch
661 (cd $testroot/wt
&& got status
) > $testroot/stdout
663 if [ $ret -ne 0 ]; then
664 test_done
$testroot $ret
668 echo -n > $testroot/stdout.expected
669 cmp -s $testroot/stdout.expected
$testroot/stdout
671 if [ $ret -ne 0 ]; then
672 diff -u $testroot/stdout.expected
$testroot/stdout
674 test_done
$testroot $ret
677 test_patch_preserve_perm
() {
678 local testroot
=`test_init patch_preserve_perm`
680 got checkout
$testroot/repo
$testroot/wt
> /dev
/null
682 if [ $ret -ne 0 ]; then
683 test_done
$testroot $ret
687 chmod +x
$testroot/wt
/alpha
688 (cd $testroot/wt
&& got commit
-m 'alpha executable') > /dev
/null
690 if [ $ret -ne 0 ]; then
691 test_done
$testroot $ret
695 cat <<EOF > $testroot/wt/patch
703 (cd $testroot/wt
&& got
patch patch) > /dev
/null
705 if [ $ret -ne 0 ]; then
706 test_done
$testroot $ret
710 if [ ! -x $testroot/wt
/alpha
]; then
711 echo "alpha is no more executable!" >&2
712 test_done
$testroot 1
715 test_done
$testroot 0
718 test_patch_create_dirs
() {
719 local testroot
=`test_init patch_create_dirs`
721 got checkout
$testroot/repo
$testroot/wt
> /dev
/null
723 if [ $ret -ne 0 ]; then
724 test_done
$testroot $ret
728 cat <<EOF > $testroot/wt/patch
730 +++ iota/kappa/lambda
735 (cd $testroot/wt
&& got
patch patch) > $testroot/stdout
737 if [ $ret -ne 0 ]; then
738 test_done
$testroot $ret
742 echo 'A iota/kappa/lambda' >> $testroot/stdout.expected
743 cmp -s $testroot/stdout.expected
$testroot/stdout
745 if [ $ret -ne 0 ]; then
746 diff -u $testroot/stdout.expected
$testroot/stdout
747 test_done
$testroot $ret
751 if [ ! -f $testroot/wt
/iota
/kappa
/lambda
]; then
752 echo "file not created!" >&2
753 test_done
$testroot $ret
756 test_done
$testroot 0
759 test_patch_with_offset
() {
760 local testroot
=`test_init patch_with_offset`
762 got checkout
$testroot/repo
$testroot/wt
> /dev
/null
764 if [ $ret -ne 0 ]; then
765 test_done
$testroot $ret
769 cat <<EOF > $testroot/wt/patch
792 seq 100 > $testroot/wt
/numbers
793 ed
-s "$testroot/wt/numbers" <<EOF
800 (cd $testroot/wt
&& got add numbers
&& got commit
-m '+numbers') \
803 if [ $ret -ne 0 ]; then
804 test_done
$testroot $ret
808 (cd $testroot/wt
&& got
patch patch) > $testroot/stdout
810 if [ $ret -ne 0 ]; then
811 test_done
$testroot/wt
$ret
815 cat <<EOF > $testroot/stdout.expected
817 @@ -47,7 +47,7 @@ applied with offset -10
818 @@ -87,7 +87,7 @@ applied with offset 10
821 cmp -s $testroot/stdout.expected
$testroot/stdout
823 if [ $ret -ne 0 ]; then
824 diff -u $testroot/stdout.expected
$testroot/stdout
826 test_done
$testroot $ret
829 test_patch_empty_file
() {
830 local testroot
=`test_init patch_empty_file`
832 got checkout
$testroot/repo
$testroot/wt
> /dev
/null
834 if [ $ret -ne 0 ]; then
835 test_done
$testroot $ret
839 echo -n > $testroot/wt
/alpha
840 (cd "$testroot/wt" && got commit
-m 'edit alpha' alpha
) >/dev
/null
842 # try a patch which re-adds file contents; should suceeed
843 cat <<EOF >$testroot/wt/patch
849 (cd $testroot/wt
&& got
patch patch) > $testroot/stdout
851 if [ $ret -ne 0 ]; then
852 test_done
$testroot $ret
855 echo 'M alpha' > $testroot/stdout.expected
856 cmp -s $testroot/stdout.expected
$testroot/stdout
858 if [ $ret -ne 0 ]; then
859 diff -u $testroot/stdout.expected
$testroot/stdout
860 test_done
$testroot $ret
864 (cd $testroot/wt
&& got revert
-R .
> /dev
/null
)
866 # try a patch which edits the file; should fail
867 cat <<EOF >$testroot/wt/patch
874 (cd $testroot/wt
&& got
patch patch) > $testroot/stdout \
877 if [ $ret -eq 0 ]; then
878 echo "got patch succeeded unexpectedly" >&2
879 test_done
$testroot $ret
883 echo 'got: patch failed to apply' > $testroot/stderr.expected
884 cmp -s $testroot/stderr.expected
$testroot/stderr
886 if [ $ret -ne 0 ]; then
887 diff -u $testroot/stderr.expected
$testroot/stderr
888 test_done
$testroot $ret
892 (cd $testroot/wt
&& got revert
-R .
> /dev
/null
)
894 # try a patch which deletes lines from the file; should fail
895 cat <<EOF >$testroot/wt/patch
902 (cd $testroot/wt
&& got
patch patch) > $testroot/stdout \
905 if [ $ret -eq 0 ]; then
906 echo "got patch succeeded unexpectedly" >&2
907 test_done
$testroot $ret
910 echo 'got: patch failed to apply' > $testroot/stderr.expected
911 cmp -s $testroot/stderr.expected
$testroot/stderr
913 if [ $ret -ne 0 ]; then
914 diff -u $testroot/stderr.expected
$testroot/stderr
916 test_done
$testroot $ret
919 test_patch_prefer_new_path
() {
920 local testroot
=`test_init patch_orig`
922 got checkout
$testroot/repo
$testroot/wt
> /dev
/null
924 if [ $ret -ne 0 ]; then
925 test_done
$testroot $ret
929 cat <<EOF > $testroot/wt/patch
937 (cd $testroot/wt
&& got
patch patch) > $testroot/stdout
939 if [ $ret -ne 0 ]; then
940 test_done
$testroot $ret
944 echo 'M alpha' > $testroot/stdout.expected
945 cmp -s $testroot/stdout.expected
$testroot/stdout
947 if [ $ret -ne 0 ]; then
948 diff -u $testroot/stdout.expected
$testroot/stdout
950 test_done
$testroot $ret
953 test_patch_no_newline
() {
954 local testroot
=`test_init patch_no_newline`
956 got checkout
$testroot/repo
$testroot/wt
> /dev
/null
958 if [ $ret -ne 0 ]; then
959 test_done
$testroot $ret
963 cat <<EOF > $testroot/wt/patch
968 \ No newline at end of file
971 (cd $testroot/wt
&& got
patch patch) > $testroot/stdout
973 if [ $ret -ne 0 ]; then
974 test_done
$testroot $ret
978 echo "A eta" > $testroot/stdout.expected
979 cmp -s $testroot/stdout.expected
$testroot/stdout
981 if [ $ret -ne 0 ]; then
982 diff -u $testroot/stdout.expected
$testroot/stdout
983 test_done
$testroot $ret
987 echo -n eta
> $testroot/wt
/eta.expected
988 cmp -s $testroot/wt
/eta.expected
$testroot/wt
/eta
990 if [ $ret -ne 0 ]; then
991 diff -u $testroot/wt
/eta.expected
$testroot/wt
/eta
992 test_done
$testroot $ret
996 (cd $testroot/wt
&& got commit
-m 'add eta') > /dev
/null
998 if [ $ret -ne 0 ]; then
999 test_done
$testroot $ret
1003 cat <<EOF > $testroot/wt/patch
1008 \ No newline at end of file
1010 \ No newline at end of file
1013 (cd $testroot/wt
&& got
patch patch) > $testroot/stdout
1015 if [ $ret -ne 0 ]; then
1016 test_done
$testroot $ret
1020 echo "M eta" > $testroot/stdout.expected
1021 cmp -s $testroot/stdout.expected
$testroot/stdout
1023 if [ $ret -ne 0 ]; then
1024 diff -u $testroot/stdout.expected
$testroot/stdout
1025 test_done
$testroot $ret
1029 echo -n ETA
> $testroot/wt
/eta.expected
1030 cmp -s $testroot/wt
/eta.expected
$testroot/wt
/eta
1032 if [ $ret -ne 0 ]; then
1033 diff -u $testroot/wt
/eta.expected
$testroot/wt
/eta
1034 test_done
$testroot $ret
1038 (cd $testroot/wt
&& got commit
-m 'edit eta') > /dev
/null
1040 if [ $ret -ne 0 ]; then
1041 test_done
$testroot $ret
1045 cat <<EOF > $testroot/wt/patch
1050 \ No newline at end of file
1054 (cd $testroot/wt
&& got
patch patch) > $testroot/stdout
1056 if [ $ret -ne 0 ]; then
1057 test_done
$testroot $ret
1061 echo "M eta" > $testroot/stdout.expected
1062 cmp -s $testroot/stdout.expected
$testroot/stdout
1064 if [ $ret -ne 0 ]; then
1065 diff -u $testroot/stdout.expected
$testroot/stdout
1066 test_done
$testroot $ret
1070 echo eta
> $testroot/wt
/eta.expected
1071 cmp -s $testroot/wt
/eta.expected
$testroot/wt
/eta
1073 if [ $ret -ne 0 ]; then
1074 diff -u $testroot/wt
/eta.expected
$testroot/wt
/eta
1076 test_done
$testroot $ret
1079 test_patch_strip
() {
1080 local testroot
=`test_init patch_strip`
1082 got checkout
$testroot/repo
$testroot/wt
> /dev
/null
1084 if [ $ret -ne 0 ]; then
1085 test_done
$testroot $ret
1089 cat <<EOF > $testroot/wt/patch
1090 --- foo/bar/alpha.orig
1097 (cd $testroot/wt
&& got
patch -p2 patch) > $testroot/stdout
1099 if [ $ret -ne 0 ]; then
1100 test_done
$testroot $ret
1104 echo "M alpha" >> $testroot/stdout.expected
1105 cmp -s $testroot/stdout.expected
$testroot/stdout
1107 if [ $ret -ne 0 ]; then
1108 diff -u $testroot/stdout.expected
$testroot/stdout
1109 test_done
$testroot $ret
1113 (cd $testroot/wt
&& got revert alpha
) > /dev
/null
2>&1
1115 if [ $ret -ne 0 ]; then
1116 test_done
$testroot $ret
1120 (cd $testroot/wt
&& got
patch -p3 patch) \
1123 if [ $ret -eq 0 ]; then
1124 echo "stripped more components than available!"
1125 test_done
$testroot 1
1129 cat <<EOF > $testroot/stderr.expected
1130 got: can't strip 1 path-components from foo/bar/alpha: bad path
1133 cmp -s $testroot/stderr.expected
$testroot/stderr
1135 if [ $ret -ne 0 ]; then
1136 diff -u $testroot/stderr.expected
$testroot/stderr
1138 test_done
$testroot 0
1141 test_patch_whitespace
() {
1142 local testroot
=`test_init patch_whitespace`
1144 got checkout
$testroot/repo
$testroot/wt
> /dev
/null
1146 if [ $ret -ne 0 ]; then
1147 test_done
$testroot $ret
1153 cat <<EOF > $testroot/wt/hello.c
1159 /* the trailing whitespace is on purpose */
1160 printf("hello, world\n");$trailing
1165 (cd $testroot/wt
&& got add hello.c
&& got ci
-m '+hello.c') \
1168 if [ $ret -ne 0 ]; then
1169 test_done
$testroot $ret
1173 # test with a diff with various whitespace corruptions
1174 cat <<EOF > $testroot/wt/patch
1179 /* the trailing whitespace is on purpose */
1180 printf("hello, world\n");
1182 + return 5; /* always fails */
1186 (cd $testroot/wt
&& got
patch patch) \
1187 2>$testroot/stderr
>$testroot/stdout
1189 if [ $ret -ne 0 ]; then
1190 echo "failed to apply diff" >&2
1191 test_done
$testroot $ret
1195 echo 'M hello.c' > $testroot/stdout.expected
1196 echo '@@ -5,5 +5,5 @@ hunk contains mangled whitespace' \
1197 >> $testroot/stdout.expected
1198 cmp -s $testroot/stdout.expected
$testroot/stdout
1200 if [ $ret -ne 0 ]; then
1201 diff -u $testroot/stdout.expected
$testroot/stdout
1202 test_done
$testroot $ret
1206 cat <<EOF > $testroot/wt/hello.c.expected
1212 /* the trailing whitespace is on purpose */
1213 printf("hello, world\n");$trailing
1214 return 5; /* always fails */
1218 cmp -s $testroot/wt
/hello.c.expected
$testroot/wt
/hello.c
1220 if [ $ret -ne 0 ]; then
1221 diff -u $testroot/wt
/hello.c.expected
$testroot/wt
/hello.c
1223 test_done
$testroot $ret
1226 test_patch_relative_paths
() {
1227 local testroot
=`test_init patch_relative_paths`
1229 got checkout
$testroot/repo
$testroot/wt
> /dev
/null
1231 if [ $ret -ne 0 ]; then
1232 test_done
$testroot $ret
1236 cat <<EOF > $testroot/wt/gamma/patch
1248 (cd $testroot/wt
/gamma
&& got
patch patch) > $testroot/stdout
1250 if [ $ret -ne 0 ]; then
1251 test_done
$testroot $ret
1255 echo 'M gamma/delta' > $testroot/stdout.expected
1256 echo 'A gamma/eta' >> $testroot/stdout.expected
1258 cmp -s $testroot/stdout.expected
$testroot/stdout
1260 if [ $ret -ne 0 ]; then
1261 diff -u $testroot/stdout.expected
$testroot/stdout
1263 test_done
$testroot $ret
1266 test_patch_with_path_prefix
() {
1267 local testroot
=`test_init patch_with_path_prefix`
1269 got checkout
-p gamma
$testroot/repo
$testroot/wt
> /dev
/null
1271 if [ $ret -ne 0 ]; then
1272 test_done
$testroot $ret
1276 cat <<EOF > $testroot/wt/patch
1288 (cd $testroot/wt
&& got
patch patch) > $testroot/stdout
1290 if [ $ret -ne 0 ]; then
1291 test_done
$testroot $ret
1295 echo 'M delta' > $testroot/stdout.expected
1296 echo 'A eta' >> $testroot/stdout.expected
1298 cmp -s $testroot/stdout.expected
$testroot/stdout
1300 if [ $ret -ne 0 ]; then
1301 diff -u $testroot/stdout.expected
$testroot/stdout
1303 test_done
$testroot $ret
1306 test_patch_relpath_with_path_prefix
() {
1307 local testroot
=`test_init patch_relpaths_with_path_prefix`
1309 got checkout
-p gamma
$testroot/repo
$testroot/wt
> /dev
/null
1311 if [ $ret -ne 0 ]; then
1312 test_done
$testroot $ret
1316 mkdir
-p $testroot/wt
/epsilon
/zeta
/
1318 cat <<EOF > $testroot/wt/patch
1325 (cd $testroot/wt
/epsilon
/zeta
&& got
patch -p1 $testroot/wt
/patch) \
1328 if [ $ret -ne 0 ]; then
1329 test_done
$testroot $ret
1333 echo 'A epsilon/zeta/theta' >> $testroot/stdout.expected
1335 cmp -s $testroot/stdout.expected
$testroot/stdout
1337 if [ $ret -ne 0 ]; then
1338 diff -u $testroot/stdout.expected
$testroot/stdout
1339 test_done
$testroot $ret
1343 echo 'theta' > $testroot/theta.expected
1344 cmp -s $testroot/wt
/epsilon
/zeta
/theta
$testroot/theta.expected
1346 if [ $ret -ne 0 ]; then
1347 diff -u $testroot/wt
/epsilon
/zeta
/theta
$testroot/theta.expected
1349 test_done
$testroot $ret
1352 test_patch_reverse
() {
1353 local testroot
=`test_init patch_reverse`
1355 got checkout
$testroot/repo
$testroot/wt
> /dev
/null
1357 if [ $ret -ne 0 ]; then
1358 test_done
$testroot $ret
1362 cat <<EOF > $testroot/wt/patch
1367 \ No newline at end of file
1371 (cd $testroot/wt
&& got
patch -R patch) > $testroot/stdout
1373 if [ $ret -ne 0 ]; then
1374 test_done
$testroot $ret
1378 echo "M alpha" > $testroot/stdout.expected
1379 cmp -s $testroot/stdout.expected
$testroot/stdout
1381 if [ $ret -ne 0 ]; then
1382 diff -u $testroot/stdout.expected
$testroot/stdout
1383 test_done
$testroot $ret
1387 echo -n ALPHA
> $testroot/wt
/alpha.expected
1388 cmp -s $testroot/wt
/alpha.expected
$testroot/wt
/alpha
1390 if [ $ret -ne 0 ]; then
1391 diff -u $testroot/wt
/alpha.expected
$testroot/wt
/alpha
1393 test_done
$testroot $ret
1396 test_patch_merge_simple
() {
1397 local testroot
=`test_init patch_merge_simple`
1399 got checkout
$testroot/repo
$testroot/wt
> /dev
/null
1401 if [ $ret -ne 0 ]; then
1402 test_done
$testroot $ret
1406 seq 10 > $testroot/wt
/numbers
1407 chmod +x
$testroot/wt
/numbers
1408 (cd $testroot/wt
&& got add numbers
&& got commit
-m +numbers
) \
1411 if [ $ret -ne 0 ]; then
1412 test_done
$testroot $ret
1416 seq 10 |
sed 's/4/four/g' > $testroot/wt
/numbers
1418 (cd $testroot/wt
&& got
diff > $testroot/old.
diff \
1419 && got revert numbers
) >/dev
/null
1421 if [ $ret -ne 0 ]; then
1422 test_done
$testroot $ret
1426 seq 10 |
sed 's/6/six/g' > $testroot/wt
/numbers
1427 (cd $testroot/wt
&& got commit
-m 'edit numbers') \
1430 if [ $ret -ne 0 ]; then
1431 test_done
$testroot $ret
1435 (cd $testroot/wt
&& got
patch $testroot/old.
diff) \
1438 if [ $ret -ne 0 ]; then
1439 test_done
$testroot $ret
1443 echo 'G numbers' > $testroot/stdout.expected
1444 cmp -s $testroot/stdout
$testroot/stdout.expected
1446 if [ $ret -ne 0 ]; then
1447 diff -u $testroot/stdout
$testroot/stdout.expected
1448 test_done
$testroot $ret
1452 seq 10 |
sed -e s
/4/four
/ -e s
/6/six
/ > $testroot/wt
/numbers.expected
1453 cmp -s $testroot/wt
/numbers
$testroot/wt
/numbers.expected
1455 if [ $ret -ne 0 ]; then
1456 diff -u $testroot/wt
/numbers
$testroot/wt
/numbers.expected
1457 test_done
$testroot $ret
1461 test -x $testroot/wt
/numbers
1463 if [ $ret -ne 0 ]; then
1464 echo "numbers lost the executable bit" >&2
1466 test_done
$testroot $ret
1469 test_patch_merge_gitdiff
() {
1470 local testroot
=`test_init patch_merge_gitdiff`
1472 seq 10 > $testroot/repo
/numbers
1473 git
-C $testroot/repo add numbers
&& \
1474 git_commit
$testroot/repo
-m "nums"
1476 if [ $ret -ne 0 ]; then
1477 test_done
$testroot $ret
1481 seq 10 |
sed 's/4/four/g' > $testroot/repo
/numbers
1482 git
-C $testroot/repo
diff > $testroot/old.
diff
1484 if [ $ret -ne 0 ]; then
1485 test_done
$testroot $ret
1490 seq 10 > $testroot/repo
/numbers
1492 seq 10 |
sed 's/6/six/g' > $testroot/repo
/numbers
1493 git
-C $testroot/repo add numbers
&& \
1494 git_commit
$testroot/repo
-m "edit"
1496 if [ $ret -ne 0 ]; then
1497 test_done
$testroot $ret
1501 # now work with got:
1502 got checkout
$testroot/repo
$testroot/wt
> /dev
/null
1504 if [ $ret -ne 0 ]; then
1505 test_done
$testroot $ret
1509 (cd $testroot/wt
&& got
patch $testroot/old.
diff) > $testroot/stdout
1511 if [ $ret -ne 0 ]; then
1512 test_done
$testroot $ret
1516 echo 'G numbers' > $testroot/stdout.expected
1517 cmp -s $testroot/stdout
$testroot/stdout.expected
1519 if [ $ret -ne 0 ]; then
1520 diff -u $testroot/stdout
$testroot/stdout.expected
1522 test_done
$testroot $ret
1525 test_patch_merge_base_provided
() {
1526 local testroot
=`test_init patch_merge_base_provided`
1528 got checkout
$testroot/repo
$testroot/wt
>/dev
/null
1530 if [ $ret -ne 0 ]; then
1531 test_done
$testroot $ret
1535 seq 10 > $testroot/wt
/numbers
1536 (cd $testroot/wt
&& got add numbers
&& got commit
-m +numbers
) \
1539 if [ $ret -ne 0 ]; then
1540 test_done
$testroot $ret
1544 local commit_id
=`git_show_head $testroot/repo`
1546 seq 10 |
sed s
/4/four
/ > $testroot/wt
/numbers
1548 # get rid of the metadata
1549 (cd $testroot/wt
&& got
diff |
sed -n '/^---/,$p' > patch) \
1552 seq 10 |
sed s
/6/six
/ > $testroot/wt
/numbers
1553 (cd $testroot/wt
&& got commit
-m 'edit numbers') >/dev
/null
1555 if [ $ret -ne 0 ]; then
1556 test_done
$testroot $ret
1560 (cd $testroot/wt
&& got
patch -c $commit_id patch) >$testroot/stdout
1562 if [ $ret -ne 0 ]; then
1563 test_done
$testroot $ret
1567 echo 'G numbers' > $testroot/stdout.expected
1568 cmp -s $testroot/stdout
$testroot/stdout.expected
1570 if [ $ret -ne 0 ]; then
1571 diff -u $testroot/stdout
$testroot/stdout.expected
1572 test_done
$testroot $ret
1576 seq 10 |
sed -e s
/4/four
/ -e s
/6/six
/ > $testroot/wt
/numbers.expected
1577 cmp -s $testroot/wt
/numbers
$testroot/wt
/numbers.expected
1579 if [ $ret -ne 0 ]; then
1580 diff -u $testroot/wt
/numbers
$testroot/wt
/numbers.expected
1582 test_done
$testroot $ret
1585 test_patch_merge_conflict
() {
1586 local testroot
=`test_init patch_merge_conflict`
1588 got checkout
$testroot/repo
$testroot/wt
> /dev
/null
1590 if [ $ret -ne 0 ]; then
1591 test_done
$testroot $ret
1595 local alpha_basecommit_id
=`git_show_head $testroot/repo`
1597 seq 10 > $testroot/wt
/numbers
1598 (cd $testroot/wt
&& got add numbers
&& got commit
-m +numbers
) \
1601 if [ $ret -ne 0 ]; then
1602 test_done
$testroot $ret
1606 local commit_id
=`git_show_head $testroot/repo`
1608 seq 10 |
sed 's/6/six/g' > $testroot/wt
/numbers
1609 echo ALPHA
> $testroot/wt
/alpha
1611 (cd $testroot/wt
&& got
diff > $testroot/old.
diff \
1612 && got revert alpha numbers
) >/dev
/null
1614 if [ $ret -ne 0 ]; then
1615 test_done
$testroot $ret
1619 seq 10 |
sed 's/6/3+3/g' > $testroot/wt
/numbers
1620 printf '%s\n' a b c
> $testroot/wt
/alpha
1621 (cd $testroot/wt
&& got commit
-m 'edit alpha and numbers') \
1624 if [ $ret -ne 0 ]; then
1625 test_done
$testroot $ret
1629 (cd $testroot/wt
&& got
patch $testroot/old.
diff) \
1630 > $testroot/stdout
2>/dev
/null
1632 if [ $ret -eq 0 ]; then
1633 echo "got patch merged a diff that should conflict" >&2
1634 test_done
$testroot 1
1638 echo 'C alpha' > $testroot/stdout.expected
1639 echo 'C numbers' >> $testroot/stdout.expected
1640 echo 'Files with merge conflicts: 2' >> $testroot/stdout.expected
1641 cmp -s $testroot/stdout
$testroot/stdout.expected
1643 if [ $ret -ne 0 ]; then
1644 diff -u $testroot/stdout
$testroot/stdout.expected
1645 test_done
$testroot $ret
1649 # XXX: prefixing every line with a tab otherwise got thinks
1650 # the file has conflicts in it.
1651 cat <<-EOF > $testroot/wt/alpha.expected
1654 ||||||| commit $alpha_basecommit_id
1663 cat <<-EOF > $testroot/wt/numbers.expected
1671 ||||||| commit $commit_id
1682 cmp -s $testroot/wt
/alpha
$testroot/wt
/alpha.expected
1684 if [ $ret -ne 0 ]; then
1685 diff -u $testroot/wt
/alpha
$testroot/wt
/alpha.expected
1686 test_done
$testroot $ret
1690 cmp -s $testroot/wt
/numbers
$testroot/wt
/numbers.expected
1692 if [ $ret -ne 0 ]; then
1693 diff -u $testroot/wt
/numbers
$testroot/wt
/numbers.expected
1695 test_done
$testroot $ret
1698 test_patch_merge_unknown_blob
() {
1699 local testroot
=`test_init patch_merge_unknown_blob`
1701 got checkout
$testroot/repo
$testroot/wt
> /dev
/null
1703 if [ $ret -ne 0 ]; then
1704 test_done
$testroot $ret
1708 cat <<EOF > $testroot/wt/patch
1710 diff aaaabbbbccccddddeeeeffff0000111122223333 foo/bar
1712 blob - aaaabbbbccccddddeeeeffff0000111122223333
1714 blob + 0000111122223333444455556666777788889999
1724 (cd $testroot/wt
/ && got
patch patch) > $testroot/stdout
1726 if [ $ret -ne 0 ]; then
1727 test_done
$testroot $ret
1731 echo 'M alpha' > $testroot/stdout.expected
1732 cmp -s $testroot/stdout.expected
$testroot/stdout
1734 if [ $ret -ne 0 ]; then
1735 diff -u $testroot/stdout.expected
$testroot/stdout
1736 test_done
$testroot $ret
1740 # try again without a `diff' header
1742 cat <<EOF > $testroot/wt/patch
1744 blob - aaaabbbbccccddddeeeeffff0000111122223333
1746 blob + 0000111122223333444455556666777788889999
1756 (cd $testroot/wt
&& got revert alpha
> /dev
/null
&& got
patch patch) \
1759 if [ $ret -ne 0 ]; then
1760 test_done
$testroot $ret
1764 echo 'M alpha' > $testroot/stdout.expected
1765 cmp -s $testroot/stdout.expected
$testroot/stdout
1767 if [ $ret -ne 0 ]; then
1768 diff -u $testroot/stdout.expected
$testroot/stdout
1769 test_done
$testroot $ret
1773 # try again with a git-style diff
1775 cat <<EOF > $testroot/wt/patch
1776 diff --git a/alpha b/alpha
1777 index 0123456789ab..abcdef012345 100644
1785 (cd $testroot/wt
&& got revert alpha
> /dev
/null
&& got
patch patch) \
1788 if [ $ret -ne 0 ]; then
1789 test_done
$testroot $ret
1793 echo 'M alpha' > $testroot/stdout.expected
1794 cmp -s $testroot/stdout.expected
$testroot/stdout
1796 if [ $ret -ne 0 ]; then
1797 diff -u $testroot/stdout.expected
$testroot/stdout
1799 test_done
$testroot $ret
1802 test_patch_merge_reverse
() {
1803 local testroot
=`test_init patch_merge_simple`
1805 got checkout
$testroot/repo
$testroot/wt
> /dev
/null
1807 if [ $ret -ne 0 ]; then
1808 test_done
$testroot $ret
1812 seq 10 > $testroot/wt
/numbers
1813 (cd $testroot/wt
&& got add numbers
&& got commit
-m +numbers
) \
1816 if [ $ret -ne 0 ]; then
1817 test_done
$testroot $ret
1821 local commit_id
=`git_show_head $testroot/repo`
1823 seq 10 |
sed s
/5/five
/g
> $testroot/wt
/numbers
1824 (cd $testroot/wt
&& got
diff > $testroot/wt
/patch \
1825 && got commit
-m 'edit numbers') > /dev
/null
1827 if [ $ret -ne 0 ]; then
1828 test_done
$testroot $ret
1832 seq 10 |
sed -e s
/5/five
/g
-e s
/6/six
/g
> $testroot/wt
/numbers
1833 (cd $testroot/wt
&& got commit
-m 'edit numbers again') >/dev
/null
1835 if [ $ret -ne 0 ]; then
1836 test_done
$testroot $ret
1840 (cd $testroot/wt
&& got
patch -R patch) >/dev
/null
2>&1
1842 if [ $ret -eq 0 ]; then
1843 echo "unexpectedly reverted the patch" >&2
1844 test_done
$testroot 1
1848 cat <<-EOF > $testroot/wt/numbers.expected
1861 >>>>>>> commit $commit_id
1868 cmp -s $testroot/wt
/numbers
$testroot/wt
/numbers.expected
1870 if [ $ret -ne 0 ]; then
1871 diff -u $testroot/wt
/numbers
$testroot/wt
/numbers.expected
1873 test_done
$testroot $ret
1876 test_patch_newfile_xbit_got_diff
() {
1877 local testroot
=`test_init patch_newfile_xbit`
1879 got checkout
$testroot/repo
$testroot/wt
> /dev
/null
1881 if [ $ret -ne 0 ]; then
1882 test_done
$testroot $ret
1886 cat <<EOF > $testroot/wt/patch
1888 blob + abcdef0123456789abcdef012345678901234567 (mode 755)
1895 (cd $testroot/wt
&& got
patch patch) > /dev
/null
1897 if [ $ret -ne 0 ]; then
1898 test_done
$testroot $ret
1902 if [ ! -x $testroot/wt
/xfile
]; then
1903 echo "failed to set xbit on newfile" >&2
1904 test_done
$testroot 1
1908 echo xfile
> $testroot/wt
/xfile.expected
1909 cmp -s $testroot/wt
/xfile
$testroot/wt
/xfile.expected
1911 if [ $ret -ne 0 ]; then
1913 diff -u $testroot/wt
/xfile
$testroot/wt
/xfile.expected
1916 test_done
$testroot $ret
1919 test_patch_newfile_xbit_git_diff
() {
1920 local testroot
=`test_init patch_newfile_xbit`
1922 got checkout
$testroot/repo
$testroot/wt
> /dev
/null
1924 if [ $ret -ne 0 ]; then
1925 test_done
$testroot $ret
1929 cat <<EOF > $testroot/wt/patch
1930 diff --git a/xfile b/xfile
1931 new file mode 100755
1932 index 00000000..abcdef01
1939 (cd $testroot/wt
&& got
patch patch) > /dev
/null
1941 if [ $ret -ne 0 ]; then
1942 test_done
$testroot $ret
1946 if [ ! -x $testroot/wt
/xfile
]; then
1947 echo "failed to set xbit on newfile" >&2
1948 test_done
$testroot 1
1952 echo xfile
> $testroot/wt
/xfile.expected
1953 cmp -s $testroot/wt
/xfile
$testroot/wt
/xfile.expected
1955 if [ $ret -ne 0 ]; then
1957 diff -u $testroot/wt
/xfile
$testroot/wt
/xfile.expected
1960 test_done
$testroot $ret
1963 test_patch_umask
() {
1964 local testroot
=`test_init patch_umask`
1966 got checkout
"$testroot/repo" "$testroot/wt" >/dev
/null
1968 cat <<EOF >$testroot/wt/patch
1976 # using a subshell to avoid clobbering global umask
1977 (umask 077 && cd "$testroot/wt" && got
patch <patch) >/dev
/null
1979 if [ $ret -ne 0 ]; then
1980 test_done
"$testroot" $ret
1984 if ! ls -l "$testroot/wt/alpha" |
grep -q ^
-rw-------; then
1985 echo "alpha is not 0600 after patch" >&2
1986 ls -l "$testroot/wt/alpha" >&2
1987 test_done
"$testroot" 1
1991 test_done
"$testroot" 0
1994 test_patch_remove_binary_file
() {
1995 local testroot
=`test_init patch_remove_binary_file`
1997 if ! got checkout
$testroot/repo
$testroot/wt
>/dev
/null
; then
1998 test_done
$testroot $ret
2002 dd if=/dev
/zero of
=$testroot/wt
/x bs
=1 count
=16 2>/dev
/null
>&2
2003 (cd $testroot/wt
&& got add x
&& got commit
-m +x
) >/dev
/null
2005 (cd $testroot/wt
&& \
2006 got branch demo
&& \
2009 got up
-b master
) >/dev
/null
2011 echo 'D x' > $testroot/stdout.expected
2013 (cd $testroot/wt
&& got log
-c demo
-l 1 -p >patch)
2015 (cd $testroot/wt
&& got
patch <patch) > $testroot/stdout
2016 if [ $?
-ne 0 ]; then
2017 echo 'patch failed' >&2
2018 test_done
$testroot 1
2022 if ! cmp -s $testroot/stdout.expected
$testroot/stdout
; then
2023 diff -u $testroot/stdout.expected
$testroot/stdout
2024 test_done
$testroot 1
2028 # try again using a git produced diff
2029 (cd $testroot/wt
&& got revert x
) >/dev
/null
2031 git
-C $testroot/repo show demo
>$testroot/wt
/patch
2033 (cd $testroot/wt
&& got
patch <patch) > $testroot/stdout
2034 if [ $?
-ne 0 ]; then
2035 echo 'patch failed' >&2
2036 test_done
$testroot 1
2040 if ! cmp -s $testroot/stdout.expected
$testroot/stdout
; then
2041 diff -u $testroot/stdout.expected
$testroot/stdout
2042 test_done
$testroot 1
2046 # try again using a diff(1) style patch
2047 (cd $testroot/wt
&& got revert x
) >/dev
/null
2049 echo "Binary files x and /dev/null differ" >$testroot/wt
/patch
2050 (cd $testroot/wt
&& got
patch <patch) >$testroot/stdout
2051 if [ $?
-ne 0 ]; then
2052 echo 'patch failed' >&2
2053 test_done
$testroot 1
2057 if ! cmp -s $testroot/stdout.expected
$testroot/stdout
; then
2058 diff -u $testroot/stdout.expected
$testroot/stdout
2059 test_done
$testroot 1
2063 test_done
$testroot 0
2066 test_patch_commit_keywords
() {
2067 local testroot
=`test_init patch_commit_keywords`
2069 got checkout
$testroot/repo
$testroot/wt
>/dev
/null
2071 if [ $ret -ne 0 ]; then
2072 test_done
$testroot $ret
2076 seq 10 > $testroot/wt
/numbers
2077 (cd $testroot/wt
&& got add numbers
&& got commit
-m +numbers
) \
2080 if [ $ret -ne 0 ]; then
2081 test_done
$testroot $ret
2085 seq 10 |
sed s
/4/four
/ > $testroot/wt
/numbers
2087 # get rid of the metadata
2088 (cd $testroot/wt
&& got
diff |
sed -n '/^---/,$p' > patch) \
2091 seq 10 |
sed s
/6/six
/ > $testroot/wt
/numbers
2092 (cd $testroot/wt
&& got commit
-m 'edit numbers') >/dev
/null
2094 if [ $ret -ne 0 ]; then
2095 test_done
$testroot $ret
2099 (cd $testroot/wt
&& got
patch -c :head:- patch) >$testroot/stdout
2101 if [ $ret -ne 0 ]; then
2102 test_done
$testroot $ret
2106 echo 'G numbers' > $testroot/stdout.expected
2107 cmp -s $testroot/stdout
$testroot/stdout.expected
2109 if [ $ret -ne 0 ]; then
2110 diff -u $testroot/stdout
$testroot/stdout.expected
2111 test_done
$testroot $ret
2115 seq 10 |
sed -e s
/4/four
/ -e s
/6/six
/ > $testroot/wt
/numbers.expected
2116 cmp -s $testroot/wt
/numbers
$testroot/wt
/numbers.expected
2118 if [ $ret -ne 0 ]; then
2119 diff -u $testroot/wt
/numbers
$testroot/wt
/numbers.expected
2122 (cd "$testroot/wt" && got rv numbers
> /dev
/null
)
2124 (cd $testroot/wt
&& got
patch -c :base
:- patch) >$testroot/stdout
2126 if [ $ret -ne 0 ]; then
2127 test_done
$testroot $ret
2131 echo 'G numbers' > $testroot/stdout.expected
2132 cmp -s $testroot/stdout
$testroot/stdout.expected
2134 if [ $ret -ne 0 ]; then
2135 diff -u $testroot/stdout
$testroot/stdout.expected
2136 test_done
$testroot $ret
2140 seq 10 |
sed -e s
/4/four
/ -e s
/6/six
/ > $testroot/wt
/numbers.expected
2141 cmp -s $testroot/wt
/numbers
$testroot/wt
/numbers.expected
2143 if [ $ret -ne 0 ]; then
2144 diff -u $testroot/wt
/numbers
$testroot/wt
/numbers.expected
2147 test_done
$testroot $ret
2151 run_test test_patch_basic
2152 run_test test_patch_dont_apply
2153 run_test test_patch_malformed
2154 run_test test_patch_no_patch
2155 run_test test_patch_equals_for_context
2156 run_test test_patch_rename
2157 run_test test_patch_illegal_status
2158 run_test test_patch_nop
2159 run_test test_patch_preserve_perm
2160 run_test test_patch_create_dirs
2161 run_test test_patch_with_offset
2162 run_test test_patch_empty_file
2163 run_test test_patch_prefer_new_path
2164 run_test test_patch_no_newline
2165 run_test test_patch_strip
2166 run_test test_patch_whitespace
2167 run_test test_patch_relative_paths
2168 run_test test_patch_with_path_prefix
2169 run_test test_patch_relpath_with_path_prefix
2170 run_test test_patch_reverse
2171 run_test test_patch_merge_simple
2172 run_test test_patch_merge_gitdiff
2173 run_test test_patch_merge_base_provided
2174 run_test test_patch_merge_conflict
2175 run_test test_patch_merge_unknown_blob
2176 run_test test_patch_merge_reverse
2177 run_test test_patch_newfile_xbit_got_diff
2178 run_test test_patch_newfile_xbit_git_diff
2179 run_test test_patch_umask
2180 run_test test_patch_remove_binary_file
2181 run_test test_patch_commit_keywords