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 -s $testroot/wt" > $testroot/stdout.expected
340 echo "commit - $commit_id" >> $testroot/stdout.expected
341 echo "path + $testroot/wt (staged changes)" >> $testroot/stdout.expected
342 echo -n 'blob - ' >> $testroot/stdout.expected
343 got tree -r $testroot/repo -i -c $commit_id \
344 | grep 'numbers$' | cut -d' ' -f 1 \
345 >> $testroot/stdout.expected
346 echo -n 'blob + ' >> $testroot/stdout.expected
347 (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 \
348 >> $testroot/stdout.expected
349 cat >> $testroot/stdout.expected <<EOF
350 --- numbers
351 +++ numbers
352 @@ -1,5 +1,5 @@
354 -2
355 +a
359 @@ -13,4 +13,4 @@
360 13
361 14
362 15
363 -16
364 +c
365 EOF
366 cmp -s $testroot/stdout.expected $testroot/stdout
367 ret=$?
368 if [ $ret -ne 0 ]; then
369 diff -u $testroot/stdout.expected $testroot/stdout
370 test_done "$testroot" "$ret"
371 return 1
372 fi
374 (cd $testroot/wt && got diff > $testroot/stdout)
375 echo "diff $testroot/wt" > $testroot/stdout.expected
376 echo "commit - $commit_id" >> $testroot/stdout.expected
377 echo "path + $testroot/wt" >> $testroot/stdout.expected
378 echo -n 'blob - ' >> $testroot/stdout.expected
379 (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 | \
380 tr -d '\n' >> $testroot/stdout.expected
381 echo " (staged)" >> $testroot/stdout.expected
382 echo "file + numbers" >> $testroot/stdout.expected
383 cat >> $testroot/stdout.expected <<EOF
384 --- numbers
385 +++ numbers
386 @@ -4,7 +4,7 @@ a
390 -7
391 +b
394 10
395 EOF
396 cmp -s $testroot/stdout.expected $testroot/stdout
397 ret=$?
398 if [ $ret -ne 0 ]; then
399 diff -u $testroot/stdout.expected $testroot/stdout
400 test_done "$testroot" "$ret"
401 return 1
402 fi
404 (cd $testroot/wt && got stage >/dev/null)
405 ret=$?
406 if [ $ret -ne 0 ]; then
407 echo "got stage command failed unexpectedly" >&2
408 test_done "$testroot" "1"
409 return 1
410 fi
412 (cd $testroot/wt && got status > $testroot/stdout)
413 echo " M numbers" > $testroot/stdout.expected
414 cmp -s $testroot/stdout.expected $testroot/stdout
415 ret=$?
416 if [ $ret -ne 0 ]; then
417 diff -u $testroot/stdout.expected $testroot/stdout
418 test_done "$testroot" "$ret"
419 return 1
420 fi
422 # unstage last hunk
423 printf "n\nn\ny\n" > $testroot/patchscript
424 (cd $testroot/wt && got unstage -F $testroot/patchscript -p \
425 numbers > $testroot/stdout)
427 cat > $testroot/stdout.expected <<EOF
428 -----------------------------------------------
429 @@ -1,5 +1,5 @@
431 -2
432 +a
436 -----------------------------------------------
437 M numbers (change 1 of 3)
438 unstage this change? [y/n/q] n
439 -----------------------------------------------
440 @@ -4,7 +4,7 @@
444 -7
445 +b
448 10
449 -----------------------------------------------
450 M numbers (change 2 of 3)
451 unstage this change? [y/n/q] n
452 -----------------------------------------------
453 @@ -13,4 +13,4 @@
454 13
455 14
456 15
457 -16
458 +c
459 -----------------------------------------------
460 M numbers (change 3 of 3)
461 unstage this change? [y/n/q] y
462 G numbers
463 EOF
464 cmp -s $testroot/stdout.expected $testroot/stdout
465 ret=$?
466 if [ $ret -ne 0 ]; then
467 diff -u $testroot/stdout.expected $testroot/stdout
468 test_done "$testroot" "$ret"
469 return 1
470 fi
472 (cd $testroot/wt && got status > $testroot/stdout)
473 echo "MM numbers" > $testroot/stdout.expected
474 cmp -s $testroot/stdout.expected $testroot/stdout
475 ret=$?
476 if [ $ret -ne 0 ]; then
477 diff -u $testroot/stdout.expected $testroot/stdout
478 test_done "$testroot" "$ret"
479 return 1
480 fi
482 (cd $testroot/wt && got diff -s > $testroot/stdout)
484 echo "diff -s $testroot/wt" > $testroot/stdout.expected
485 echo "commit - $commit_id" >> $testroot/stdout.expected
486 echo "path + $testroot/wt (staged changes)" >> $testroot/stdout.expected
487 echo -n 'blob - ' >> $testroot/stdout.expected
488 got tree -r $testroot/repo -i -c $commit_id \
489 | grep 'numbers$' | cut -d' ' -f 1 \
490 >> $testroot/stdout.expected
491 echo -n 'blob + ' >> $testroot/stdout.expected
492 (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 \
493 >> $testroot/stdout.expected
494 cat >> $testroot/stdout.expected <<EOF
495 --- numbers
496 +++ numbers
497 @@ -1,10 +1,10 @@
499 -2
500 +a
505 -7
506 +b
509 10
510 EOF
511 cmp -s $testroot/stdout.expected $testroot/stdout
512 ret=$?
513 if [ $ret -ne 0 ]; then
514 diff -u $testroot/stdout.expected $testroot/stdout
515 test_done "$testroot" "$ret"
516 return 1
517 fi
519 (cd $testroot/wt && got diff > $testroot/stdout)
520 echo "diff $testroot/wt" > $testroot/stdout.expected
521 echo "commit - $commit_id" >> $testroot/stdout.expected
522 echo "path + $testroot/wt" >> $testroot/stdout.expected
523 echo -n 'blob - ' >> $testroot/stdout.expected
524 (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 | \
525 tr -d '\n' >> $testroot/stdout.expected
526 echo " (staged)" >> $testroot/stdout.expected
527 echo "file + numbers" >> $testroot/stdout.expected
528 cat >> $testroot/stdout.expected <<EOF
529 --- numbers
530 +++ numbers
531 @@ -13,4 +13,4 @@ b
532 13
533 14
534 15
535 -16
536 +c
537 EOF
538 cmp -s $testroot/stdout.expected $testroot/stdout
539 ret=$?
540 if [ $ret -ne 0 ]; then
541 diff -u $testroot/stdout.expected $testroot/stdout
542 test_done "$testroot" "$ret"
543 return 1
544 fi
546 (cd $testroot/wt && got stage >/dev/null)
547 ret=$?
548 if [ $ret -ne 0 ]; then
549 echo "got stage command failed unexpectedly" >&2
550 test_done "$testroot" "1"
551 return 1
552 fi
554 (cd $testroot/wt && got status > $testroot/stdout)
555 echo " M numbers" > $testroot/stdout.expected
556 cmp -s $testroot/stdout.expected $testroot/stdout
557 ret=$?
558 if [ $ret -ne 0 ]; then
559 diff -u $testroot/stdout.expected $testroot/stdout
560 test_done "$testroot" "$ret"
561 return 1
562 fi
564 # unstage all hunks
565 printf "y\ny\ny\n" > $testroot/patchscript
566 (cd $testroot/wt && got unstage -F $testroot/patchscript -p \
567 numbers > $testroot/stdout)
569 cat > $testroot/stdout.expected <<EOF
570 -----------------------------------------------
571 @@ -1,5 +1,5 @@
573 -2
574 +a
578 -----------------------------------------------
579 M numbers (change 1 of 3)
580 unstage this change? [y/n/q] y
581 -----------------------------------------------
582 @@ -4,7 +4,7 @@
586 -7
587 +b
590 10
591 -----------------------------------------------
592 M numbers (change 2 of 3)
593 unstage this change? [y/n/q] y
594 -----------------------------------------------
595 @@ -13,4 +13,4 @@
596 13
597 14
598 15
599 -16
600 +c
601 -----------------------------------------------
602 M numbers (change 3 of 3)
603 unstage this change? [y/n/q] y
604 G numbers
605 EOF
606 cmp -s $testroot/stdout.expected $testroot/stdout
607 ret=$?
608 if [ $ret -ne 0 ]; then
609 diff -u $testroot/stdout.expected $testroot/stdout
610 test_done "$testroot" "$ret"
611 return 1
612 fi
614 (cd $testroot/wt && got status > $testroot/stdout)
615 echo "M numbers" > $testroot/stdout.expected
616 cmp -s $testroot/stdout.expected $testroot/stdout
617 ret=$?
618 if [ $ret -ne 0 ]; then
619 diff -u $testroot/stdout.expected $testroot/stdout
620 test_done "$testroot" "$ret"
621 return 1
622 fi
624 (cd $testroot/wt && got diff -s > $testroot/stdout)
625 echo -n > $testroot/stdout.expected
626 cmp -s $testroot/stdout.expected $testroot/stdout
627 ret=$?
628 if [ $ret -ne 0 ]; then
629 diff -u $testroot/stdout.expected $testroot/stdout
630 test_done "$testroot" "$ret"
631 return 1
632 fi
634 (cd $testroot/wt && got diff > $testroot/stdout)
636 echo "diff $testroot/wt" > $testroot/stdout.expected
637 echo "commit - $commit_id" >> $testroot/stdout.expected
638 echo "path + $testroot/wt" >> $testroot/stdout.expected
639 echo -n 'blob - ' >> $testroot/stdout.expected
640 got tree -r $testroot/repo -i -c $commit_id \
641 | grep 'numbers$' | cut -d' ' -f 1 \
642 >> $testroot/stdout.expected
643 echo 'file + numbers' >> $testroot/stdout.expected
644 cat >> $testroot/stdout.expected <<EOF
645 --- numbers
646 +++ numbers
647 @@ -1,10 +1,10 @@
649 -2
650 +a
655 -7
656 +b
659 10
660 @@ -13,4 +13,4 @@
661 13
662 14
663 15
664 -16
665 +c
666 EOF
667 cmp -s $testroot/stdout.expected $testroot/stdout
668 ret=$?
669 if [ $ret -ne 0 ]; then
670 diff -u $testroot/stdout.expected $testroot/stdout
671 fi
672 test_done "$testroot" "$ret"
676 test_unstage_patch_added() {
677 local testroot=`test_init unstage_patch_added`
678 local commit_id=`git_show_head $testroot/repo`
680 got checkout $testroot/repo $testroot/wt > /dev/null
681 ret=$?
682 if [ $ret -ne 0 ]; then
683 test_done "$testroot" "$ret"
684 return 1
685 fi
687 echo "new" > $testroot/wt/epsilon/new
688 (cd $testroot/wt && got add epsilon/new > /dev/null)
690 (cd $testroot/wt && got stage > /dev/null)
692 printf "y\n" > $testroot/patchscript
693 (cd $testroot/wt && got unstage -F $testroot/patchscript -p \
694 epsilon/new > $testroot/stdout)
696 echo "A epsilon/new" > $testroot/stdout.expected
697 echo "unstage this addition? [y/n] y" >> $testroot/stdout.expected
698 echo "G epsilon/new" >> $testroot/stdout.expected
699 cmp -s $testroot/stdout.expected $testroot/stdout
700 ret=$?
701 if [ $ret -ne 0 ]; then
702 diff -u $testroot/stdout.expected $testroot/stdout
703 test_done "$testroot" "$ret"
704 return 1
705 fi
707 (cd $testroot/wt && got status > $testroot/stdout)
708 echo "A epsilon/new" > $testroot/stdout.expected
709 cmp -s $testroot/stdout.expected $testroot/stdout
710 ret=$?
711 if [ $ret -ne 0 ]; then
712 diff -u $testroot/stdout.expected $testroot/stdout
713 test_done "$testroot" "$ret"
714 return 1
715 fi
717 (cd $testroot/wt && got diff -s > $testroot/stdout)
718 echo -n > $testroot/stdout.expected
719 cmp -s $testroot/stdout.expected $testroot/stdout
720 ret=$?
721 if [ $ret -ne 0 ]; then
722 diff -u $testroot/stdout.expected $testroot/stdout
723 test_done "$testroot" "$ret"
724 return 1
725 fi
727 (cd $testroot/wt && got diff > $testroot/stdout)
729 echo "diff $testroot/wt" > $testroot/stdout.expected
730 echo "commit - $commit_id" >> $testroot/stdout.expected
731 echo "path + $testroot/wt" >> $testroot/stdout.expected
732 echo 'blob - /dev/null' >> $testroot/stdout.expected
733 echo 'file + epsilon/new (mode 644)' >> $testroot/stdout.expected
734 echo "--- /dev/null" >> $testroot/stdout.expected
735 echo "+++ epsilon/new" >> $testroot/stdout.expected
736 echo "@@ -0,0 +1 @@" >> $testroot/stdout.expected
737 echo "+new" >> $testroot/stdout.expected
738 cmp -s $testroot/stdout.expected $testroot/stdout
739 ret=$?
740 if [ $ret -ne 0 ]; then
741 diff -u $testroot/stdout.expected $testroot/stdout
742 fi
743 test_done "$testroot" "$ret"
746 test_unstage_patch_removed() {
747 local testroot=`test_init unstage_patch_removed`
748 local commit_id=`git_show_head $testroot/repo`
750 got checkout $testroot/repo $testroot/wt > /dev/null
751 ret=$?
752 if [ $ret -ne 0 ]; then
753 test_done "$testroot" "$ret"
754 return 1
755 fi
757 (cd $testroot/wt && got rm beta > /dev/null)
758 (cd $testroot/wt && got stage > /dev/null)
760 printf "y\n" > $testroot/patchscript
761 (cd $testroot/wt && got unstage -F $testroot/patchscript -p \
762 beta > $testroot/stdout)
764 echo "D beta" > $testroot/stdout.expected
765 echo "unstage this deletion? [y/n] y" >> $testroot/stdout.expected
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 status > $testroot/stdout)
776 echo "D beta" > $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 -s > $testroot/stdout)
786 echo -n > $testroot/stdout.expected
787 cmp -s $testroot/stdout.expected $testroot/stdout
788 ret=$?
789 if [ $ret -ne 0 ]; then
790 diff -u $testroot/stdout.expected $testroot/stdout
791 test_done "$testroot" "$ret"
792 return 1
793 fi
795 (cd $testroot/wt && got diff > $testroot/stdout)
797 echo "diff $testroot/wt" > $testroot/stdout.expected
798 echo "commit - $commit_id" >> $testroot/stdout.expected
799 echo "path + $testroot/wt" >> $testroot/stdout.expected
800 echo -n 'blob - ' >> $testroot/stdout.expected
801 got tree -r $testroot/repo -i | grep 'beta$' | cut -d' ' -f 1 \
802 >> $testroot/stdout.expected
803 echo 'file + /dev/null' >> $testroot/stdout.expected
804 echo "--- beta" >> $testroot/stdout.expected
805 echo "+++ /dev/null" >> $testroot/stdout.expected
806 echo "@@ -1 +0,0 @@" >> $testroot/stdout.expected
807 echo "-beta" >> $testroot/stdout.expected
808 cmp -s $testroot/stdout.expected $testroot/stdout
809 ret=$?
810 if [ $ret -ne 0 ]; then
811 diff -u $testroot/stdout.expected $testroot/stdout
812 fi
813 test_done "$testroot" "$ret"
816 test_unstage_patch_quit() {
817 local testroot=`test_init unstage_patch_quit`
819 jot 16 > $testroot/repo/numbers
820 echo zzz > $testroot/repo/zzz
821 (cd $testroot/repo && git add numbers zzz)
822 git_commit $testroot/repo -m "added files"
823 local commit_id=`git_show_head $testroot/repo`
825 got checkout $testroot/repo $testroot/wt > /dev/null
826 ret=$?
827 if [ $ret -ne 0 ]; then
828 test_done "$testroot" "$ret"
829 return 1
830 fi
832 sed -i -e 's/^2$/a/' $testroot/wt/numbers
833 sed -i -e 's/^7$/b/' $testroot/wt/numbers
834 sed -i -e 's/^16$/c/' $testroot/wt/numbers
835 (cd $testroot/wt && got rm zzz > /dev/null)
836 (cd $testroot/wt && got stage > /dev/null)
838 # unstage first hunk and quit; and don't pass a path argument to
839 # ensure that we don't skip asking about the 'zzz' file after 'quit'
840 printf "y\nq\nn\n" > $testroot/patchscript
841 (cd $testroot/wt && got unstage -F $testroot/patchscript -p \
842 > $testroot/stdout)
843 ret=$?
844 if [ $ret -ne 0 ]; then
845 echo "got unstage command failed unexpectedly" >&2
846 test_done "$testroot" "1"
847 return 1
848 fi
849 cat > $testroot/stdout.expected <<EOF
850 -----------------------------------------------
851 @@ -1,5 +1,5 @@
853 -2
854 +a
858 -----------------------------------------------
859 M numbers (change 1 of 3)
860 unstage this change? [y/n/q] y
861 -----------------------------------------------
862 @@ -4,7 +4,7 @@
866 -7
867 +b
870 10
871 -----------------------------------------------
872 M numbers (change 2 of 3)
873 unstage this change? [y/n/q] q
874 G numbers
875 D zzz
876 unstage this deletion? [y/n] n
877 EOF
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 status > $testroot/stdout)
887 echo "MM numbers" > $testroot/stdout.expected
888 echo " D zzz" >> $testroot/stdout.expected
889 cmp -s $testroot/stdout.expected $testroot/stdout
890 ret=$?
891 if [ $ret -ne 0 ]; then
892 diff -u $testroot/stdout.expected $testroot/stdout
893 test_done "$testroot" "$ret"
894 return 1
895 fi
897 (cd $testroot/wt && got diff > $testroot/stdout)
899 echo "diff $testroot/wt" > $testroot/stdout.expected
900 echo "commit - $commit_id" >> $testroot/stdout.expected
901 echo "path + $testroot/wt" >> $testroot/stdout.expected
902 echo -n 'blob - ' >> $testroot/stdout.expected
903 (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 | \
904 tr -d '\n' >> $testroot/stdout.expected
905 echo " (staged)" >> $testroot/stdout.expected
906 echo "file + numbers" >> $testroot/stdout.expected
907 echo "--- numbers" >> $testroot/stdout.expected
908 echo "+++ numbers" >> $testroot/stdout.expected
909 echo "@@ -1,5 +1,5 @@" >> $testroot/stdout.expected
910 echo " 1" >> $testroot/stdout.expected
911 echo "-2" >> $testroot/stdout.expected
912 echo "+a" >> $testroot/stdout.expected
913 echo " 3" >> $testroot/stdout.expected
914 echo " 4" >> $testroot/stdout.expected
915 echo " 5" >> $testroot/stdout.expected
916 cmp -s $testroot/stdout.expected $testroot/stdout
917 ret=$?
918 if [ $ret -ne 0 ]; then
919 diff -u $testroot/stdout.expected $testroot/stdout
920 test_done "$testroot" "$ret"
921 return 1
922 fi
924 (cd $testroot/wt && got diff -s > $testroot/stdout)
925 echo "diff -s $testroot/wt" > $testroot/stdout.expected
926 echo "commit - $commit_id" >> $testroot/stdout.expected
927 echo "path + $testroot/wt (staged changes)" >> $testroot/stdout.expected
928 echo -n 'blob - ' >> $testroot/stdout.expected
929 got tree -r $testroot/repo -i -c $commit_id \
930 | grep 'numbers$' | cut -d' ' -f 1 \
931 >> $testroot/stdout.expected
932 echo -n 'blob + ' >> $testroot/stdout.expected
933 (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 \
934 >> $testroot/stdout.expected
935 cat >> $testroot/stdout.expected <<EOF
936 --- numbers
937 +++ numbers
938 @@ -4,7 +4,7 @@
942 -7
943 +b
946 10
947 @@ -13,4 +13,4 @@
948 13
949 14
950 15
951 -16
952 +c
953 EOF
954 echo -n 'blob - ' >> $testroot/stdout.expected
955 got tree -r $testroot/repo -i | grep 'zzz$' | cut -d' ' -f 1 \
956 >> $testroot/stdout.expected
957 echo 'blob + /dev/null' >> $testroot/stdout.expected
958 echo "--- zzz" >> $testroot/stdout.expected
959 echo "+++ /dev/null" >> $testroot/stdout.expected
960 echo "@@ -1 +0,0 @@" >> $testroot/stdout.expected
961 echo "-zzz" >> $testroot/stdout.expected
962 cmp -s $testroot/stdout.expected $testroot/stdout
963 ret=$?
964 if [ $ret -ne 0 ]; then
965 diff -u $testroot/stdout.expected $testroot/stdout
966 fi
967 test_done "$testroot" "$ret"
970 test_unstage_symlink() {
971 local testroot=`test_init unstage_symlink`
973 (cd $testroot/repo && ln -s alpha alpha.link)
974 (cd $testroot/repo && ln -s epsilon epsilon.link)
975 (cd $testroot/repo && ln -s /etc/passwd passwd.link)
976 (cd $testroot/repo && ln -s ../beta epsilon/beta.link)
977 (cd $testroot/repo && ln -s nonexistent nonexistent.link)
978 (cd $testroot/repo && git add .)
979 git_commit $testroot/repo -m "add symlinks"
980 local head_commit=`git_show_head $testroot/repo`
982 got checkout $testroot/repo $testroot/wt > /dev/null
983 ret=$?
984 if [ $ret -ne 0 ]; then
985 test_done "$testroot" "$ret"
986 return 1
987 fi
989 (cd $testroot/wt && ln -sf beta alpha.link)
990 (cd $testroot/wt && ln -sfh gamma epsilon.link)
991 (cd $testroot/wt && ln -sf ../gamma/delta epsilon/beta.link)
992 echo 'this is regular file foo' > $testroot/wt/dotgotfoo.link
993 (cd $testroot/wt && got add dotgotfoo.link > /dev/null)
994 (cd $testroot/wt && ln -sf .got/bar dotgotbar.link)
995 (cd $testroot/wt && got add dotgotbar.link > /dev/null)
996 (cd $testroot/wt && got rm nonexistent.link > /dev/null)
997 (cd $testroot/wt && ln -sf gamma/delta zeta.link)
998 (cd $testroot/wt && got add zeta.link > /dev/null)
1000 (cd $testroot/wt && got stage -S > /dev/null)
1002 (cd $testroot/wt && got status > $testroot/stdout)
1003 cat > $testroot/stdout.expected <<EOF
1004 M alpha.link
1005 A dotgotbar.link
1006 A dotgotfoo.link
1007 M epsilon/beta.link
1008 M epsilon.link
1009 D nonexistent.link
1010 A zeta.link
1011 EOF
1012 cmp -s $testroot/stdout.expected $testroot/stdout
1013 ret=$?
1014 if [ $ret -ne 0 ]; then
1015 diff -u $testroot/stdout.expected $testroot/stdout
1016 test_done "$testroot" "$ret"
1017 return 1
1020 (cd $testroot/wt && got unstage > $testroot/stdout)
1021 ret=$?
1022 if [ $ret -ne 0 ]; then
1023 echo "got unstage command failed unexpectedly" >&2
1024 test_done "$testroot" "1"
1025 return 1
1028 cat > $testroot/stdout.expected <<EOF
1029 G alpha.link
1030 G dotgotbar.link
1031 G dotgotfoo.link
1032 G epsilon/beta.link
1033 G epsilon.link
1034 D nonexistent.link
1035 G zeta.link
1036 EOF
1038 cmp -s $testroot/stdout.expected $testroot/stdout
1039 ret=$?
1040 if [ $ret -ne 0 ]; then
1041 diff -u $testroot/stdout.expected $testroot/stdout
1042 test_done "$testroot" "$ret"
1043 return 1
1046 if [ ! -h $testroot/wt/alpha.link ]; then
1047 echo "alpha.link is not a symlink"
1048 test_done "$testroot" "1"
1049 return 1
1052 readlink $testroot/wt/alpha.link > $testroot/stdout
1053 echo "beta" > $testroot/stdout.expected
1054 cmp -s $testroot/stdout.expected $testroot/stdout
1055 ret=$?
1056 if [ $ret -ne 0 ]; then
1057 diff -u $testroot/stdout.expected $testroot/stdout
1058 test_done "$testroot" "$ret"
1059 return 1
1062 if [ ! -h $testroot/wt/epsilon.link ]; then
1063 echo "epsilon.link is not a symlink"
1064 test_done "$testroot" "1"
1065 return 1
1068 readlink $testroot/wt/epsilon.link > $testroot/stdout
1069 echo "gamma" > $testroot/stdout.expected
1070 cmp -s $testroot/stdout.expected $testroot/stdout
1071 ret=$?
1072 if [ $ret -ne 0 ]; then
1073 diff -u $testroot/stdout.expected $testroot/stdout
1074 test_done "$testroot" "$ret"
1075 return 1
1078 if [ ! -h $testroot/wt/epsilon/beta.link ]; then
1079 echo "epsilon/beta.link is not a symlink"
1080 test_done "$testroot" "1"
1081 return 1
1084 readlink $testroot/wt/epsilon/beta.link > $testroot/stdout
1085 echo "../gamma/delta" > $testroot/stdout.expected
1086 cmp -s $testroot/stdout.expected $testroot/stdout
1087 ret=$?
1088 if [ $ret -ne 0 ]; then
1089 diff -u $testroot/stdout.expected $testroot/stdout
1090 test_done "$testroot" "$ret"
1091 return 1
1094 if [ ! -f $testroot/wt/dotgotfoo.link ]; then
1095 echo "dotgotfoo.link is a symlink"
1096 test_done "$testroot" "1"
1097 return 1
1100 echo "this is regular file foo" > $testroot/content.expected
1101 cp $testroot/wt/dotgotfoo.link $testroot/content
1102 cmp -s $testroot/content.expected $testroot/content
1103 ret=$?
1104 if [ $ret -ne 0 ]; then
1105 diff -u $testroot/content.expected $testroot/content
1106 test_done "$testroot" "$ret"
1107 return 1
1110 # bad symlinks are allowed as-is for commit and stage/unstage
1111 if [ ! -h $testroot/wt/dotgotbar.link ]; then
1112 echo "dotgotbar.link is not a symlink"
1113 test_done "$testroot" "1"
1114 return 1
1117 readlink $testroot/wt/dotgotbar.link > $testroot/stdout
1118 echo ".got/bar" > $testroot/stdout.expected
1119 cmp -s $testroot/stdout.expected $testroot/stdout
1120 ret=$?
1121 if [ $ret -ne 0 ]; then
1122 diff -u $testroot/stdout.expected $testroot/stdout
1123 test_done "$testroot" "$ret"
1124 return 1
1127 if [ -e $testroot/wt/nonexistent.link ]; then
1128 echo "nonexistent.link exists on disk"
1129 test_done "$testroot" "1"
1130 return 1
1133 if [ ! -h $testroot/wt/zeta.link ]; then
1134 echo "zeta.link is not a symlink"
1135 test_done "$testroot" "1"
1136 return 1
1139 readlink $testroot/wt/zeta.link > $testroot/stdout
1140 echo "gamma/delta" > $testroot/stdout.expected
1141 cmp -s $testroot/stdout.expected $testroot/stdout
1142 ret=$?
1143 if [ $ret -ne 0 ]; then
1144 diff -u $testroot/stdout.expected $testroot/stdout
1145 test_done "$testroot" "$ret"
1146 return 1
1149 test_done "$testroot" "0"
1152 test_unstage_patch_symlink() {
1153 local testroot=`test_init unstage_patch_symlink`
1155 (cd $testroot/repo && ln -s alpha alpha.link)
1156 (cd $testroot/repo && ln -s epsilon epsilon.link)
1157 (cd $testroot/repo && ln -s /etc/passwd passwd.link)
1158 (cd $testroot/repo && ln -s ../beta epsilon/beta.link)
1159 (cd $testroot/repo && ln -s nonexistent nonexistent.link)
1160 (cd $testroot/repo && ln -sf epsilon/zeta zeta.link)
1161 (cd $testroot/repo && ln -sf epsilon/zeta zeta2.link)
1162 (cd $testroot/repo && git add .)
1163 git_commit $testroot/repo -m "add symlinks"
1164 local commit_id1=`git_show_head $testroot/repo`
1166 got checkout $testroot/repo $testroot/wt > /dev/null
1167 ret=$?
1168 if [ $ret -ne 0 ]; then
1169 test_done "$testroot" "$ret"
1170 return 1
1173 # symlink to file A now points to file B
1174 (cd $testroot/wt && ln -sf gamma/delta alpha.link)
1175 # symlink to a directory A now points to file B
1176 (cd $testroot/wt && ln -sfh beta epsilon.link)
1177 # "bad" symlink now contains a different target path
1178 echo "foo" > $testroot/wt/passwd.link
1179 # relative symlink to directory A now points to relative directory B
1180 (cd $testroot/wt && ln -sfh ../gamma epsilon/beta.link)
1181 # an unversioned symlink
1182 (cd $testroot/wt && ln -sf .got/foo dotgotfoo.link)
1183 # symlink to file A now points to non-existent file B
1184 (cd $testroot/wt && ln -sf nonexistent2 nonexistent.link)
1185 # removed symlink
1186 (cd $testroot/wt && got rm zeta.link > /dev/null)
1187 (cd $testroot/wt && got rm zeta2.link > /dev/null)
1188 # added symlink
1189 (cd $testroot/wt && ln -sf beta new.link)
1190 (cd $testroot/wt && got add new.link > /dev/null)
1191 (cd $testroot/wt && ln -sf beta zeta3.link)
1192 (cd $testroot/wt && got add zeta3.link > /dev/null)
1194 (cd $testroot/wt && got stage -S > /dev/null)
1196 (cd $testroot/wt && got status > $testroot/stdout)
1197 cat > $testroot/stdout.expected <<EOF
1198 M alpha.link
1199 ? dotgotfoo.link
1200 M epsilon/beta.link
1201 M epsilon.link
1202 A new.link
1203 M nonexistent.link
1204 M passwd.link
1205 D zeta.link
1206 D zeta2.link
1207 A zeta3.link
1208 EOF
1209 cmp -s $testroot/stdout.expected $testroot/stdout
1210 ret=$?
1211 if [ $ret -ne 0 ]; then
1212 diff -u $testroot/stdout.expected $testroot/stdout
1213 test_done "$testroot" "$ret"
1214 return 1
1217 printf "y\nn\ny\nn\ny\ny\nn\ny\ny\n" > $testroot/patchscript
1218 (cd $testroot/wt && got unstage -F $testroot/patchscript -p \
1219 > $testroot/stdout)
1220 ret=$?
1221 if [ $ret -ne 0 ]; then
1222 echo "got unstage command failed unexpectedly" >&2
1223 test_done "$testroot" "1"
1224 return 1
1227 cat > $testroot/stdout.expected <<EOF
1228 -----------------------------------------------
1229 @@ -1 +1 @@
1230 -alpha
1231 \ No newline at end of file
1232 +gamma/delta
1233 \ No newline at end of file
1234 -----------------------------------------------
1235 M alpha.link (change 1 of 1)
1236 unstage this change? [y/n/q] y
1237 G alpha.link
1238 -----------------------------------------------
1239 @@ -1 +1 @@
1240 -../beta
1241 \ No newline at end of file
1242 +../gamma
1243 \ No newline at end of file
1244 -----------------------------------------------
1245 M epsilon/beta.link (change 1 of 1)
1246 unstage this change? [y/n/q] n
1247 -----------------------------------------------
1248 @@ -1 +1 @@
1249 -epsilon
1250 \ No newline at end of file
1251 +beta
1252 \ No newline at end of file
1253 -----------------------------------------------
1254 M epsilon.link (change 1 of 1)
1255 unstage this change? [y/n/q] y
1256 G epsilon.link
1257 A new.link
1258 unstage this addition? [y/n] n
1259 -----------------------------------------------
1260 @@ -1 +1 @@
1261 -nonexistent
1262 \ No newline at end of file
1263 +nonexistent2
1264 \ No newline at end of file
1265 -----------------------------------------------
1266 M nonexistent.link (change 1 of 1)
1267 unstage this change? [y/n/q] y
1268 G nonexistent.link
1269 -----------------------------------------------
1270 @@ -1 +1 @@
1271 -/etc/passwd
1272 \ No newline at end of file
1273 +foo
1274 -----------------------------------------------
1275 M passwd.link (change 1 of 1)
1276 unstage this change? [y/n/q] y
1277 G passwd.link
1278 D zeta.link
1279 unstage this deletion? [y/n] n
1280 D zeta2.link
1281 unstage this deletion? [y/n] y
1282 D zeta2.link
1283 A zeta3.link
1284 unstage this addition? [y/n] y
1285 G zeta3.link
1286 EOF
1287 cmp -s $testroot/stdout.expected $testroot/stdout
1288 ret=$?
1289 if [ $ret -ne 0 ]; then
1290 diff -u $testroot/stdout.expected $testroot/stdout
1291 test_done "$testroot" "$ret"
1292 return 1
1295 if ! [ -h $testroot/wt/alpha.link ]; then
1296 echo "alpha.link is not a symlink"
1297 test_done "$testroot" "1"
1298 return 1
1301 readlink $testroot/wt/alpha.link > $testroot/stdout
1302 echo "gamma/delta" > $testroot/stdout.expected
1303 cmp -s $testroot/stdout.expected $testroot/stdout
1304 ret=$?
1305 if [ $ret -ne 0 ]; then
1306 diff -u $testroot/stdout.expected $testroot/stdout
1307 test_done "$testroot" "$ret"
1308 return 1
1311 if ! [ -h $testroot/wt/epsilon.link ]; then
1312 echo "epsilon.link is not a symlink"
1313 test_done "$testroot" "1"
1314 return 1
1317 readlink $testroot/wt/epsilon.link > $testroot/stdout
1318 echo "beta" > $testroot/stdout.expected
1319 cmp -s $testroot/stdout.expected $testroot/stdout
1320 ret=$?
1321 if [ $ret -ne 0 ]; then
1322 diff -u $testroot/stdout.expected $testroot/stdout
1323 test_done "$testroot" "$ret"
1324 return 1
1327 if [ -h $testroot/wt/passwd.link ]; then
1328 echo "passwd.link should not be a symlink" >&2
1329 test_done "$testroot" "1"
1330 return 1
1333 echo "foo" > $testroot/content.expected
1334 cp $testroot/wt/passwd.link $testroot/content
1336 cmp -s $testroot/content.expected $testroot/content
1337 ret=$?
1338 if [ $ret -ne 0 ]; then
1339 diff -u $testroot/content.expected $testroot/content
1340 test_done "$testroot" "$ret"
1341 return 1
1344 readlink $testroot/wt/epsilon/beta.link > $testroot/stdout
1345 echo "../gamma" > $testroot/stdout.expected
1346 cmp -s $testroot/stdout.expected $testroot/stdout
1347 ret=$?
1348 if [ $ret -ne 0 ]; then
1349 diff -u $testroot/stdout.expected $testroot/stdout
1350 test_done "$testroot" "$ret"
1351 return 1
1354 readlink $testroot/wt/nonexistent.link > $testroot/stdout
1355 echo "nonexistent2" > $testroot/stdout.expected
1356 cmp -s $testroot/stdout.expected $testroot/stdout
1357 ret=$?
1358 if [ $ret -ne 0 ]; then
1359 diff -u $testroot/stdout.expected $testroot/stdout
1360 test_done "$testroot" "$ret"
1361 return 1
1364 if [ ! -h $testroot/wt/dotgotfoo.link ]; then
1365 echo "dotgotfoo.link is not a symlink " >&2
1366 test_done "$testroot" "1"
1367 return 1
1369 readlink $testroot/wt/dotgotfoo.link > $testroot/stdout
1370 echo ".got/foo" > $testroot/stdout.expected
1371 cmp -s $testroot/stdout.expected $testroot/stdout
1372 ret=$?
1373 if [ $ret -ne 0 ]; then
1374 diff -u $testroot/stdout.expected $testroot/stdout
1375 test_done "$testroot" "$ret"
1376 return 1
1380 if [ -e $testroot/wt/zeta.link ]; then
1381 echo -n "zeta.link should not exist on disk" >&2
1382 test_done "$testroot" "1"
1383 return 1
1386 if [ -e $testroot/wt/zeta2.link ]; then
1387 echo -n "zeta2.link exists on disk" >&2
1388 test_done "$testroot" "1"
1389 return 1
1392 if [ ! -h $testroot/wt/zeta3.link ]; then
1393 echo -n "zeta3.link is not a symlink" >&2
1394 test_done "$testroot" "1"
1395 return 1
1398 readlink $testroot/wt/zeta3.link > $testroot/stdout
1399 echo "beta" > $testroot/stdout.expected
1400 cmp -s $testroot/stdout.expected $testroot/stdout
1401 ret=$?
1402 if [ $ret -ne 0 ]; then
1403 diff -u $testroot/stdout.expected $testroot/stdout
1404 test_done "$testroot" "$ret"
1405 return 1
1408 if [ ! -h $testroot/wt/new.link ]; then
1409 echo -n "new.link is not a symlink" >&2
1410 test_done "$testroot" "1"
1411 return 1
1414 (cd $testroot/wt && got status > $testroot/stdout)
1415 echo "M alpha.link" > $testroot/stdout.expected
1416 echo "? dotgotfoo.link" >> $testroot/stdout.expected
1417 echo " M epsilon/beta.link" >> $testroot/stdout.expected
1418 echo "M epsilon.link" >> $testroot/stdout.expected
1419 echo " A new.link" >> $testroot/stdout.expected
1420 echo "M nonexistent.link" >> $testroot/stdout.expected
1421 echo "M passwd.link" >> $testroot/stdout.expected
1422 echo " D zeta.link" >> $testroot/stdout.expected
1423 echo "D zeta2.link" >> $testroot/stdout.expected
1424 echo "A zeta3.link" >> $testroot/stdout.expected
1425 cmp -s $testroot/stdout.expected $testroot/stdout
1426 ret=$?
1427 if [ $ret -ne 0 ]; then
1428 diff -u $testroot/stdout.expected $testroot/stdout
1429 return 1
1431 test_done "$testroot" "$ret"
1434 test_parseargs "$@"
1435 run_test test_unstage_basic
1436 run_test test_unstage_unversioned
1437 run_test test_unstage_nonexistent
1438 run_test test_unstage_patch
1439 run_test test_unstage_patch_added
1440 run_test test_unstage_patch_removed
1441 run_test test_unstage_patch_quit
1442 run_test test_unstage_symlink
1443 run_test test_unstage_patch_symlink