3 # Copyright (c) 2019 Stefan Sperling <stsp@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.
19 function test_unstage_basic {
20 local testroot=`test_init unstage_basic`
22 got checkout $testroot/repo $testroot/wt > /dev/null
24 if [ "$ret" != "0" ]; then
25 test_done "$testroot" "$ret"
29 echo "modified file" > $testroot/wt/alpha
30 (cd $testroot/wt && got rm beta > /dev/null)
31 echo "new file" > $testroot/wt/foo
32 (cd $testroot/wt && got add foo > /dev/null)
34 echo ' M alpha' > $testroot/stdout.expected
35 echo ' D beta' >> $testroot/stdout.expected
36 echo ' A foo' >> $testroot/stdout.expected
37 (cd $testroot/wt && got stage alpha beta foo > /dev/null)
39 (cd $testroot/wt && got unstage > $testroot/stdout)
41 if [ "$ret" != "0" ]; then
42 echo "got stage command succeeded unexpectedly" >&2
43 test_done "$testroot" "1"
47 echo 'G alpha' > $testroot/stdout.expected
48 echo 'D beta' >> $testroot/stdout.expected
49 echo 'G foo' >> $testroot/stdout.expected
50 cmp -s $testroot/stdout.expected $testroot/stdout
52 if [ "$ret" != "0" ]; then
53 diff -u $testroot/stdout.expected $testroot/stdout
54 test_done "$testroot" "$ret"
58 echo 'M alpha' > $testroot/stdout.expected
59 echo 'D beta' >> $testroot/stdout.expected
60 echo 'A foo' >> $testroot/stdout.expected
61 (cd $testroot/wt && got status > $testroot/stdout)
62 cmp -s $testroot/stdout.expected $testroot/stdout
64 if [ "$ret" != "0" ]; then
65 diff -u $testroot/stdout.expected $testroot/stdout
67 test_done "$testroot" "$ret"
70 function test_unstage_unversioned {
71 local testroot=`test_init unstage_unversioned`
73 got checkout $testroot/repo $testroot/wt > /dev/null
75 if [ "$ret" != "0" ]; then
76 test_done "$testroot" "$ret"
80 echo "modified file" > $testroot/wt/alpha
81 (cd $testroot/wt && got rm beta > /dev/null)
82 echo "new file" > $testroot/wt/foo
83 (cd $testroot/wt && got add foo > /dev/null)
85 echo ' M alpha' > $testroot/stdout.expected
86 echo ' D beta' >> $testroot/stdout.expected
87 echo ' A foo' >> $testroot/stdout.expected
88 (cd $testroot/wt && got stage > /dev/null)
90 touch $testroot/wt/unversioned-file
92 (cd $testroot/wt && got status > $testroot/stdout)
93 echo ' M alpha' > $testroot/stdout.expected
94 echo ' D beta' >> $testroot/stdout.expected
95 echo ' A foo' >> $testroot/stdout.expected
96 echo "? unversioned-file" >> $testroot/stdout.expected
97 cmp -s $testroot/stdout.expected $testroot/stdout
99 if [ "$ret" != "0" ]; then
100 diff -u $testroot/stdout.expected $testroot/stdout
101 test_done "$testroot" "$ret"
105 (cd $testroot/wt && got unstage > $testroot/stdout)
107 if [ "$ret" != "0" ]; then
108 echo "got unstage command failed unexpectedly" >&2
109 test_done "$testroot" "1"
113 echo 'G alpha' > $testroot/stdout.expected
114 echo 'D beta' >> $testroot/stdout.expected
115 echo 'G foo' >> $testroot/stdout.expected
116 cmp -s $testroot/stdout.expected $testroot/stdout
118 if [ "$ret" != "0" ]; then
119 diff -u $testroot/stdout.expected $testroot/stdout
120 test_done "$testroot" "$ret"
124 (cd $testroot/wt && got stage > /dev/null)
126 # unstaging an unversioned path is a no-op
127 (cd $testroot/wt && got unstage unversioned > $testroot/stdout)
129 if [ "$ret" != "0" ]; then
130 echo "got unstage command failed unexpectedly" >&2
131 test_done "$testroot" "$ret"
135 echo ' M alpha' > $testroot/stdout.expected
136 echo ' D beta' >> $testroot/stdout.expected
137 echo ' A foo' >> $testroot/stdout.expected
138 echo "? unversioned-file" >> $testroot/stdout.expected
139 (cd $testroot/wt && got status > $testroot/stdout)
140 cmp -s $testroot/stdout.expected $testroot/stdout
142 if [ "$ret" != "0" ]; then
143 diff -u $testroot/stdout.expected $testroot/stdout
145 test_done "$testroot" "$ret"
148 function test_unstage_patch {
149 local testroot=`test_init unstage_patch`
151 jot 16 > $testroot/repo/numbers
152 (cd $testroot/repo && git add numbers)
153 git_commit $testroot/repo -m "added numbers file"
154 local commit_id=`git_show_head $testroot/repo`
156 got checkout $testroot/repo $testroot/wt > /dev/null
158 if [ "$ret" != "0" ]; then
159 test_done "$testroot" "$ret"
163 sed -i -e 's/^2$/a/' $testroot/wt/numbers
164 sed -i -e 's/^7$/b/' $testroot/wt/numbers
165 sed -i -e 's/^16$/c/' $testroot/wt/numbers
167 (cd $testroot/wt && got stage > /dev/null)
169 if [ "$ret" != "0" ]; then
170 echo "got stage command failed unexpectedly" >&2
171 test_done "$testroot" "1"
175 # don't unstage any hunks
176 printf "n\nn\nn\n" > $testroot/patchscript
177 (cd $testroot/wt && got unstage -F $testroot/patchscript -p \
178 numbers > $testroot/stdout)
180 if [ "$ret" != "0" ]; then
181 echo "got stage command failed unexpectedly" >&2
182 test_done "$testroot" "1"
185 cat > $testroot/stdout.expected <<EOF
186 -----------------------------------------------
194 -----------------------------------------------
195 M numbers (change 1 of 3)
196 unstage this change? [y/n/q] n
197 -----------------------------------------------
207 -----------------------------------------------
208 M numbers (change 2 of 3)
209 unstage this change? [y/n/q] n
210 -----------------------------------------------
217 -----------------------------------------------
218 M numbers (change 3 of 3)
219 unstage this change? [y/n/q] n
221 cmp -s $testroot/stdout.expected $testroot/stdout
223 if [ "$ret" != "0" ]; then
224 diff -u $testroot/stdout.expected $testroot/stdout
225 test_done "$testroot" "$ret"
229 (cd $testroot/wt && got status > $testroot/stdout)
230 echo " M numbers" > $testroot/stdout.expected
231 cmp -s $testroot/stdout.expected $testroot/stdout
233 if [ "$ret" != "0" ]; then
234 diff -u $testroot/stdout.expected $testroot/stdout
235 test_done "$testroot" "$ret"
239 # unstage middle hunk
240 printf "n\ny\nn\n" > $testroot/patchscript
241 (cd $testroot/wt && got unstage -F $testroot/patchscript -p \
242 numbers > $testroot/stdout)
244 cat > $testroot/stdout.expected <<EOF
245 -----------------------------------------------
253 -----------------------------------------------
254 M numbers (change 1 of 3)
255 unstage this change? [y/n/q] n
256 -----------------------------------------------
266 -----------------------------------------------
267 M numbers (change 2 of 3)
268 unstage this change? [y/n/q] y
269 -----------------------------------------------
276 -----------------------------------------------
277 M numbers (change 3 of 3)
278 unstage this change? [y/n/q] n
281 cmp -s $testroot/stdout.expected $testroot/stdout
283 if [ "$ret" != "0" ]; then
284 diff -u $testroot/stdout.expected $testroot/stdout
285 test_done "$testroot" "$ret"
289 (cd $testroot/wt && got status > $testroot/stdout)
290 echo "MM numbers" > $testroot/stdout.expected
291 cmp -s $testroot/stdout.expected $testroot/stdout
293 if [ "$ret" != "0" ]; then
294 diff -u $testroot/stdout.expected $testroot/stdout
295 test_done "$testroot" "$ret"
299 (cd $testroot/wt && got diff -s > $testroot/stdout)
301 echo "diff $commit_id $testroot/wt (staged changes)" \
302 > $testroot/stdout.expected
303 echo -n 'blob - ' >> $testroot/stdout.expected
304 got tree -r $testroot/repo -i -c $commit_id \
305 | grep 'numbers$' | cut -d' ' -f 1 \
306 >> $testroot/stdout.expected
307 echo -n 'blob + ' >> $testroot/stdout.expected
308 (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 \
309 >> $testroot/stdout.expected
310 cat >> $testroot/stdout.expected <<EOF
327 cmp -s $testroot/stdout.expected $testroot/stdout
329 if [ "$ret" != "0" ]; then
330 diff -u $testroot/stdout.expected $testroot/stdout
331 test_done "$testroot" "$ret"
335 (cd $testroot/wt && got diff > $testroot/stdout)
336 echo "diff $commit_id $testroot/wt" > $testroot/stdout.expected
337 echo -n 'blob - ' >> $testroot/stdout.expected
338 (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 | \
339 tr -d '\n' >> $testroot/stdout.expected
340 echo " (staged)" >> $testroot/stdout.expected
341 echo "file + numbers" >> $testroot/stdout.expected
342 cat >> $testroot/stdout.expected <<EOF
355 cmp -s $testroot/stdout.expected $testroot/stdout
357 if [ "$ret" != "0" ]; then
358 diff -u $testroot/stdout.expected $testroot/stdout
359 test_done "$testroot" "$ret"
363 (cd $testroot/wt && got stage >/dev/null)
365 if [ "$ret" != "0" ]; then
366 echo "got stage command failed unexpectedly" >&2
367 test_done "$testroot" "1"
371 (cd $testroot/wt && got status > $testroot/stdout)
372 echo " M numbers" > $testroot/stdout.expected
373 cmp -s $testroot/stdout.expected $testroot/stdout
375 if [ "$ret" != "0" ]; then
376 diff -u $testroot/stdout.expected $testroot/stdout
377 test_done "$testroot" "$ret"
382 printf "n\nn\ny\n" > $testroot/patchscript
383 (cd $testroot/wt && got unstage -F $testroot/patchscript -p \
384 numbers > $testroot/stdout)
386 cat > $testroot/stdout.expected <<EOF
387 -----------------------------------------------
395 -----------------------------------------------
396 M numbers (change 1 of 3)
397 unstage this change? [y/n/q] n
398 -----------------------------------------------
408 -----------------------------------------------
409 M numbers (change 2 of 3)
410 unstage this change? [y/n/q] n
411 -----------------------------------------------
418 -----------------------------------------------
419 M numbers (change 3 of 3)
420 unstage this change? [y/n/q] y
423 cmp -s $testroot/stdout.expected $testroot/stdout
425 if [ "$ret" != "0" ]; then
426 diff -u $testroot/stdout.expected $testroot/stdout
427 test_done "$testroot" "$ret"
431 (cd $testroot/wt && got status > $testroot/stdout)
432 echo "MM numbers" > $testroot/stdout.expected
433 cmp -s $testroot/stdout.expected $testroot/stdout
435 if [ "$ret" != "0" ]; then
436 diff -u $testroot/stdout.expected $testroot/stdout
437 test_done "$testroot" "$ret"
441 (cd $testroot/wt && got diff -s > $testroot/stdout)
443 echo "diff $commit_id $testroot/wt (staged changes)" \
444 > $testroot/stdout.expected
445 echo -n 'blob - ' >> $testroot/stdout.expected
446 got tree -r $testroot/repo -i -c $commit_id \
447 | grep 'numbers$' | cut -d' ' -f 1 \
448 >> $testroot/stdout.expected
449 echo -n 'blob + ' >> $testroot/stdout.expected
450 (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 \
451 >> $testroot/stdout.expected
452 cat >> $testroot/stdout.expected <<EOF
469 cmp -s $testroot/stdout.expected $testroot/stdout
471 if [ "$ret" != "0" ]; then
472 diff -u $testroot/stdout.expected $testroot/stdout
473 test_done "$testroot" "$ret"
477 (cd $testroot/wt && got diff > $testroot/stdout)
478 echo "diff $commit_id $testroot/wt" > $testroot/stdout.expected
479 echo -n 'blob - ' >> $testroot/stdout.expected
480 (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 | \
481 tr -d '\n' >> $testroot/stdout.expected
482 echo " (staged)" >> $testroot/stdout.expected
483 echo "file + numbers" >> $testroot/stdout.expected
484 cat >> $testroot/stdout.expected <<EOF
494 cmp -s $testroot/stdout.expected $testroot/stdout
496 if [ "$ret" != "0" ]; then
497 diff -u $testroot/stdout.expected $testroot/stdout
498 test_done "$testroot" "$ret"
502 (cd $testroot/wt && got stage >/dev/null)
504 if [ "$ret" != "0" ]; then
505 echo "got stage command failed unexpectedly" >&2
506 test_done "$testroot" "1"
510 (cd $testroot/wt && got status > $testroot/stdout)
511 echo " M numbers" > $testroot/stdout.expected
512 cmp -s $testroot/stdout.expected $testroot/stdout
514 if [ "$ret" != "0" ]; then
515 diff -u $testroot/stdout.expected $testroot/stdout
516 test_done "$testroot" "$ret"
521 printf "y\ny\ny\n" > $testroot/patchscript
522 (cd $testroot/wt && got unstage -F $testroot/patchscript -p \
523 numbers > $testroot/stdout)
525 cat > $testroot/stdout.expected <<EOF
526 -----------------------------------------------
534 -----------------------------------------------
535 M numbers (change 1 of 3)
536 unstage this change? [y/n/q] y
537 -----------------------------------------------
547 -----------------------------------------------
548 M numbers (change 2 of 3)
549 unstage this change? [y/n/q] y
550 -----------------------------------------------
557 -----------------------------------------------
558 M numbers (change 3 of 3)
559 unstage this change? [y/n/q] y
562 cmp -s $testroot/stdout.expected $testroot/stdout
564 if [ "$ret" != "0" ]; then
565 diff -u $testroot/stdout.expected $testroot/stdout
566 test_done "$testroot" "$ret"
570 (cd $testroot/wt && got status > $testroot/stdout)
571 echo "M numbers" > $testroot/stdout.expected
572 cmp -s $testroot/stdout.expected $testroot/stdout
574 if [ "$ret" != "0" ]; then
575 diff -u $testroot/stdout.expected $testroot/stdout
576 test_done "$testroot" "$ret"
580 (cd $testroot/wt && got diff -s > $testroot/stdout)
581 echo -n > $testroot/stdout.expected
582 cmp -s $testroot/stdout.expected $testroot/stdout
584 if [ "$ret" != "0" ]; then
585 diff -u $testroot/stdout.expected $testroot/stdout
586 test_done "$testroot" "$ret"
590 (cd $testroot/wt && got diff > $testroot/stdout)
592 echo "diff $commit_id $testroot/wt" > $testroot/stdout.expected
593 echo -n 'blob - ' >> $testroot/stdout.expected
594 got tree -r $testroot/repo -i -c $commit_id \
595 | grep 'numbers$' | cut -d' ' -f 1 \
596 >> $testroot/stdout.expected
597 echo 'file + numbers' >> $testroot/stdout.expected
598 cat >> $testroot/stdout.expected <<EOF
621 cmp -s $testroot/stdout.expected $testroot/stdout
623 if [ "$ret" != "0" ]; then
624 diff -u $testroot/stdout.expected $testroot/stdout
626 test_done "$testroot" "$ret"
630 function test_unstage_patch_added {
631 local testroot=`test_init unstage_patch_added`
632 local commit_id=`git_show_head $testroot/repo`
634 got checkout $testroot/repo $testroot/wt > /dev/null
636 if [ "$ret" != "0" ]; then
637 test_done "$testroot" "$ret"
641 echo "new" > $testroot/wt/epsilon/new
642 (cd $testroot/wt && got add epsilon/new > /dev/null)
644 (cd $testroot/wt && got stage > /dev/null)
646 printf "y\n" > $testroot/patchscript
647 (cd $testroot/wt && got unstage -F $testroot/patchscript -p \
648 epsilon/new > $testroot/stdout)
650 echo "A epsilon/new" > $testroot/stdout.expected
651 echo "unstage this addition? [y/n] y" >> $testroot/stdout.expected
652 echo "G epsilon/new" >> $testroot/stdout.expected
653 cmp -s $testroot/stdout.expected $testroot/stdout
655 if [ "$ret" != "0" ]; then
656 diff -u $testroot/stdout.expected $testroot/stdout
657 test_done "$testroot" "$ret"
661 (cd $testroot/wt && got status > $testroot/stdout)
662 echo "A epsilon/new" > $testroot/stdout.expected
663 cmp -s $testroot/stdout.expected $testroot/stdout
665 if [ "$ret" != "0" ]; then
666 diff -u $testroot/stdout.expected $testroot/stdout
667 test_done "$testroot" "$ret"
671 (cd $testroot/wt && got diff -s > $testroot/stdout)
672 echo -n > $testroot/stdout.expected
673 cmp -s $testroot/stdout.expected $testroot/stdout
675 if [ "$ret" != "0" ]; then
676 diff -u $testroot/stdout.expected $testroot/stdout
677 test_done "$testroot" "$ret"
681 (cd $testroot/wt && got diff > $testroot/stdout)
683 echo "diff $commit_id $testroot/wt" > $testroot/stdout.expected
684 echo 'blob - /dev/null' >> $testroot/stdout.expected
685 echo 'file + epsilon/new' >> $testroot/stdout.expected
686 echo "--- epsilon/new" >> $testroot/stdout.expected
687 echo "+++ epsilon/new" >> $testroot/stdout.expected
688 echo "@@ -0,0 +1 @@" >> $testroot/stdout.expected
689 echo "+new" >> $testroot/stdout.expected
690 cmp -s $testroot/stdout.expected $testroot/stdout
692 if [ "$ret" != "0" ]; then
693 diff -u $testroot/stdout.expected $testroot/stdout
695 test_done "$testroot" "$ret"
698 function test_unstage_patch_removed {
699 local testroot=`test_init unstage_patch_removed`
700 local commit_id=`git_show_head $testroot/repo`
702 got checkout $testroot/repo $testroot/wt > /dev/null
704 if [ "$ret" != "0" ]; then
705 test_done "$testroot" "$ret"
709 (cd $testroot/wt && got rm beta > /dev/null)
710 (cd $testroot/wt && got stage > /dev/null)
712 printf "y\n" > $testroot/patchscript
713 (cd $testroot/wt && got unstage -F $testroot/patchscript -p \
714 beta > $testroot/stdout)
716 echo "D beta" > $testroot/stdout.expected
717 echo "unstage this deletion? [y/n] y" >> $testroot/stdout.expected
718 echo "D beta" >> $testroot/stdout.expected
719 cmp -s $testroot/stdout.expected $testroot/stdout
721 if [ "$ret" != "0" ]; then
722 diff -u $testroot/stdout.expected $testroot/stdout
723 test_done "$testroot" "$ret"
727 (cd $testroot/wt && got status > $testroot/stdout)
728 echo "D beta" > $testroot/stdout.expected
729 cmp -s $testroot/stdout.expected $testroot/stdout
731 if [ "$ret" != "0" ]; then
732 diff -u $testroot/stdout.expected $testroot/stdout
733 test_done "$testroot" "$ret"
737 (cd $testroot/wt && got diff -s > $testroot/stdout)
738 echo -n > $testroot/stdout.expected
739 cmp -s $testroot/stdout.expected $testroot/stdout
741 if [ "$ret" != "0" ]; then
742 diff -u $testroot/stdout.expected $testroot/stdout
743 test_done "$testroot" "$ret"
747 (cd $testroot/wt && got diff > $testroot/stdout)
749 echo "diff $commit_id $testroot/wt" \
750 > $testroot/stdout.expected
751 echo -n 'blob - ' >> $testroot/stdout.expected
752 got tree -r $testroot/repo -i | grep 'beta$' | cut -d' ' -f 1 \
753 >> $testroot/stdout.expected
754 echo 'file + /dev/null' >> $testroot/stdout.expected
755 echo "--- beta" >> $testroot/stdout.expected
756 echo "+++ beta" >> $testroot/stdout.expected
757 echo "@@ -1 +0,0 @@" >> $testroot/stdout.expected
758 echo "-beta" >> $testroot/stdout.expected
759 cmp -s $testroot/stdout.expected $testroot/stdout
761 if [ "$ret" != "0" ]; then
762 diff -u $testroot/stdout.expected $testroot/stdout
764 test_done "$testroot" "$ret"
767 function test_unstage_patch_quit {
768 local testroot=`test_init unstage_patch_quit`
770 jot 16 > $testroot/repo/numbers
771 echo zzz > $testroot/repo/zzz
772 (cd $testroot/repo && git add numbers zzz)
773 git_commit $testroot/repo -m "added files"
774 local commit_id=`git_show_head $testroot/repo`
776 got checkout $testroot/repo $testroot/wt > /dev/null
778 if [ "$ret" != "0" ]; then
779 test_done "$testroot" "$ret"
783 sed -i -e 's/^2$/a/' $testroot/wt/numbers
784 sed -i -e 's/^7$/b/' $testroot/wt/numbers
785 sed -i -e 's/^16$/c/' $testroot/wt/numbers
786 (cd $testroot/wt && got rm zzz > /dev/null)
787 (cd $testroot/wt && got stage > /dev/null)
789 # unstage first hunk and quit; and don't pass a path argument to
790 # ensure that we don't skip asking about the 'zzz' file after 'quit'
791 printf "y\nq\nn\n" > $testroot/patchscript
792 (cd $testroot/wt && got unstage -F $testroot/patchscript -p \
795 if [ "$ret" != "0" ]; then
796 echo "got stage command failed unexpectedly" >&2
797 test_done "$testroot" "1"
800 cat > $testroot/stdout.expected <<EOF
801 -----------------------------------------------
809 -----------------------------------------------
810 M numbers (change 1 of 3)
811 unstage this change? [y/n/q] y
812 -----------------------------------------------
822 -----------------------------------------------
823 M numbers (change 2 of 3)
824 unstage this change? [y/n/q] q
827 unstage this deletion? [y/n] n
829 cmp -s $testroot/stdout.expected $testroot/stdout
831 if [ "$ret" != "0" ]; then
832 diff -u $testroot/stdout.expected $testroot/stdout
833 test_done "$testroot" "$ret"
837 (cd $testroot/wt && got status > $testroot/stdout)
838 echo "MM numbers" > $testroot/stdout.expected
839 echo " D zzz" >> $testroot/stdout.expected
840 cmp -s $testroot/stdout.expected $testroot/stdout
842 if [ "$ret" != "0" ]; then
843 diff -u $testroot/stdout.expected $testroot/stdout
844 test_done "$testroot" "$ret"
848 (cd $testroot/wt && got diff > $testroot/stdout)
850 echo "diff $commit_id $testroot/wt" > $testroot/stdout.expected
851 echo -n 'blob - ' >> $testroot/stdout.expected
852 (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 | \
853 tr -d '\n' >> $testroot/stdout.expected
854 echo " (staged)" >> $testroot/stdout.expected
855 echo "file + numbers" >> $testroot/stdout.expected
856 echo "--- numbers" >> $testroot/stdout.expected
857 echo "+++ numbers" >> $testroot/stdout.expected
858 echo "@@ -1,5 +1,5 @@" >> $testroot/stdout.expected
859 echo " 1" >> $testroot/stdout.expected
860 echo "-2" >> $testroot/stdout.expected
861 echo "+a" >> $testroot/stdout.expected
862 echo " 3" >> $testroot/stdout.expected
863 echo " 4" >> $testroot/stdout.expected
864 echo " 5" >> $testroot/stdout.expected
865 cmp -s $testroot/stdout.expected $testroot/stdout
867 if [ "$ret" != "0" ]; then
868 diff -u $testroot/stdout.expected $testroot/stdout
869 test_done "$testroot" "$ret"
873 (cd $testroot/wt && got diff -s > $testroot/stdout)
874 echo "diff $commit_id $testroot/wt (staged changes)" \
875 > $testroot/stdout.expected
876 echo -n 'blob - ' >> $testroot/stdout.expected
877 got tree -r $testroot/repo -i -c $commit_id \
878 | grep 'numbers$' | cut -d' ' -f 1 \
879 >> $testroot/stdout.expected
880 echo -n 'blob + ' >> $testroot/stdout.expected
881 (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 \
882 >> $testroot/stdout.expected
883 cat >> $testroot/stdout.expected <<EOF
902 echo -n 'blob - ' >> $testroot/stdout.expected
903 got tree -r $testroot/repo -i | grep 'zzz$' | cut -d' ' -f 1 \
904 >> $testroot/stdout.expected
905 echo 'blob + /dev/null' >> $testroot/stdout.expected
906 echo "--- zzz" >> $testroot/stdout.expected
907 echo "+++ /dev/null" >> $testroot/stdout.expected
908 echo "@@ -1 +0,0 @@" >> $testroot/stdout.expected
909 echo "-zzz" >> $testroot/stdout.expected
910 cmp -s $testroot/stdout.expected $testroot/stdout
912 if [ "$ret" != "0" ]; then
913 diff -u $testroot/stdout.expected $testroot/stdout
915 test_done "$testroot" "$ret"
918 run_test test_unstage_basic
919 run_test test_unstage_unversioned
920 run_test test_unstage_patch
921 run_test test_unstage_patch_added
922 run_test test_unstage_patch_removed
923 run_test test_unstage_patch_quit