Blob


1 #!/bin/sh
2 #
3 # Copyright (c) 2019 Stefan Sperling <stsp@openbsd.org>
4 #
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.
8 #
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_unstage_basic() {
20 local testroot=`test_init unstage_basic`
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
27 fi
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)
40 ret=$?
41 if [ $ret -ne 0 ]; then
42 echo "got unstage command failed unexpectedly" >&2
43 test_done "$testroot" "1"
44 return 1
45 fi
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
51 ret=$?
52 if [ $ret -ne 0 ]; then
53 diff -u $testroot/stdout.expected $testroot/stdout
54 test_done "$testroot" "$ret"
55 return 1
56 fi
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
63 ret=$?
64 if [ $ret -ne 0 ]; then
65 diff -u $testroot/stdout.expected $testroot/stdout
66 fi
67 test_done "$testroot" "$ret"
68 }
70 test_unstage_unversioned() {
71 local testroot=`test_init unstage_unversioned`
73 got checkout $testroot/repo $testroot/wt > /dev/null
74 ret=$?
75 if [ $ret -ne 0 ]; then
76 test_done "$testroot" "$ret"
77 return 1
78 fi
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
98 ret=$?
99 if [ $ret -ne 0 ]; then
100 diff -u $testroot/stdout.expected $testroot/stdout
101 test_done "$testroot" "$ret"
102 return 1
103 fi
105 (cd $testroot/wt && got unstage > $testroot/stdout)
106 ret=$?
107 if [ $ret -ne 0 ]; then
108 echo "got unstage command failed unexpectedly" >&2
109 test_done "$testroot" "1"
110 return 1
111 fi
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
117 ret=$?
118 if [ $ret -ne 0 ]; then
119 diff -u $testroot/stdout.expected $testroot/stdout
120 test_done "$testroot" "$ret"
121 return 1
122 fi
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)
128 ret=$?
129 if [ $ret -ne 0 ]; then
130 echo "got unstage command failed unexpectedly" >&2
131 test_done "$testroot" "$ret"
132 return 1
133 fi
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
141 ret=$?
142 if [ $ret -ne 0 ]; then
143 diff -u $testroot/stdout.expected $testroot/stdout
144 fi
145 test_done "$testroot" "$ret"
148 test_unstage_nonexistent() {
149 local testroot=`test_init unstage_nonexistent`
151 got checkout $testroot/repo $testroot/wt > /dev/null
152 ret=$?
153 if [ $ret -ne 0 ]; then
154 test_done "$testroot" "$ret"
155 return 1
156 fi
158 echo "modified file" > $testroot/wt/alpha
159 (cd $testroot/wt && got rm beta > /dev/null)
160 echo "new file" > $testroot/wt/foo
161 (cd $testroot/wt && got add foo > /dev/null)
163 echo ' M alpha' > $testroot/stdout.expected
164 echo ' D beta' >> $testroot/stdout.expected
165 echo ' A foo' >> $testroot/stdout.expected
166 (cd $testroot/wt && got stage > /dev/null)
168 # unstaging a non-existent file is a no-op
169 (cd $testroot/wt && got unstage nonexistent-file > $testroot/stdout)
170 ret=$?
171 if [ $ret -ne 0 ]; then
172 echo "got unstage command failed unexpectedly" >&2
173 test_done "$testroot" "1"
174 return 1
175 fi
177 echo -n > $testroot/stdout.expected
178 cmp -s $testroot/stdout.expected $testroot/stdout
179 ret=$?
180 if [ $ret -ne 0 ]; then
181 diff -u $testroot/stdout.expected $testroot/stdout
182 fi
183 test_done "$testroot" "$ret"
186 test_unstage_patch() {
187 local testroot=`test_init unstage_patch`
189 jot 16 > $testroot/repo/numbers
190 (cd $testroot/repo && git add numbers)
191 git_commit $testroot/repo -m "added numbers file"
192 local commit_id=`git_show_head $testroot/repo`
194 got checkout $testroot/repo $testroot/wt > /dev/null
195 ret=$?
196 if [ $ret -ne 0 ]; then
197 test_done "$testroot" "$ret"
198 return 1
199 fi
201 sed -i -e 's/^2$/a/' $testroot/wt/numbers
202 sed -i -e 's/^7$/b/' $testroot/wt/numbers
203 sed -i -e 's/^16$/c/' $testroot/wt/numbers
205 (cd $testroot/wt && got stage > /dev/null)
206 ret=$?
207 if [ $ret -ne 0 ]; then
208 echo "got stage command failed unexpectedly" >&2
209 test_done "$testroot" "1"
210 return 1
211 fi
213 # don't unstage any hunks
214 printf "n\nn\nn\n" > $testroot/patchscript
215 (cd $testroot/wt && got unstage -F $testroot/patchscript -p \
216 numbers > $testroot/stdout)
217 ret=$?
218 if [ $ret -ne 0 ]; then
219 echo "got unstage command failed unexpectedly" >&2
220 test_done "$testroot" "1"
221 return 1
222 fi
223 cat > $testroot/stdout.expected <<EOF
224 -----------------------------------------------
225 @@ -1,5 +1,5 @@
227 -2
228 +a
232 -----------------------------------------------
233 M numbers (change 1 of 3)
234 unstage this change? [y/n/q] n
235 -----------------------------------------------
236 @@ -4,7 +4,7 @@
240 -7
241 +b
244 10
245 -----------------------------------------------
246 M numbers (change 2 of 3)
247 unstage this change? [y/n/q] n
248 -----------------------------------------------
249 @@ -13,4 +13,4 @@
250 13
251 14
252 15
253 -16
254 +c
255 -----------------------------------------------
256 M numbers (change 3 of 3)
257 unstage this change? [y/n/q] n
258 EOF
259 cmp -s $testroot/stdout.expected $testroot/stdout
260 ret=$?
261 if [ $ret -ne 0 ]; then
262 diff -u $testroot/stdout.expected $testroot/stdout
263 test_done "$testroot" "$ret"
264 return 1
265 fi
267 (cd $testroot/wt && got status > $testroot/stdout)
268 echo " M numbers" > $testroot/stdout.expected
269 cmp -s $testroot/stdout.expected $testroot/stdout
270 ret=$?
271 if [ $ret -ne 0 ]; then
272 diff -u $testroot/stdout.expected $testroot/stdout
273 test_done "$testroot" "$ret"
274 return 1
275 fi
277 # unstage middle hunk
278 printf "n\ny\nn\n" > $testroot/patchscript
279 (cd $testroot/wt && got unstage -F $testroot/patchscript -p \
280 numbers > $testroot/stdout)
282 cat > $testroot/stdout.expected <<EOF
283 -----------------------------------------------
284 @@ -1,5 +1,5 @@
286 -2
287 +a
291 -----------------------------------------------
292 M numbers (change 1 of 3)
293 unstage this change? [y/n/q] n
294 -----------------------------------------------
295 @@ -4,7 +4,7 @@
299 -7
300 +b
303 10
304 -----------------------------------------------
305 M numbers (change 2 of 3)
306 unstage this change? [y/n/q] y
307 -----------------------------------------------
308 @@ -13,4 +13,4 @@
309 13
310 14
311 15
312 -16
313 +c
314 -----------------------------------------------
315 M numbers (change 3 of 3)
316 unstage this change? [y/n/q] n
317 G numbers
318 EOF
319 cmp -s $testroot/stdout.expected $testroot/stdout
320 ret=$?
321 if [ $ret -ne 0 ]; then
322 diff -u $testroot/stdout.expected $testroot/stdout
323 test_done "$testroot" "$ret"
324 return 1
325 fi
327 (cd $testroot/wt && got status > $testroot/stdout)
328 echo "MM numbers" > $testroot/stdout.expected
329 cmp -s $testroot/stdout.expected $testroot/stdout
330 ret=$?
331 if [ $ret -ne 0 ]; then
332 diff -u $testroot/stdout.expected $testroot/stdout
333 test_done "$testroot" "$ret"
334 return 1
335 fi
337 (cd $testroot/wt && got diff -s > $testroot/stdout)
339 echo "diff $commit_id $testroot/wt (staged changes)" \
340 > $testroot/stdout.expected
341 echo -n 'blob - ' >> $testroot/stdout.expected
342 got tree -r $testroot/repo -i -c $commit_id \
343 | grep 'numbers$' | cut -d' ' -f 1 \
344 >> $testroot/stdout.expected
345 echo -n 'blob + ' >> $testroot/stdout.expected
346 (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 \
347 >> $testroot/stdout.expected
348 cat >> $testroot/stdout.expected <<EOF
349 --- numbers
350 +++ numbers
351 @@ -1,5 +1,5 @@
353 -2
354 +a
358 @@ -13,4 +13,4 @@
359 13
360 14
361 15
362 -16
363 +c
364 EOF
365 cmp -s $testroot/stdout.expected $testroot/stdout
366 ret=$?
367 if [ $ret -ne 0 ]; then
368 diff -u $testroot/stdout.expected $testroot/stdout
369 test_done "$testroot" "$ret"
370 return 1
371 fi
373 (cd $testroot/wt && got diff > $testroot/stdout)
374 echo "diff $commit_id $testroot/wt" > $testroot/stdout.expected
375 echo -n 'blob - ' >> $testroot/stdout.expected
376 (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 | \
377 tr -d '\n' >> $testroot/stdout.expected
378 echo " (staged)" >> $testroot/stdout.expected
379 echo "file + numbers" >> $testroot/stdout.expected
380 cat >> $testroot/stdout.expected <<EOF
381 --- numbers
382 +++ numbers
383 @@ -4,7 +4,7 @@ a
387 -7
388 +b
391 10
392 EOF
393 cmp -s $testroot/stdout.expected $testroot/stdout
394 ret=$?
395 if [ $ret -ne 0 ]; then
396 diff -u $testroot/stdout.expected $testroot/stdout
397 test_done "$testroot" "$ret"
398 return 1
399 fi
401 (cd $testroot/wt && got stage >/dev/null)
402 ret=$?
403 if [ $ret -ne 0 ]; then
404 echo "got stage command failed unexpectedly" >&2
405 test_done "$testroot" "1"
406 return 1
407 fi
409 (cd $testroot/wt && got status > $testroot/stdout)
410 echo " M numbers" > $testroot/stdout.expected
411 cmp -s $testroot/stdout.expected $testroot/stdout
412 ret=$?
413 if [ $ret -ne 0 ]; then
414 diff -u $testroot/stdout.expected $testroot/stdout
415 test_done "$testroot" "$ret"
416 return 1
417 fi
419 # unstage last hunk
420 printf "n\nn\ny\n" > $testroot/patchscript
421 (cd $testroot/wt && got unstage -F $testroot/patchscript -p \
422 numbers > $testroot/stdout)
424 cat > $testroot/stdout.expected <<EOF
425 -----------------------------------------------
426 @@ -1,5 +1,5 @@
428 -2
429 +a
433 -----------------------------------------------
434 M numbers (change 1 of 3)
435 unstage this change? [y/n/q] n
436 -----------------------------------------------
437 @@ -4,7 +4,7 @@
441 -7
442 +b
445 10
446 -----------------------------------------------
447 M numbers (change 2 of 3)
448 unstage this change? [y/n/q] n
449 -----------------------------------------------
450 @@ -13,4 +13,4 @@
451 13
452 14
453 15
454 -16
455 +c
456 -----------------------------------------------
457 M numbers (change 3 of 3)
458 unstage this change? [y/n/q] y
459 G numbers
460 EOF
461 cmp -s $testroot/stdout.expected $testroot/stdout
462 ret=$?
463 if [ $ret -ne 0 ]; then
464 diff -u $testroot/stdout.expected $testroot/stdout
465 test_done "$testroot" "$ret"
466 return 1
467 fi
469 (cd $testroot/wt && got status > $testroot/stdout)
470 echo "MM numbers" > $testroot/stdout.expected
471 cmp -s $testroot/stdout.expected $testroot/stdout
472 ret=$?
473 if [ $ret -ne 0 ]; then
474 diff -u $testroot/stdout.expected $testroot/stdout
475 test_done "$testroot" "$ret"
476 return 1
477 fi
479 (cd $testroot/wt && got diff -s > $testroot/stdout)
481 echo "diff $commit_id $testroot/wt (staged changes)" \
482 > $testroot/stdout.expected
483 echo -n 'blob - ' >> $testroot/stdout.expected
484 got tree -r $testroot/repo -i -c $commit_id \
485 | grep 'numbers$' | cut -d' ' -f 1 \
486 >> $testroot/stdout.expected
487 echo -n 'blob + ' >> $testroot/stdout.expected
488 (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 \
489 >> $testroot/stdout.expected
490 cat >> $testroot/stdout.expected <<EOF
491 --- numbers
492 +++ numbers
493 @@ -1,10 +1,10 @@
495 -2
496 +a
501 -7
502 +b
505 10
506 EOF
507 cmp -s $testroot/stdout.expected $testroot/stdout
508 ret=$?
509 if [ $ret -ne 0 ]; then
510 diff -u $testroot/stdout.expected $testroot/stdout
511 test_done "$testroot" "$ret"
512 return 1
513 fi
515 (cd $testroot/wt && got diff > $testroot/stdout)
516 echo "diff $commit_id $testroot/wt" > $testroot/stdout.expected
517 echo -n 'blob - ' >> $testroot/stdout.expected
518 (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 | \
519 tr -d '\n' >> $testroot/stdout.expected
520 echo " (staged)" >> $testroot/stdout.expected
521 echo "file + numbers" >> $testroot/stdout.expected
522 cat >> $testroot/stdout.expected <<EOF
523 --- numbers
524 +++ numbers
525 @@ -13,4 +13,4 @@ b
526 13
527 14
528 15
529 -16
530 +c
531 EOF
532 cmp -s $testroot/stdout.expected $testroot/stdout
533 ret=$?
534 if [ $ret -ne 0 ]; then
535 diff -u $testroot/stdout.expected $testroot/stdout
536 test_done "$testroot" "$ret"
537 return 1
538 fi
540 (cd $testroot/wt && got stage >/dev/null)
541 ret=$?
542 if [ $ret -ne 0 ]; then
543 echo "got stage command failed unexpectedly" >&2
544 test_done "$testroot" "1"
545 return 1
546 fi
548 (cd $testroot/wt && got status > $testroot/stdout)
549 echo " M numbers" > $testroot/stdout.expected
550 cmp -s $testroot/stdout.expected $testroot/stdout
551 ret=$?
552 if [ $ret -ne 0 ]; then
553 diff -u $testroot/stdout.expected $testroot/stdout
554 test_done "$testroot" "$ret"
555 return 1
556 fi
558 # unstage all hunks
559 printf "y\ny\ny\n" > $testroot/patchscript
560 (cd $testroot/wt && got unstage -F $testroot/patchscript -p \
561 numbers > $testroot/stdout)
563 cat > $testroot/stdout.expected <<EOF
564 -----------------------------------------------
565 @@ -1,5 +1,5 @@
567 -2
568 +a
572 -----------------------------------------------
573 M numbers (change 1 of 3)
574 unstage this change? [y/n/q] y
575 -----------------------------------------------
576 @@ -4,7 +4,7 @@
580 -7
581 +b
584 10
585 -----------------------------------------------
586 M numbers (change 2 of 3)
587 unstage this change? [y/n/q] y
588 -----------------------------------------------
589 @@ -13,4 +13,4 @@
590 13
591 14
592 15
593 -16
594 +c
595 -----------------------------------------------
596 M numbers (change 3 of 3)
597 unstage this change? [y/n/q] y
598 G numbers
599 EOF
600 cmp -s $testroot/stdout.expected $testroot/stdout
601 ret=$?
602 if [ $ret -ne 0 ]; then
603 diff -u $testroot/stdout.expected $testroot/stdout
604 test_done "$testroot" "$ret"
605 return 1
606 fi
608 (cd $testroot/wt && got status > $testroot/stdout)
609 echo "M numbers" > $testroot/stdout.expected
610 cmp -s $testroot/stdout.expected $testroot/stdout
611 ret=$?
612 if [ $ret -ne 0 ]; then
613 diff -u $testroot/stdout.expected $testroot/stdout
614 test_done "$testroot" "$ret"
615 return 1
616 fi
618 (cd $testroot/wt && got diff -s > $testroot/stdout)
619 echo -n > $testroot/stdout.expected
620 cmp -s $testroot/stdout.expected $testroot/stdout
621 ret=$?
622 if [ $ret -ne 0 ]; then
623 diff -u $testroot/stdout.expected $testroot/stdout
624 test_done "$testroot" "$ret"
625 return 1
626 fi
628 (cd $testroot/wt && got diff > $testroot/stdout)
630 echo "diff $commit_id $testroot/wt" > $testroot/stdout.expected
631 echo -n 'blob - ' >> $testroot/stdout.expected
632 got tree -r $testroot/repo -i -c $commit_id \
633 | grep 'numbers$' | cut -d' ' -f 1 \
634 >> $testroot/stdout.expected
635 echo 'file + numbers' >> $testroot/stdout.expected
636 cat >> $testroot/stdout.expected <<EOF
637 --- numbers
638 +++ numbers
639 @@ -1,10 +1,10 @@
641 -2
642 +a
647 -7
648 +b
651 10
652 @@ -13,4 +13,4 @@
653 13
654 14
655 15
656 -16
657 +c
658 EOF
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 fi
664 test_done "$testroot" "$ret"
668 test_unstage_patch_added() {
669 local testroot=`test_init unstage_patch_added`
670 local commit_id=`git_show_head $testroot/repo`
672 got checkout $testroot/repo $testroot/wt > /dev/null
673 ret=$?
674 if [ $ret -ne 0 ]; then
675 test_done "$testroot" "$ret"
676 return 1
677 fi
679 echo "new" > $testroot/wt/epsilon/new
680 (cd $testroot/wt && got add epsilon/new > /dev/null)
682 (cd $testroot/wt && got stage > /dev/null)
684 printf "y\n" > $testroot/patchscript
685 (cd $testroot/wt && got unstage -F $testroot/patchscript -p \
686 epsilon/new > $testroot/stdout)
688 echo "A epsilon/new" > $testroot/stdout.expected
689 echo "unstage this addition? [y/n] y" >> $testroot/stdout.expected
690 echo "G epsilon/new" >> $testroot/stdout.expected
691 cmp -s $testroot/stdout.expected $testroot/stdout
692 ret=$?
693 if [ $ret -ne 0 ]; then
694 diff -u $testroot/stdout.expected $testroot/stdout
695 test_done "$testroot" "$ret"
696 return 1
697 fi
699 (cd $testroot/wt && got status > $testroot/stdout)
700 echo "A epsilon/new" > $testroot/stdout.expected
701 cmp -s $testroot/stdout.expected $testroot/stdout
702 ret=$?
703 if [ $ret -ne 0 ]; then
704 diff -u $testroot/stdout.expected $testroot/stdout
705 test_done "$testroot" "$ret"
706 return 1
707 fi
709 (cd $testroot/wt && got diff -s > $testroot/stdout)
710 echo -n > $testroot/stdout.expected
711 cmp -s $testroot/stdout.expected $testroot/stdout
712 ret=$?
713 if [ $ret -ne 0 ]; then
714 diff -u $testroot/stdout.expected $testroot/stdout
715 test_done "$testroot" "$ret"
716 return 1
717 fi
719 (cd $testroot/wt && got diff > $testroot/stdout)
721 echo "diff $commit_id $testroot/wt" > $testroot/stdout.expected
722 echo 'blob - /dev/null' >> $testroot/stdout.expected
723 echo 'file + epsilon/new' >> $testroot/stdout.expected
724 echo "--- /dev/null" >> $testroot/stdout.expected
725 echo "+++ epsilon/new" >> $testroot/stdout.expected
726 echo "@@ -0,0 +1 @@" >> $testroot/stdout.expected
727 echo "+new" >> $testroot/stdout.expected
728 cmp -s $testroot/stdout.expected $testroot/stdout
729 ret=$?
730 if [ $ret -ne 0 ]; then
731 diff -u $testroot/stdout.expected $testroot/stdout
732 fi
733 test_done "$testroot" "$ret"
736 test_unstage_patch_removed() {
737 local testroot=`test_init unstage_patch_removed`
738 local commit_id=`git_show_head $testroot/repo`
740 got checkout $testroot/repo $testroot/wt > /dev/null
741 ret=$?
742 if [ $ret -ne 0 ]; then
743 test_done "$testroot" "$ret"
744 return 1
745 fi
747 (cd $testroot/wt && got rm beta > /dev/null)
748 (cd $testroot/wt && got stage > /dev/null)
750 printf "y\n" > $testroot/patchscript
751 (cd $testroot/wt && got unstage -F $testroot/patchscript -p \
752 beta > $testroot/stdout)
754 echo "D beta" > $testroot/stdout.expected
755 echo "unstage this deletion? [y/n] y" >> $testroot/stdout.expected
756 echo "D beta" >> $testroot/stdout.expected
757 cmp -s $testroot/stdout.expected $testroot/stdout
758 ret=$?
759 if [ $ret -ne 0 ]; then
760 diff -u $testroot/stdout.expected $testroot/stdout
761 test_done "$testroot" "$ret"
762 return 1
763 fi
765 (cd $testroot/wt && got status > $testroot/stdout)
766 echo "D beta" > $testroot/stdout.expected
767 cmp -s $testroot/stdout.expected $testroot/stdout
768 ret=$?
769 if [ $ret -ne 0 ]; then
770 diff -u $testroot/stdout.expected $testroot/stdout
771 test_done "$testroot" "$ret"
772 return 1
773 fi
775 (cd $testroot/wt && got diff -s > $testroot/stdout)
776 echo -n > $testroot/stdout.expected
777 cmp -s $testroot/stdout.expected $testroot/stdout
778 ret=$?
779 if [ $ret -ne 0 ]; then
780 diff -u $testroot/stdout.expected $testroot/stdout
781 test_done "$testroot" "$ret"
782 return 1
783 fi
785 (cd $testroot/wt && got diff > $testroot/stdout)
787 echo "diff $commit_id $testroot/wt" \
788 > $testroot/stdout.expected
789 echo -n 'blob - ' >> $testroot/stdout.expected
790 got tree -r $testroot/repo -i | grep 'beta$' | cut -d' ' -f 1 \
791 >> $testroot/stdout.expected
792 echo 'file + /dev/null' >> $testroot/stdout.expected
793 echo "--- beta" >> $testroot/stdout.expected
794 echo "+++ /dev/null" >> $testroot/stdout.expected
795 echo "@@ -1 +0,0 @@" >> $testroot/stdout.expected
796 echo "-beta" >> $testroot/stdout.expected
797 cmp -s $testroot/stdout.expected $testroot/stdout
798 ret=$?
799 if [ $ret -ne 0 ]; then
800 diff -u $testroot/stdout.expected $testroot/stdout
801 fi
802 test_done "$testroot" "$ret"
805 test_unstage_patch_quit() {
806 local testroot=`test_init unstage_patch_quit`
808 jot 16 > $testroot/repo/numbers
809 echo zzz > $testroot/repo/zzz
810 (cd $testroot/repo && git add numbers zzz)
811 git_commit $testroot/repo -m "added files"
812 local commit_id=`git_show_head $testroot/repo`
814 got checkout $testroot/repo $testroot/wt > /dev/null
815 ret=$?
816 if [ $ret -ne 0 ]; then
817 test_done "$testroot" "$ret"
818 return 1
819 fi
821 sed -i -e 's/^2$/a/' $testroot/wt/numbers
822 sed -i -e 's/^7$/b/' $testroot/wt/numbers
823 sed -i -e 's/^16$/c/' $testroot/wt/numbers
824 (cd $testroot/wt && got rm zzz > /dev/null)
825 (cd $testroot/wt && got stage > /dev/null)
827 # unstage first hunk and quit; and don't pass a path argument to
828 # ensure that we don't skip asking about the 'zzz' file after 'quit'
829 printf "y\nq\nn\n" > $testroot/patchscript
830 (cd $testroot/wt && got unstage -F $testroot/patchscript -p \
831 > $testroot/stdout)
832 ret=$?
833 if [ $ret -ne 0 ]; then
834 echo "got unstage command failed unexpectedly" >&2
835 test_done "$testroot" "1"
836 return 1
837 fi
838 cat > $testroot/stdout.expected <<EOF
839 -----------------------------------------------
840 @@ -1,5 +1,5 @@
842 -2
843 +a
847 -----------------------------------------------
848 M numbers (change 1 of 3)
849 unstage this change? [y/n/q] y
850 -----------------------------------------------
851 @@ -4,7 +4,7 @@
855 -7
856 +b
859 10
860 -----------------------------------------------
861 M numbers (change 2 of 3)
862 unstage this change? [y/n/q] q
863 G numbers
864 D zzz
865 unstage this deletion? [y/n] n
866 EOF
867 cmp -s $testroot/stdout.expected $testroot/stdout
868 ret=$?
869 if [ $ret -ne 0 ]; then
870 diff -u $testroot/stdout.expected $testroot/stdout
871 test_done "$testroot" "$ret"
872 return 1
873 fi
875 (cd $testroot/wt && got status > $testroot/stdout)
876 echo "MM numbers" > $testroot/stdout.expected
877 echo " D zzz" >> $testroot/stdout.expected
878 cmp -s $testroot/stdout.expected $testroot/stdout
879 ret=$?
880 if [ $ret -ne 0 ]; then
881 diff -u $testroot/stdout.expected $testroot/stdout
882 test_done "$testroot" "$ret"
883 return 1
884 fi
886 (cd $testroot/wt && got diff > $testroot/stdout)
888 echo "diff $commit_id $testroot/wt" > $testroot/stdout.expected
889 echo -n 'blob - ' >> $testroot/stdout.expected
890 (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 | \
891 tr -d '\n' >> $testroot/stdout.expected
892 echo " (staged)" >> $testroot/stdout.expected
893 echo "file + numbers" >> $testroot/stdout.expected
894 echo "--- numbers" >> $testroot/stdout.expected
895 echo "+++ numbers" >> $testroot/stdout.expected
896 echo "@@ -1,5 +1,5 @@" >> $testroot/stdout.expected
897 echo " 1" >> $testroot/stdout.expected
898 echo "-2" >> $testroot/stdout.expected
899 echo "+a" >> $testroot/stdout.expected
900 echo " 3" >> $testroot/stdout.expected
901 echo " 4" >> $testroot/stdout.expected
902 echo " 5" >> $testroot/stdout.expected
903 cmp -s $testroot/stdout.expected $testroot/stdout
904 ret=$?
905 if [ $ret -ne 0 ]; then
906 diff -u $testroot/stdout.expected $testroot/stdout
907 test_done "$testroot" "$ret"
908 return 1
909 fi
911 (cd $testroot/wt && got diff -s > $testroot/stdout)
912 echo "diff $commit_id $testroot/wt (staged changes)" \
913 > $testroot/stdout.expected
914 echo -n 'blob - ' >> $testroot/stdout.expected
915 got tree -r $testroot/repo -i -c $commit_id \
916 | grep 'numbers$' | cut -d' ' -f 1 \
917 >> $testroot/stdout.expected
918 echo -n 'blob + ' >> $testroot/stdout.expected
919 (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 \
920 >> $testroot/stdout.expected
921 cat >> $testroot/stdout.expected <<EOF
922 --- numbers
923 +++ numbers
924 @@ -4,7 +4,7 @@
928 -7
929 +b
932 10
933 @@ -13,4 +13,4 @@
934 13
935 14
936 15
937 -16
938 +c
939 EOF
940 echo -n 'blob - ' >> $testroot/stdout.expected
941 got tree -r $testroot/repo -i | grep 'zzz$' | cut -d' ' -f 1 \
942 >> $testroot/stdout.expected
943 echo 'blob + /dev/null' >> $testroot/stdout.expected
944 echo "--- zzz" >> $testroot/stdout.expected
945 echo "+++ /dev/null" >> $testroot/stdout.expected
946 echo "@@ -1 +0,0 @@" >> $testroot/stdout.expected
947 echo "-zzz" >> $testroot/stdout.expected
948 cmp -s $testroot/stdout.expected $testroot/stdout
949 ret=$?
950 if [ $ret -ne 0 ]; then
951 diff -u $testroot/stdout.expected $testroot/stdout
952 fi
953 test_done "$testroot" "$ret"
956 test_unstage_symlink() {
957 local testroot=`test_init unstage_symlink`
959 (cd $testroot/repo && ln -s alpha alpha.link)
960 (cd $testroot/repo && ln -s epsilon epsilon.link)
961 (cd $testroot/repo && ln -s /etc/passwd passwd.link)
962 (cd $testroot/repo && ln -s ../beta epsilon/beta.link)
963 (cd $testroot/repo && ln -s nonexistent nonexistent.link)
964 (cd $testroot/repo && git add .)
965 git_commit $testroot/repo -m "add symlinks"
966 local head_commit=`git_show_head $testroot/repo`
968 got checkout $testroot/repo $testroot/wt > /dev/null
969 ret=$?
970 if [ $ret -ne 0 ]; then
971 test_done "$testroot" "$ret"
972 return 1
973 fi
975 (cd $testroot/wt && ln -sf beta alpha.link)
976 (cd $testroot/wt && ln -sfh gamma epsilon.link)
977 (cd $testroot/wt && ln -sf ../gamma/delta epsilon/beta.link)
978 echo 'this is regular file foo' > $testroot/wt/dotgotfoo.link
979 (cd $testroot/wt && got add dotgotfoo.link > /dev/null)
980 (cd $testroot/wt && ln -sf .got/bar dotgotbar.link)
981 (cd $testroot/wt && got add dotgotbar.link > /dev/null)
982 (cd $testroot/wt && got rm nonexistent.link > /dev/null)
983 (cd $testroot/wt && ln -sf gamma/delta zeta.link)
984 (cd $testroot/wt && got add zeta.link > /dev/null)
986 (cd $testroot/wt && got stage -S > /dev/null)
988 (cd $testroot/wt && got status > $testroot/stdout)
989 cat > $testroot/stdout.expected <<EOF
990 M alpha.link
991 A dotgotbar.link
992 A dotgotfoo.link
993 M epsilon/beta.link
994 M epsilon.link
995 D nonexistent.link
996 A zeta.link
997 EOF
998 cmp -s $testroot/stdout.expected $testroot/stdout
999 ret=$?
1000 if [ $ret -ne 0 ]; then
1001 diff -u $testroot/stdout.expected $testroot/stdout
1002 test_done "$testroot" "$ret"
1003 return 1
1006 (cd $testroot/wt && got unstage > $testroot/stdout)
1007 ret=$?
1008 if [ $ret -ne 0 ]; then
1009 echo "got unstage command failed unexpectedly" >&2
1010 test_done "$testroot" "1"
1011 return 1
1014 cat > $testroot/stdout.expected <<EOF
1015 G alpha.link
1016 G dotgotbar.link
1017 G dotgotfoo.link
1018 G epsilon/beta.link
1019 G epsilon.link
1020 D nonexistent.link
1021 G zeta.link
1022 EOF
1024 cmp -s $testroot/stdout.expected $testroot/stdout
1025 ret=$?
1026 if [ $ret -ne 0 ]; then
1027 diff -u $testroot/stdout.expected $testroot/stdout
1028 test_done "$testroot" "$ret"
1029 return 1
1032 if [ ! -h $testroot/wt/alpha.link ]; then
1033 echo "alpha.link is not a symlink"
1034 test_done "$testroot" "1"
1035 return 1
1038 readlink $testroot/wt/alpha.link > $testroot/stdout
1039 echo "beta" > $testroot/stdout.expected
1040 cmp -s $testroot/stdout.expected $testroot/stdout
1041 ret=$?
1042 if [ $ret -ne 0 ]; then
1043 diff -u $testroot/stdout.expected $testroot/stdout
1044 test_done "$testroot" "$ret"
1045 return 1
1048 if [ ! -h $testroot/wt/epsilon.link ]; then
1049 echo "epsilon.link is not a symlink"
1050 test_done "$testroot" "1"
1051 return 1
1054 readlink $testroot/wt/epsilon.link > $testroot/stdout
1055 echo "gamma" > $testroot/stdout.expected
1056 cmp -s $testroot/stdout.expected $testroot/stdout
1057 ret=$?
1058 if [ $ret -ne 0 ]; then
1059 diff -u $testroot/stdout.expected $testroot/stdout
1060 test_done "$testroot" "$ret"
1061 return 1
1064 if [ ! -h $testroot/wt/epsilon/beta.link ]; then
1065 echo "epsilon/beta.link is not a symlink"
1066 test_done "$testroot" "1"
1067 return 1
1070 readlink $testroot/wt/epsilon/beta.link > $testroot/stdout
1071 echo "../gamma/delta" > $testroot/stdout.expected
1072 cmp -s $testroot/stdout.expected $testroot/stdout
1073 ret=$?
1074 if [ $ret -ne 0 ]; then
1075 diff -u $testroot/stdout.expected $testroot/stdout
1076 test_done "$testroot" "$ret"
1077 return 1
1080 if [ ! -f $testroot/wt/dotgotfoo.link ]; then
1081 echo "dotgotfoo.link is a symlink"
1082 test_done "$testroot" "1"
1083 return 1
1086 echo "this is regular file foo" > $testroot/content.expected
1087 cp $testroot/wt/dotgotfoo.link $testroot/content
1088 cmp -s $testroot/content.expected $testroot/content
1089 ret=$?
1090 if [ $ret -ne 0 ]; then
1091 diff -u $testroot/content.expected $testroot/content
1092 test_done "$testroot" "$ret"
1093 return 1
1096 # bad symlinks are allowed as-is for commit and stage/unstage
1097 if [ ! -h $testroot/wt/dotgotbar.link ]; then
1098 echo "dotgotbar.link is not a symlink"
1099 test_done "$testroot" "1"
1100 return 1
1103 readlink $testroot/wt/dotgotbar.link > $testroot/stdout
1104 echo ".got/bar" > $testroot/stdout.expected
1105 cmp -s $testroot/stdout.expected $testroot/stdout
1106 ret=$?
1107 if [ $ret -ne 0 ]; then
1108 diff -u $testroot/stdout.expected $testroot/stdout
1109 test_done "$testroot" "$ret"
1110 return 1
1113 if [ -e $testroot/wt/nonexistent.link ]; then
1114 echo "nonexistent.link exists on disk"
1115 test_done "$testroot" "1"
1116 return 1
1119 if [ ! -h $testroot/wt/zeta.link ]; then
1120 echo "zeta.link is not a symlink"
1121 test_done "$testroot" "1"
1122 return 1
1125 readlink $testroot/wt/zeta.link > $testroot/stdout
1126 echo "gamma/delta" > $testroot/stdout.expected
1127 cmp -s $testroot/stdout.expected $testroot/stdout
1128 ret=$?
1129 if [ $ret -ne 0 ]; then
1130 diff -u $testroot/stdout.expected $testroot/stdout
1131 test_done "$testroot" "$ret"
1132 return 1
1135 test_done "$testroot" "0"
1138 test_unstage_patch_symlink() {
1139 local testroot=`test_init unstage_patch_symlink`
1141 (cd $testroot/repo && ln -s alpha alpha.link)
1142 (cd $testroot/repo && ln -s epsilon epsilon.link)
1143 (cd $testroot/repo && ln -s /etc/passwd passwd.link)
1144 (cd $testroot/repo && ln -s ../beta epsilon/beta.link)
1145 (cd $testroot/repo && ln -s nonexistent nonexistent.link)
1146 (cd $testroot/repo && ln -sf epsilon/zeta zeta.link)
1147 (cd $testroot/repo && ln -sf epsilon/zeta zeta2.link)
1148 (cd $testroot/repo && git add .)
1149 git_commit $testroot/repo -m "add symlinks"
1150 local commit_id1=`git_show_head $testroot/repo`
1152 got checkout $testroot/repo $testroot/wt > /dev/null
1153 ret=$?
1154 if [ $ret -ne 0 ]; then
1155 test_done "$testroot" "$ret"
1156 return 1
1159 # symlink to file A now points to file B
1160 (cd $testroot/wt && ln -sf gamma/delta alpha.link)
1161 # symlink to a directory A now points to file B
1162 (cd $testroot/wt && ln -sfh beta epsilon.link)
1163 # "bad" symlink now contains a different target path
1164 echo "foo" > $testroot/wt/passwd.link
1165 # relative symlink to directory A now points to relative directory B
1166 (cd $testroot/wt && ln -sfh ../gamma epsilon/beta.link)
1167 # an unversioned symlink
1168 (cd $testroot/wt && ln -sf .got/foo dotgotfoo.link)
1169 # symlink to file A now points to non-existent file B
1170 (cd $testroot/wt && ln -sf nonexistent2 nonexistent.link)
1171 # removed symlink
1172 (cd $testroot/wt && got rm zeta.link > /dev/null)
1173 (cd $testroot/wt && got rm zeta2.link > /dev/null)
1174 # added symlink
1175 (cd $testroot/wt && ln -sf beta new.link)
1176 (cd $testroot/wt && got add new.link > /dev/null)
1177 (cd $testroot/wt && ln -sf beta zeta3.link)
1178 (cd $testroot/wt && got add zeta3.link > /dev/null)
1180 (cd $testroot/wt && got stage -S > /dev/null)
1182 (cd $testroot/wt && got status > $testroot/stdout)
1183 cat > $testroot/stdout.expected <<EOF
1184 M alpha.link
1185 ? dotgotfoo.link
1186 M epsilon/beta.link
1187 M epsilon.link
1188 A new.link
1189 M nonexistent.link
1190 M passwd.link
1191 D zeta.link
1192 D zeta2.link
1193 A zeta3.link
1194 EOF
1195 cmp -s $testroot/stdout.expected $testroot/stdout
1196 ret=$?
1197 if [ $ret -ne 0 ]; then
1198 diff -u $testroot/stdout.expected $testroot/stdout
1199 test_done "$testroot" "$ret"
1200 return 1
1203 printf "y\nn\ny\nn\ny\ny\nn\ny\ny\n" > $testroot/patchscript
1204 (cd $testroot/wt && got unstage -F $testroot/patchscript -p \
1205 > $testroot/stdout)
1206 ret=$?
1207 if [ $ret -ne 0 ]; then
1208 echo "got unstage command failed unexpectedly" >&2
1209 test_done "$testroot" "1"
1210 return 1
1213 cat > $testroot/stdout.expected <<EOF
1214 -----------------------------------------------
1215 @@ -1 +1 @@
1216 -alpha
1217 \ No newline at end of file
1218 +gamma/delta
1219 \ No newline at end of file
1220 -----------------------------------------------
1221 M alpha.link (change 1 of 1)
1222 unstage this change? [y/n/q] y
1223 G alpha.link
1224 -----------------------------------------------
1225 @@ -1 +1 @@
1226 -../beta
1227 \ No newline at end of file
1228 +../gamma
1229 \ No newline at end of file
1230 -----------------------------------------------
1231 M epsilon/beta.link (change 1 of 1)
1232 unstage this change? [y/n/q] n
1233 -----------------------------------------------
1234 @@ -1 +1 @@
1235 -epsilon
1236 \ No newline at end of file
1237 +beta
1238 \ No newline at end of file
1239 -----------------------------------------------
1240 M epsilon.link (change 1 of 1)
1241 unstage this change? [y/n/q] y
1242 G epsilon.link
1243 A new.link
1244 unstage this addition? [y/n] n
1245 -----------------------------------------------
1246 @@ -1 +1 @@
1247 -nonexistent
1248 \ No newline at end of file
1249 +nonexistent2
1250 \ No newline at end of file
1251 -----------------------------------------------
1252 M nonexistent.link (change 1 of 1)
1253 unstage this change? [y/n/q] y
1254 G nonexistent.link
1255 -----------------------------------------------
1256 @@ -1 +1 @@
1257 -/etc/passwd
1258 \ No newline at end of file
1259 +foo
1260 -----------------------------------------------
1261 M passwd.link (change 1 of 1)
1262 unstage this change? [y/n/q] y
1263 G passwd.link
1264 D zeta.link
1265 unstage this deletion? [y/n] n
1266 D zeta2.link
1267 unstage this deletion? [y/n] y
1268 D zeta2.link
1269 A zeta3.link
1270 unstage this addition? [y/n] y
1271 G zeta3.link
1272 EOF
1273 cmp -s $testroot/stdout.expected $testroot/stdout
1274 ret=$?
1275 if [ $ret -ne 0 ]; then
1276 diff -u $testroot/stdout.expected $testroot/stdout
1277 test_done "$testroot" "$ret"
1278 return 1
1281 if ! [ -h $testroot/wt/alpha.link ]; then
1282 echo "alpha.link is not a symlink"
1283 test_done "$testroot" "1"
1284 return 1
1287 readlink $testroot/wt/alpha.link > $testroot/stdout
1288 echo "gamma/delta" > $testroot/stdout.expected
1289 cmp -s $testroot/stdout.expected $testroot/stdout
1290 ret=$?
1291 if [ $ret -ne 0 ]; then
1292 diff -u $testroot/stdout.expected $testroot/stdout
1293 test_done "$testroot" "$ret"
1294 return 1
1297 if ! [ -h $testroot/wt/epsilon.link ]; then
1298 echo "epsilon.link is not a symlink"
1299 test_done "$testroot" "1"
1300 return 1
1303 readlink $testroot/wt/epsilon.link > $testroot/stdout
1304 echo "beta" > $testroot/stdout.expected
1305 cmp -s $testroot/stdout.expected $testroot/stdout
1306 ret=$?
1307 if [ $ret -ne 0 ]; then
1308 diff -u $testroot/stdout.expected $testroot/stdout
1309 test_done "$testroot" "$ret"
1310 return 1
1313 if [ -h $testroot/wt/passwd.link ]; then
1314 echo "passwd.link should not be a symlink" >&2
1315 test_done "$testroot" "1"
1316 return 1
1319 echo "foo" > $testroot/content.expected
1320 cp $testroot/wt/passwd.link $testroot/content
1322 cmp -s $testroot/content.expected $testroot/content
1323 ret=$?
1324 if [ $ret -ne 0 ]; then
1325 diff -u $testroot/content.expected $testroot/content
1326 test_done "$testroot" "$ret"
1327 return 1
1330 readlink $testroot/wt/epsilon/beta.link > $testroot/stdout
1331 echo "../gamma" > $testroot/stdout.expected
1332 cmp -s $testroot/stdout.expected $testroot/stdout
1333 ret=$?
1334 if [ $ret -ne 0 ]; then
1335 diff -u $testroot/stdout.expected $testroot/stdout
1336 test_done "$testroot" "$ret"
1337 return 1
1340 readlink $testroot/wt/nonexistent.link > $testroot/stdout
1341 echo "nonexistent2" > $testroot/stdout.expected
1342 cmp -s $testroot/stdout.expected $testroot/stdout
1343 ret=$?
1344 if [ $ret -ne 0 ]; then
1345 diff -u $testroot/stdout.expected $testroot/stdout
1346 test_done "$testroot" "$ret"
1347 return 1
1350 if [ ! -h $testroot/wt/dotgotfoo.link ]; then
1351 echo "dotgotfoo.link is not a symlink " >&2
1352 test_done "$testroot" "1"
1353 return 1
1355 readlink $testroot/wt/dotgotfoo.link > $testroot/stdout
1356 echo ".got/foo" > $testroot/stdout.expected
1357 cmp -s $testroot/stdout.expected $testroot/stdout
1358 ret=$?
1359 if [ $ret -ne 0 ]; then
1360 diff -u $testroot/stdout.expected $testroot/stdout
1361 test_done "$testroot" "$ret"
1362 return 1
1366 if [ -e $testroot/wt/zeta.link ]; then
1367 echo -n "zeta.link should not exist on disk" >&2
1368 test_done "$testroot" "1"
1369 return 1
1372 if [ -e $testroot/wt/zeta2.link ]; then
1373 echo -n "zeta2.link exists on disk" >&2
1374 test_done "$testroot" "1"
1375 return 1
1378 if [ ! -h $testroot/wt/zeta3.link ]; then
1379 echo -n "zeta3.link is not a symlink" >&2
1380 test_done "$testroot" "1"
1381 return 1
1384 readlink $testroot/wt/zeta3.link > $testroot/stdout
1385 echo "beta" > $testroot/stdout.expected
1386 cmp -s $testroot/stdout.expected $testroot/stdout
1387 ret=$?
1388 if [ $ret -ne 0 ]; then
1389 diff -u $testroot/stdout.expected $testroot/stdout
1390 test_done "$testroot" "$ret"
1391 return 1
1394 if [ ! -h $testroot/wt/new.link ]; then
1395 echo -n "new.link is not a symlink" >&2
1396 test_done "$testroot" "1"
1397 return 1
1400 (cd $testroot/wt && got status > $testroot/stdout)
1401 echo "M alpha.link" > $testroot/stdout.expected
1402 echo "? dotgotfoo.link" >> $testroot/stdout.expected
1403 echo " M epsilon/beta.link" >> $testroot/stdout.expected
1404 echo "M epsilon.link" >> $testroot/stdout.expected
1405 echo " A new.link" >> $testroot/stdout.expected
1406 echo "M nonexistent.link" >> $testroot/stdout.expected
1407 echo "M passwd.link" >> $testroot/stdout.expected
1408 echo " D zeta.link" >> $testroot/stdout.expected
1409 echo "D zeta2.link" >> $testroot/stdout.expected
1410 echo "A zeta3.link" >> $testroot/stdout.expected
1411 cmp -s $testroot/stdout.expected $testroot/stdout
1412 ret=$?
1413 if [ $ret -ne 0 ]; then
1414 diff -u $testroot/stdout.expected $testroot/stdout
1415 return 1
1417 test_done "$testroot" "$ret"
1420 test_parseargs "$@"
1421 run_test test_unstage_basic
1422 run_test test_unstage_unversioned
1423 run_test test_unstage_nonexistent
1424 run_test test_unstage_patch
1425 run_test test_unstage_patch_added
1426 run_test test_unstage_patch_removed
1427 run_test test_unstage_patch_quit
1428 run_test test_unstage_symlink
1429 run_test test_unstage_patch_symlink