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 ed -s $testroot/wt/numbers <<-\EOF
202 ,s/^2$/a/
203 ,s/^7$/b/
204 ,s/^16$/c/
206 EOF
208 (cd $testroot/wt && got stage > /dev/null)
209 ret=$?
210 if [ $ret -ne 0 ]; then
211 echo "got stage command failed unexpectedly" >&2
212 test_done "$testroot" "1"
213 return 1
214 fi
216 # don't unstage any hunks
217 printf "n\nn\nn\n" > $testroot/patchscript
218 (cd $testroot/wt && got unstage -F $testroot/patchscript -p \
219 numbers > $testroot/stdout)
220 ret=$?
221 if [ $ret -ne 0 ]; then
222 echo "got unstage command failed unexpectedly" >&2
223 test_done "$testroot" "1"
224 return 1
225 fi
226 cat > $testroot/stdout.expected <<EOF
227 -----------------------------------------------
228 @@ -1,5 +1,5 @@
230 -2
231 +a
235 -----------------------------------------------
236 M numbers (change 1 of 3)
237 unstage this change? [y/n/q] n
238 -----------------------------------------------
239 @@ -4,7 +4,7 @@
243 -7
244 +b
247 10
248 -----------------------------------------------
249 M numbers (change 2 of 3)
250 unstage this change? [y/n/q] n
251 -----------------------------------------------
252 @@ -13,4 +13,4 @@
253 13
254 14
255 15
256 -16
257 +c
258 -----------------------------------------------
259 M numbers (change 3 of 3)
260 unstage this change? [y/n/q] n
261 EOF
262 cmp -s $testroot/stdout.expected $testroot/stdout
263 ret=$?
264 if [ $ret -ne 0 ]; then
265 diff -u $testroot/stdout.expected $testroot/stdout
266 test_done "$testroot" "$ret"
267 return 1
268 fi
270 (cd $testroot/wt && got status > $testroot/stdout)
271 echo " M numbers" > $testroot/stdout.expected
272 cmp -s $testroot/stdout.expected $testroot/stdout
273 ret=$?
274 if [ $ret -ne 0 ]; then
275 diff -u $testroot/stdout.expected $testroot/stdout
276 test_done "$testroot" "$ret"
277 return 1
278 fi
280 # unstage middle hunk
281 printf "n\ny\nn\n" > $testroot/patchscript
282 (cd $testroot/wt && got unstage -F $testroot/patchscript -p \
283 numbers > $testroot/stdout)
285 cat > $testroot/stdout.expected <<EOF
286 -----------------------------------------------
287 @@ -1,5 +1,5 @@
289 -2
290 +a
294 -----------------------------------------------
295 M numbers (change 1 of 3)
296 unstage this change? [y/n/q] n
297 -----------------------------------------------
298 @@ -4,7 +4,7 @@
302 -7
303 +b
306 10
307 -----------------------------------------------
308 M numbers (change 2 of 3)
309 unstage this change? [y/n/q] y
310 -----------------------------------------------
311 @@ -13,4 +13,4 @@
312 13
313 14
314 15
315 -16
316 +c
317 -----------------------------------------------
318 M numbers (change 3 of 3)
319 unstage this change? [y/n/q] n
320 G numbers
321 EOF
322 cmp -s $testroot/stdout.expected $testroot/stdout
323 ret=$?
324 if [ $ret -ne 0 ]; then
325 diff -u $testroot/stdout.expected $testroot/stdout
326 test_done "$testroot" "$ret"
327 return 1
328 fi
330 (cd $testroot/wt && got status > $testroot/stdout)
331 echo "MM numbers" > $testroot/stdout.expected
332 cmp -s $testroot/stdout.expected $testroot/stdout
333 ret=$?
334 if [ $ret -ne 0 ]; then
335 diff -u $testroot/stdout.expected $testroot/stdout
336 test_done "$testroot" "$ret"
337 return 1
338 fi
340 (cd $testroot/wt && got diff -s > $testroot/stdout)
342 echo "diff -s $testroot/wt" > $testroot/stdout.expected
343 echo "commit - $commit_id" >> $testroot/stdout.expected
344 echo "path + $testroot/wt (staged changes)" >> $testroot/stdout.expected
345 echo -n 'blob - ' >> $testroot/stdout.expected
346 got tree -r $testroot/repo -i -c $commit_id \
347 | grep 'numbers$' | cut -d' ' -f 1 \
348 >> $testroot/stdout.expected
349 echo -n 'blob + ' >> $testroot/stdout.expected
350 (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 \
351 >> $testroot/stdout.expected
352 cat >> $testroot/stdout.expected <<EOF
353 --- numbers
354 +++ numbers
355 @@ -1,5 +1,5 @@
357 -2
358 +a
362 @@ -13,4 +13,4 @@
363 13
364 14
365 15
366 -16
367 +c
368 EOF
369 cmp -s $testroot/stdout.expected $testroot/stdout
370 ret=$?
371 if [ $ret -ne 0 ]; then
372 diff -u $testroot/stdout.expected $testroot/stdout
373 test_done "$testroot" "$ret"
374 return 1
375 fi
377 (cd $testroot/wt && got diff > $testroot/stdout)
378 echo "diff $testroot/wt" > $testroot/stdout.expected
379 echo "commit - $commit_id" >> $testroot/stdout.expected
380 echo "path + $testroot/wt" >> $testroot/stdout.expected
381 echo -n 'blob - ' >> $testroot/stdout.expected
382 (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 | \
383 tr -d '\n' >> $testroot/stdout.expected
384 echo " (staged)" >> $testroot/stdout.expected
385 echo "file + numbers" >> $testroot/stdout.expected
386 cat >> $testroot/stdout.expected <<EOF
387 --- numbers
388 +++ numbers
389 @@ -4,7 +4,7 @@ a
393 -7
394 +b
397 10
398 EOF
399 cmp -s $testroot/stdout.expected $testroot/stdout
400 ret=$?
401 if [ $ret -ne 0 ]; then
402 diff -u $testroot/stdout.expected $testroot/stdout
403 test_done "$testroot" "$ret"
404 return 1
405 fi
407 (cd $testroot/wt && got stage >/dev/null)
408 ret=$?
409 if [ $ret -ne 0 ]; then
410 echo "got stage command failed unexpectedly" >&2
411 test_done "$testroot" "1"
412 return 1
413 fi
415 (cd $testroot/wt && got status > $testroot/stdout)
416 echo " M numbers" > $testroot/stdout.expected
417 cmp -s $testroot/stdout.expected $testroot/stdout
418 ret=$?
419 if [ $ret -ne 0 ]; then
420 diff -u $testroot/stdout.expected $testroot/stdout
421 test_done "$testroot" "$ret"
422 return 1
423 fi
425 # unstage last hunk
426 printf "n\nn\ny\n" > $testroot/patchscript
427 (cd $testroot/wt && got unstage -F $testroot/patchscript -p \
428 numbers > $testroot/stdout)
430 cat > $testroot/stdout.expected <<EOF
431 -----------------------------------------------
432 @@ -1,5 +1,5 @@
434 -2
435 +a
439 -----------------------------------------------
440 M numbers (change 1 of 3)
441 unstage this change? [y/n/q] n
442 -----------------------------------------------
443 @@ -4,7 +4,7 @@
447 -7
448 +b
451 10
452 -----------------------------------------------
453 M numbers (change 2 of 3)
454 unstage this change? [y/n/q] n
455 -----------------------------------------------
456 @@ -13,4 +13,4 @@
457 13
458 14
459 15
460 -16
461 +c
462 -----------------------------------------------
463 M numbers (change 3 of 3)
464 unstage this change? [y/n/q] y
465 G numbers
466 EOF
467 cmp -s $testroot/stdout.expected $testroot/stdout
468 ret=$?
469 if [ $ret -ne 0 ]; then
470 diff -u $testroot/stdout.expected $testroot/stdout
471 test_done "$testroot" "$ret"
472 return 1
473 fi
475 (cd $testroot/wt && got status > $testroot/stdout)
476 echo "MM numbers" > $testroot/stdout.expected
477 cmp -s $testroot/stdout.expected $testroot/stdout
478 ret=$?
479 if [ $ret -ne 0 ]; then
480 diff -u $testroot/stdout.expected $testroot/stdout
481 test_done "$testroot" "$ret"
482 return 1
483 fi
485 (cd $testroot/wt && got diff -s > $testroot/stdout)
487 echo "diff -s $testroot/wt" > $testroot/stdout.expected
488 echo "commit - $commit_id" >> $testroot/stdout.expected
489 echo "path + $testroot/wt (staged changes)" >> $testroot/stdout.expected
490 echo -n 'blob - ' >> $testroot/stdout.expected
491 got tree -r $testroot/repo -i -c $commit_id \
492 | grep 'numbers$' | cut -d' ' -f 1 \
493 >> $testroot/stdout.expected
494 echo -n 'blob + ' >> $testroot/stdout.expected
495 (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 \
496 >> $testroot/stdout.expected
497 cat >> $testroot/stdout.expected <<EOF
498 --- numbers
499 +++ numbers
500 @@ -1,10 +1,10 @@
502 -2
503 +a
508 -7
509 +b
512 10
513 EOF
514 cmp -s $testroot/stdout.expected $testroot/stdout
515 ret=$?
516 if [ $ret -ne 0 ]; then
517 diff -u $testroot/stdout.expected $testroot/stdout
518 test_done "$testroot" "$ret"
519 return 1
520 fi
522 (cd $testroot/wt && got diff > $testroot/stdout)
523 echo "diff $testroot/wt" > $testroot/stdout.expected
524 echo "commit - $commit_id" >> $testroot/stdout.expected
525 echo "path + $testroot/wt" >> $testroot/stdout.expected
526 echo -n 'blob - ' >> $testroot/stdout.expected
527 (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 | \
528 tr -d '\n' >> $testroot/stdout.expected
529 echo " (staged)" >> $testroot/stdout.expected
530 echo "file + numbers" >> $testroot/stdout.expected
531 cat >> $testroot/stdout.expected <<EOF
532 --- numbers
533 +++ numbers
534 @@ -13,4 +13,4 @@ b
535 13
536 14
537 15
538 -16
539 +c
540 EOF
541 cmp -s $testroot/stdout.expected $testroot/stdout
542 ret=$?
543 if [ $ret -ne 0 ]; then
544 diff -u $testroot/stdout.expected $testroot/stdout
545 test_done "$testroot" "$ret"
546 return 1
547 fi
549 (cd $testroot/wt && got stage >/dev/null)
550 ret=$?
551 if [ $ret -ne 0 ]; then
552 echo "got stage command failed unexpectedly" >&2
553 test_done "$testroot" "1"
554 return 1
555 fi
557 (cd $testroot/wt && got status > $testroot/stdout)
558 echo " M numbers" > $testroot/stdout.expected
559 cmp -s $testroot/stdout.expected $testroot/stdout
560 ret=$?
561 if [ $ret -ne 0 ]; then
562 diff -u $testroot/stdout.expected $testroot/stdout
563 test_done "$testroot" "$ret"
564 return 1
565 fi
567 # unstage all hunks
568 printf "y\ny\ny\n" > $testroot/patchscript
569 (cd $testroot/wt && got unstage -F $testroot/patchscript -p \
570 numbers > $testroot/stdout)
572 cat > $testroot/stdout.expected <<EOF
573 -----------------------------------------------
574 @@ -1,5 +1,5 @@
576 -2
577 +a
581 -----------------------------------------------
582 M numbers (change 1 of 3)
583 unstage this change? [y/n/q] y
584 -----------------------------------------------
585 @@ -4,7 +4,7 @@
589 -7
590 +b
593 10
594 -----------------------------------------------
595 M numbers (change 2 of 3)
596 unstage this change? [y/n/q] y
597 -----------------------------------------------
598 @@ -13,4 +13,4 @@
599 13
600 14
601 15
602 -16
603 +c
604 -----------------------------------------------
605 M numbers (change 3 of 3)
606 unstage this change? [y/n/q] y
607 G numbers
608 EOF
609 cmp -s $testroot/stdout.expected $testroot/stdout
610 ret=$?
611 if [ $ret -ne 0 ]; then
612 diff -u $testroot/stdout.expected $testroot/stdout
613 test_done "$testroot" "$ret"
614 return 1
615 fi
617 (cd $testroot/wt && got status > $testroot/stdout)
618 echo "M numbers" > $testroot/stdout.expected
619 cmp -s $testroot/stdout.expected $testroot/stdout
620 ret=$?
621 if [ $ret -ne 0 ]; then
622 diff -u $testroot/stdout.expected $testroot/stdout
623 test_done "$testroot" "$ret"
624 return 1
625 fi
627 (cd $testroot/wt && got diff -s > $testroot/stdout)
628 echo -n > $testroot/stdout.expected
629 cmp -s $testroot/stdout.expected $testroot/stdout
630 ret=$?
631 if [ $ret -ne 0 ]; then
632 diff -u $testroot/stdout.expected $testroot/stdout
633 test_done "$testroot" "$ret"
634 return 1
635 fi
637 (cd $testroot/wt && got diff > $testroot/stdout)
639 echo "diff $testroot/wt" > $testroot/stdout.expected
640 echo "commit - $commit_id" >> $testroot/stdout.expected
641 echo "path + $testroot/wt" >> $testroot/stdout.expected
642 echo -n 'blob - ' >> $testroot/stdout.expected
643 got tree -r $testroot/repo -i -c $commit_id \
644 | grep 'numbers$' | cut -d' ' -f 1 \
645 >> $testroot/stdout.expected
646 echo 'file + numbers' >> $testroot/stdout.expected
647 cat >> $testroot/stdout.expected <<EOF
648 --- numbers
649 +++ numbers
650 @@ -1,10 +1,10 @@
652 -2
653 +a
658 -7
659 +b
662 10
663 @@ -13,4 +13,4 @@
664 13
665 14
666 15
667 -16
668 +c
669 EOF
670 cmp -s $testroot/stdout.expected $testroot/stdout
671 ret=$?
672 if [ $ret -ne 0 ]; then
673 diff -u $testroot/stdout.expected $testroot/stdout
674 fi
675 test_done "$testroot" "$ret"
679 test_unstage_patch_added() {
680 local testroot=`test_init unstage_patch_added`
681 local commit_id=`git_show_head $testroot/repo`
683 got checkout $testroot/repo $testroot/wt > /dev/null
684 ret=$?
685 if [ $ret -ne 0 ]; then
686 test_done "$testroot" "$ret"
687 return 1
688 fi
690 echo "new" > $testroot/wt/epsilon/new
691 (cd $testroot/wt && got add epsilon/new > /dev/null)
693 (cd $testroot/wt && got stage > /dev/null)
695 printf "y\n" > $testroot/patchscript
696 (cd $testroot/wt && got unstage -F $testroot/patchscript -p \
697 epsilon/new > $testroot/stdout)
699 echo "A epsilon/new" > $testroot/stdout.expected
700 echo "unstage this addition? [y/n] y" >> $testroot/stdout.expected
701 echo "G epsilon/new" >> $testroot/stdout.expected
702 cmp -s $testroot/stdout.expected $testroot/stdout
703 ret=$?
704 if [ $ret -ne 0 ]; then
705 diff -u $testroot/stdout.expected $testroot/stdout
706 test_done "$testroot" "$ret"
707 return 1
708 fi
710 (cd $testroot/wt && got status > $testroot/stdout)
711 echo "A epsilon/new" > $testroot/stdout.expected
712 cmp -s $testroot/stdout.expected $testroot/stdout
713 ret=$?
714 if [ $ret -ne 0 ]; then
715 diff -u $testroot/stdout.expected $testroot/stdout
716 test_done "$testroot" "$ret"
717 return 1
718 fi
720 (cd $testroot/wt && got diff -s > $testroot/stdout)
721 echo -n > $testroot/stdout.expected
722 cmp -s $testroot/stdout.expected $testroot/stdout
723 ret=$?
724 if [ $ret -ne 0 ]; then
725 diff -u $testroot/stdout.expected $testroot/stdout
726 test_done "$testroot" "$ret"
727 return 1
728 fi
730 (cd $testroot/wt && got diff > $testroot/stdout)
732 echo "diff $testroot/wt" > $testroot/stdout.expected
733 echo "commit - $commit_id" >> $testroot/stdout.expected
734 echo "path + $testroot/wt" >> $testroot/stdout.expected
735 echo 'blob - /dev/null' >> $testroot/stdout.expected
736 echo 'file + epsilon/new (mode 644)' >> $testroot/stdout.expected
737 echo "--- /dev/null" >> $testroot/stdout.expected
738 echo "+++ epsilon/new" >> $testroot/stdout.expected
739 echo "@@ -0,0 +1 @@" >> $testroot/stdout.expected
740 echo "+new" >> $testroot/stdout.expected
741 cmp -s $testroot/stdout.expected $testroot/stdout
742 ret=$?
743 if [ $ret -ne 0 ]; then
744 diff -u $testroot/stdout.expected $testroot/stdout
745 fi
746 test_done "$testroot" "$ret"
749 test_unstage_patch_removed() {
750 local testroot=`test_init unstage_patch_removed`
751 local commit_id=`git_show_head $testroot/repo`
753 got checkout $testroot/repo $testroot/wt > /dev/null
754 ret=$?
755 if [ $ret -ne 0 ]; then
756 test_done "$testroot" "$ret"
757 return 1
758 fi
760 (cd $testroot/wt && got rm beta > /dev/null)
761 (cd $testroot/wt && got stage > /dev/null)
763 printf "y\n" > $testroot/patchscript
764 (cd $testroot/wt && got unstage -F $testroot/patchscript -p \
765 beta > $testroot/stdout)
767 echo "D beta" > $testroot/stdout.expected
768 echo "unstage this deletion? [y/n] y" >> $testroot/stdout.expected
769 echo "D beta" >> $testroot/stdout.expected
770 cmp -s $testroot/stdout.expected $testroot/stdout
771 ret=$?
772 if [ $ret -ne 0 ]; then
773 diff -u $testroot/stdout.expected $testroot/stdout
774 test_done "$testroot" "$ret"
775 return 1
776 fi
778 (cd $testroot/wt && got status > $testroot/stdout)
779 echo "D beta" > $testroot/stdout.expected
780 cmp -s $testroot/stdout.expected $testroot/stdout
781 ret=$?
782 if [ $ret -ne 0 ]; then
783 diff -u $testroot/stdout.expected $testroot/stdout
784 test_done "$testroot" "$ret"
785 return 1
786 fi
788 (cd $testroot/wt && got diff -s > $testroot/stdout)
789 echo -n > $testroot/stdout.expected
790 cmp -s $testroot/stdout.expected $testroot/stdout
791 ret=$?
792 if [ $ret -ne 0 ]; then
793 diff -u $testroot/stdout.expected $testroot/stdout
794 test_done "$testroot" "$ret"
795 return 1
796 fi
798 (cd $testroot/wt && got diff > $testroot/stdout)
800 echo "diff $testroot/wt" > $testroot/stdout.expected
801 echo "commit - $commit_id" >> $testroot/stdout.expected
802 echo "path + $testroot/wt" >> $testroot/stdout.expected
803 echo -n 'blob - ' >> $testroot/stdout.expected
804 got tree -r $testroot/repo -i | grep 'beta$' | cut -d' ' -f 1 \
805 >> $testroot/stdout.expected
806 echo 'file + /dev/null' >> $testroot/stdout.expected
807 echo "--- beta" >> $testroot/stdout.expected
808 echo "+++ /dev/null" >> $testroot/stdout.expected
809 echo "@@ -1 +0,0 @@" >> $testroot/stdout.expected
810 echo "-beta" >> $testroot/stdout.expected
811 cmp -s $testroot/stdout.expected $testroot/stdout
812 ret=$?
813 if [ $ret -ne 0 ]; then
814 diff -u $testroot/stdout.expected $testroot/stdout
815 fi
816 test_done "$testroot" "$ret"
819 test_unstage_patch_quit() {
820 local testroot=`test_init unstage_patch_quit`
822 jot 16 > $testroot/repo/numbers
823 echo zzz > $testroot/repo/zzz
824 (cd $testroot/repo && git add numbers zzz)
825 git_commit $testroot/repo -m "added files"
826 local commit_id=`git_show_head $testroot/repo`
828 got checkout $testroot/repo $testroot/wt > /dev/null
829 ret=$?
830 if [ $ret -ne 0 ]; then
831 test_done "$testroot" "$ret"
832 return 1
833 fi
835 ed -s $testroot/wt/numbers <<-\EOF
836 ,s/^2$/a/
837 ,s/^7$/b/
838 ,s/^16$/c/
840 EOF
841 (cd $testroot/wt && got rm zzz > /dev/null)
842 (cd $testroot/wt && got stage > /dev/null)
844 # unstage first hunk and quit; and don't pass a path argument to
845 # ensure that we don't skip asking about the 'zzz' file after 'quit'
846 printf "y\nq\nn\n" > $testroot/patchscript
847 (cd $testroot/wt && got unstage -F $testroot/patchscript -p \
848 > $testroot/stdout)
849 ret=$?
850 if [ $ret -ne 0 ]; then
851 echo "got unstage command failed unexpectedly" >&2
852 test_done "$testroot" "1"
853 return 1
854 fi
855 cat > $testroot/stdout.expected <<EOF
856 -----------------------------------------------
857 @@ -1,5 +1,5 @@
859 -2
860 +a
864 -----------------------------------------------
865 M numbers (change 1 of 3)
866 unstage this change? [y/n/q] y
867 -----------------------------------------------
868 @@ -4,7 +4,7 @@
872 -7
873 +b
876 10
877 -----------------------------------------------
878 M numbers (change 2 of 3)
879 unstage this change? [y/n/q] q
880 G numbers
881 D zzz
882 unstage this deletion? [y/n] n
883 EOF
884 cmp -s $testroot/stdout.expected $testroot/stdout
885 ret=$?
886 if [ $ret -ne 0 ]; then
887 diff -u $testroot/stdout.expected $testroot/stdout
888 test_done "$testroot" "$ret"
889 return 1
890 fi
892 (cd $testroot/wt && got status > $testroot/stdout)
893 echo "MM numbers" > $testroot/stdout.expected
894 echo " D zzz" >> $testroot/stdout.expected
895 cmp -s $testroot/stdout.expected $testroot/stdout
896 ret=$?
897 if [ $ret -ne 0 ]; then
898 diff -u $testroot/stdout.expected $testroot/stdout
899 test_done "$testroot" "$ret"
900 return 1
901 fi
903 (cd $testroot/wt && got diff > $testroot/stdout)
905 echo "diff $testroot/wt" > $testroot/stdout.expected
906 echo "commit - $commit_id" >> $testroot/stdout.expected
907 echo "path + $testroot/wt" >> $testroot/stdout.expected
908 echo -n 'blob - ' >> $testroot/stdout.expected
909 (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 | \
910 tr -d '\n' >> $testroot/stdout.expected
911 echo " (staged)" >> $testroot/stdout.expected
912 echo "file + numbers" >> $testroot/stdout.expected
913 echo "--- numbers" >> $testroot/stdout.expected
914 echo "+++ numbers" >> $testroot/stdout.expected
915 echo "@@ -1,5 +1,5 @@" >> $testroot/stdout.expected
916 echo " 1" >> $testroot/stdout.expected
917 echo "-2" >> $testroot/stdout.expected
918 echo "+a" >> $testroot/stdout.expected
919 echo " 3" >> $testroot/stdout.expected
920 echo " 4" >> $testroot/stdout.expected
921 echo " 5" >> $testroot/stdout.expected
922 cmp -s $testroot/stdout.expected $testroot/stdout
923 ret=$?
924 if [ $ret -ne 0 ]; then
925 diff -u $testroot/stdout.expected $testroot/stdout
926 test_done "$testroot" "$ret"
927 return 1
928 fi
930 (cd $testroot/wt && got diff -s > $testroot/stdout)
931 echo "diff -s $testroot/wt" > $testroot/stdout.expected
932 echo "commit - $commit_id" >> $testroot/stdout.expected
933 echo "path + $testroot/wt (staged changes)" >> $testroot/stdout.expected
934 echo -n 'blob - ' >> $testroot/stdout.expected
935 got tree -r $testroot/repo -i -c $commit_id \
936 | grep 'numbers$' | cut -d' ' -f 1 \
937 >> $testroot/stdout.expected
938 echo -n 'blob + ' >> $testroot/stdout.expected
939 (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 \
940 >> $testroot/stdout.expected
941 cat >> $testroot/stdout.expected <<EOF
942 --- numbers
943 +++ numbers
944 @@ -4,7 +4,7 @@
948 -7
949 +b
952 10
953 @@ -13,4 +13,4 @@
954 13
955 14
956 15
957 -16
958 +c
959 EOF
960 echo -n 'blob - ' >> $testroot/stdout.expected
961 got tree -r $testroot/repo -i | grep 'zzz$' | cut -d' ' -f 1 \
962 >> $testroot/stdout.expected
963 echo 'blob + /dev/null' >> $testroot/stdout.expected
964 echo "--- zzz" >> $testroot/stdout.expected
965 echo "+++ /dev/null" >> $testroot/stdout.expected
966 echo "@@ -1 +0,0 @@" >> $testroot/stdout.expected
967 echo "-zzz" >> $testroot/stdout.expected
968 cmp -s $testroot/stdout.expected $testroot/stdout
969 ret=$?
970 if [ $ret -ne 0 ]; then
971 diff -u $testroot/stdout.expected $testroot/stdout
972 fi
973 test_done "$testroot" "$ret"
976 test_unstage_symlink() {
977 local testroot=`test_init unstage_symlink`
979 (cd $testroot/repo && ln -s alpha alpha.link)
980 (cd $testroot/repo && ln -s epsilon epsilon.link)
981 (cd $testroot/repo && ln -s /etc/passwd passwd.link)
982 (cd $testroot/repo && ln -s ../beta epsilon/beta.link)
983 (cd $testroot/repo && ln -s nonexistent nonexistent.link)
984 (cd $testroot/repo && git add .)
985 git_commit $testroot/repo -m "add symlinks"
986 local head_commit=`git_show_head $testroot/repo`
988 got checkout $testroot/repo $testroot/wt > /dev/null
989 ret=$?
990 if [ $ret -ne 0 ]; then
991 test_done "$testroot" "$ret"
992 return 1
993 fi
995 (cd $testroot/wt && ln -sf beta alpha.link)
996 (cd $testroot/wt && rm epsilon.link && ln -s gamma epsilon.link)
997 (cd $testroot/wt && ln -sf ../gamma/delta epsilon/beta.link)
998 echo 'this is regular file foo' > $testroot/wt/dotgotfoo.link
999 (cd $testroot/wt && got add dotgotfoo.link > /dev/null)
1000 (cd $testroot/wt && ln -sf .got/bar dotgotbar.link)
1001 (cd $testroot/wt && got add dotgotbar.link > /dev/null)
1002 (cd $testroot/wt && got rm nonexistent.link > /dev/null)
1003 (cd $testroot/wt && ln -sf gamma/delta zeta.link)
1004 (cd $testroot/wt && got add zeta.link > /dev/null)
1006 (cd $testroot/wt && got stage -S > /dev/null)
1008 (cd $testroot/wt && got status > $testroot/stdout)
1009 cat > $testroot/stdout.expected <<EOF
1010 M alpha.link
1011 A dotgotbar.link
1012 A dotgotfoo.link
1013 M epsilon/beta.link
1014 M epsilon.link
1015 D nonexistent.link
1016 A zeta.link
1017 EOF
1018 cmp -s $testroot/stdout.expected $testroot/stdout
1019 ret=$?
1020 if [ $ret -ne 0 ]; then
1021 diff -u $testroot/stdout.expected $testroot/stdout
1022 test_done "$testroot" "$ret"
1023 return 1
1026 (cd $testroot/wt && got unstage > $testroot/stdout)
1027 ret=$?
1028 if [ $ret -ne 0 ]; then
1029 echo "got unstage command failed unexpectedly" >&2
1030 test_done "$testroot" "1"
1031 return 1
1034 cat > $testroot/stdout.expected <<EOF
1035 G alpha.link
1036 G dotgotbar.link
1037 G dotgotfoo.link
1038 G epsilon/beta.link
1039 G epsilon.link
1040 D nonexistent.link
1041 G zeta.link
1042 EOF
1044 cmp -s $testroot/stdout.expected $testroot/stdout
1045 ret=$?
1046 if [ $ret -ne 0 ]; then
1047 diff -u $testroot/stdout.expected $testroot/stdout
1048 test_done "$testroot" "$ret"
1049 return 1
1052 if [ ! -h $testroot/wt/alpha.link ]; then
1053 echo "alpha.link is not a symlink"
1054 test_done "$testroot" "1"
1055 return 1
1058 readlink $testroot/wt/alpha.link > $testroot/stdout
1059 echo "beta" > $testroot/stdout.expected
1060 cmp -s $testroot/stdout.expected $testroot/stdout
1061 ret=$?
1062 if [ $ret -ne 0 ]; then
1063 diff -u $testroot/stdout.expected $testroot/stdout
1064 test_done "$testroot" "$ret"
1065 return 1
1068 if [ ! -h $testroot/wt/epsilon.link ]; then
1069 echo "epsilon.link is not a symlink"
1070 test_done "$testroot" "1"
1071 return 1
1074 readlink $testroot/wt/epsilon.link > $testroot/stdout
1075 echo "gamma" > $testroot/stdout.expected
1076 cmp -s $testroot/stdout.expected $testroot/stdout
1077 ret=$?
1078 if [ $ret -ne 0 ]; then
1079 diff -u $testroot/stdout.expected $testroot/stdout
1080 test_done "$testroot" "$ret"
1081 return 1
1084 if [ ! -h $testroot/wt/epsilon/beta.link ]; then
1085 echo "epsilon/beta.link is not a symlink"
1086 test_done "$testroot" "1"
1087 return 1
1090 readlink $testroot/wt/epsilon/beta.link > $testroot/stdout
1091 echo "../gamma/delta" > $testroot/stdout.expected
1092 cmp -s $testroot/stdout.expected $testroot/stdout
1093 ret=$?
1094 if [ $ret -ne 0 ]; then
1095 diff -u $testroot/stdout.expected $testroot/stdout
1096 test_done "$testroot" "$ret"
1097 return 1
1100 if [ ! -f $testroot/wt/dotgotfoo.link ]; then
1101 echo "dotgotfoo.link is a symlink"
1102 test_done "$testroot" "1"
1103 return 1
1106 echo "this is regular file foo" > $testroot/content.expected
1107 cp $testroot/wt/dotgotfoo.link $testroot/content
1108 cmp -s $testroot/content.expected $testroot/content
1109 ret=$?
1110 if [ $ret -ne 0 ]; then
1111 diff -u $testroot/content.expected $testroot/content
1112 test_done "$testroot" "$ret"
1113 return 1
1116 # bad symlinks are allowed as-is for commit and stage/unstage
1117 if [ ! -h $testroot/wt/dotgotbar.link ]; then
1118 echo "dotgotbar.link is not a symlink"
1119 test_done "$testroot" "1"
1120 return 1
1123 readlink $testroot/wt/dotgotbar.link > $testroot/stdout
1124 echo ".got/bar" > $testroot/stdout.expected
1125 cmp -s $testroot/stdout.expected $testroot/stdout
1126 ret=$?
1127 if [ $ret -ne 0 ]; then
1128 diff -u $testroot/stdout.expected $testroot/stdout
1129 test_done "$testroot" "$ret"
1130 return 1
1133 if [ -e $testroot/wt/nonexistent.link ]; then
1134 echo "nonexistent.link exists on disk"
1135 test_done "$testroot" "1"
1136 return 1
1139 if [ ! -h $testroot/wt/zeta.link ]; then
1140 echo "zeta.link is not a symlink"
1141 test_done "$testroot" "1"
1142 return 1
1145 readlink $testroot/wt/zeta.link > $testroot/stdout
1146 echo "gamma/delta" > $testroot/stdout.expected
1147 cmp -s $testroot/stdout.expected $testroot/stdout
1148 ret=$?
1149 if [ $ret -ne 0 ]; then
1150 diff -u $testroot/stdout.expected $testroot/stdout
1151 test_done "$testroot" "$ret"
1152 return 1
1155 test_done "$testroot" "0"
1158 test_unstage_patch_symlink() {
1159 local testroot=`test_init unstage_patch_symlink`
1161 (cd $testroot/repo && ln -s alpha alpha.link)
1162 (cd $testroot/repo && ln -s epsilon epsilon.link)
1163 (cd $testroot/repo && ln -s /etc/passwd passwd.link)
1164 (cd $testroot/repo && ln -s ../beta epsilon/beta.link)
1165 (cd $testroot/repo && ln -s nonexistent nonexistent.link)
1166 (cd $testroot/repo && ln -sf epsilon/zeta zeta.link)
1167 (cd $testroot/repo && ln -sf epsilon/zeta zeta2.link)
1168 (cd $testroot/repo && git add .)
1169 git_commit $testroot/repo -m "add symlinks"
1170 local commit_id1=`git_show_head $testroot/repo`
1172 got checkout $testroot/repo $testroot/wt > /dev/null
1173 ret=$?
1174 if [ $ret -ne 0 ]; then
1175 test_done "$testroot" "$ret"
1176 return 1
1179 # symlink to file A now points to file B
1180 (cd $testroot/wt && ln -sf gamma/delta alpha.link)
1181 # symlink to a directory A now points to file B
1182 (cd $testroot/wt && rm epsilon.link && ln -s beta epsilon.link)
1183 # "bad" symlink now contains a different target path
1184 echo "foo" > $testroot/wt/passwd.link
1185 # relative symlink to directory A now points to relative directory B
1186 (cd $testroot/wt && rm epsilon/beta.link && ln -s ../gamma \
1187 epsilon/beta.link)
1188 # an unversioned symlink
1189 (cd $testroot/wt && ln -sf .got/foo dotgotfoo.link)
1190 # symlink to file A now points to non-existent file B
1191 (cd $testroot/wt && ln -sf nonexistent2 nonexistent.link)
1192 # removed symlink
1193 (cd $testroot/wt && got rm zeta.link > /dev/null)
1194 (cd $testroot/wt && got rm zeta2.link > /dev/null)
1195 # added symlink
1196 (cd $testroot/wt && ln -sf beta new.link)
1197 (cd $testroot/wt && got add new.link > /dev/null)
1198 (cd $testroot/wt && ln -sf beta zeta3.link)
1199 (cd $testroot/wt && got add zeta3.link > /dev/null)
1201 (cd $testroot/wt && got stage -S > /dev/null)
1203 (cd $testroot/wt && got status > $testroot/stdout)
1204 cat > $testroot/stdout.expected <<EOF
1205 M alpha.link
1206 ? dotgotfoo.link
1207 M epsilon/beta.link
1208 M epsilon.link
1209 A new.link
1210 M nonexistent.link
1211 M passwd.link
1212 D zeta.link
1213 D zeta2.link
1214 A zeta3.link
1215 EOF
1216 cmp -s $testroot/stdout.expected $testroot/stdout
1217 ret=$?
1218 if [ $ret -ne 0 ]; then
1219 diff -u $testroot/stdout.expected $testroot/stdout
1220 test_done "$testroot" "$ret"
1221 return 1
1224 printf "y\nn\ny\nn\ny\ny\nn\ny\ny\n" > $testroot/patchscript
1225 (cd $testroot/wt && got unstage -F $testroot/patchscript -p \
1226 > $testroot/stdout)
1227 ret=$?
1228 if [ $ret -ne 0 ]; then
1229 echo "got unstage command failed unexpectedly" >&2
1230 test_done "$testroot" "1"
1231 return 1
1234 cat > $testroot/stdout.expected <<EOF
1235 -----------------------------------------------
1236 @@ -1 +1 @@
1237 -alpha
1238 \ No newline at end of file
1239 +gamma/delta
1240 \ No newline at end of file
1241 -----------------------------------------------
1242 M alpha.link (change 1 of 1)
1243 unstage this change? [y/n/q] y
1244 G alpha.link
1245 -----------------------------------------------
1246 @@ -1 +1 @@
1247 -../beta
1248 \ No newline at end of file
1249 +../gamma
1250 \ No newline at end of file
1251 -----------------------------------------------
1252 M epsilon/beta.link (change 1 of 1)
1253 unstage this change? [y/n/q] n
1254 -----------------------------------------------
1255 @@ -1 +1 @@
1256 -epsilon
1257 \ No newline at end of file
1258 +beta
1259 \ No newline at end of file
1260 -----------------------------------------------
1261 M epsilon.link (change 1 of 1)
1262 unstage this change? [y/n/q] y
1263 G epsilon.link
1264 A new.link
1265 unstage this addition? [y/n] n
1266 -----------------------------------------------
1267 @@ -1 +1 @@
1268 -nonexistent
1269 \ No newline at end of file
1270 +nonexistent2
1271 \ No newline at end of file
1272 -----------------------------------------------
1273 M nonexistent.link (change 1 of 1)
1274 unstage this change? [y/n/q] y
1275 G nonexistent.link
1276 -----------------------------------------------
1277 @@ -1 +1 @@
1278 -/etc/passwd
1279 \ No newline at end of file
1280 +foo
1281 -----------------------------------------------
1282 M passwd.link (change 1 of 1)
1283 unstage this change? [y/n/q] y
1284 G passwd.link
1285 D zeta.link
1286 unstage this deletion? [y/n] n
1287 D zeta2.link
1288 unstage this deletion? [y/n] y
1289 D zeta2.link
1290 A zeta3.link
1291 unstage this addition? [y/n] y
1292 G zeta3.link
1293 EOF
1294 cmp -s $testroot/stdout.expected $testroot/stdout
1295 ret=$?
1296 if [ $ret -ne 0 ]; then
1297 diff -u $testroot/stdout.expected $testroot/stdout
1298 test_done "$testroot" "$ret"
1299 return 1
1302 if ! [ -h $testroot/wt/alpha.link ]; then
1303 echo "alpha.link is not a symlink"
1304 test_done "$testroot" "1"
1305 return 1
1308 readlink $testroot/wt/alpha.link > $testroot/stdout
1309 echo "gamma/delta" > $testroot/stdout.expected
1310 cmp -s $testroot/stdout.expected $testroot/stdout
1311 ret=$?
1312 if [ $ret -ne 0 ]; then
1313 diff -u $testroot/stdout.expected $testroot/stdout
1314 test_done "$testroot" "$ret"
1315 return 1
1318 if ! [ -h $testroot/wt/epsilon.link ]; then
1319 echo "epsilon.link is not a symlink"
1320 test_done "$testroot" "1"
1321 return 1
1324 readlink $testroot/wt/epsilon.link > $testroot/stdout
1325 echo "beta" > $testroot/stdout.expected
1326 cmp -s $testroot/stdout.expected $testroot/stdout
1327 ret=$?
1328 if [ $ret -ne 0 ]; then
1329 diff -u $testroot/stdout.expected $testroot/stdout
1330 test_done "$testroot" "$ret"
1331 return 1
1334 if [ -h $testroot/wt/passwd.link ]; then
1335 echo "passwd.link should not be a symlink" >&2
1336 test_done "$testroot" "1"
1337 return 1
1340 echo "foo" > $testroot/content.expected
1341 cp $testroot/wt/passwd.link $testroot/content
1343 cmp -s $testroot/content.expected $testroot/content
1344 ret=$?
1345 if [ $ret -ne 0 ]; then
1346 diff -u $testroot/content.expected $testroot/content
1347 test_done "$testroot" "$ret"
1348 return 1
1351 readlink $testroot/wt/epsilon/beta.link > $testroot/stdout
1352 echo "../gamma" > $testroot/stdout.expected
1353 cmp -s $testroot/stdout.expected $testroot/stdout
1354 ret=$?
1355 if [ $ret -ne 0 ]; then
1356 diff -u $testroot/stdout.expected $testroot/stdout
1357 test_done "$testroot" "$ret"
1358 return 1
1361 readlink $testroot/wt/nonexistent.link > $testroot/stdout
1362 echo "nonexistent2" > $testroot/stdout.expected
1363 cmp -s $testroot/stdout.expected $testroot/stdout
1364 ret=$?
1365 if [ $ret -ne 0 ]; then
1366 diff -u $testroot/stdout.expected $testroot/stdout
1367 test_done "$testroot" "$ret"
1368 return 1
1371 if [ ! -h $testroot/wt/dotgotfoo.link ]; then
1372 echo "dotgotfoo.link is not a symlink " >&2
1373 test_done "$testroot" "1"
1374 return 1
1376 readlink $testroot/wt/dotgotfoo.link > $testroot/stdout
1377 echo ".got/foo" > $testroot/stdout.expected
1378 cmp -s $testroot/stdout.expected $testroot/stdout
1379 ret=$?
1380 if [ $ret -ne 0 ]; then
1381 diff -u $testroot/stdout.expected $testroot/stdout
1382 test_done "$testroot" "$ret"
1383 return 1
1387 if [ -e $testroot/wt/zeta.link ]; then
1388 echo -n "zeta.link should not exist on disk" >&2
1389 test_done "$testroot" "1"
1390 return 1
1393 if [ -e $testroot/wt/zeta2.link ]; then
1394 echo -n "zeta2.link exists on disk" >&2
1395 test_done "$testroot" "1"
1396 return 1
1399 if [ ! -h $testroot/wt/zeta3.link ]; then
1400 echo -n "zeta3.link is not a symlink" >&2
1401 test_done "$testroot" "1"
1402 return 1
1405 readlink $testroot/wt/zeta3.link > $testroot/stdout
1406 echo "beta" > $testroot/stdout.expected
1407 cmp -s $testroot/stdout.expected $testroot/stdout
1408 ret=$?
1409 if [ $ret -ne 0 ]; then
1410 diff -u $testroot/stdout.expected $testroot/stdout
1411 test_done "$testroot" "$ret"
1412 return 1
1415 if [ ! -h $testroot/wt/new.link ]; then
1416 echo -n "new.link is not a symlink" >&2
1417 test_done "$testroot" "1"
1418 return 1
1421 (cd $testroot/wt && got status > $testroot/stdout)
1422 echo "M alpha.link" > $testroot/stdout.expected
1423 echo "? dotgotfoo.link" >> $testroot/stdout.expected
1424 echo " M epsilon/beta.link" >> $testroot/stdout.expected
1425 echo "M epsilon.link" >> $testroot/stdout.expected
1426 echo " A new.link" >> $testroot/stdout.expected
1427 echo "M nonexistent.link" >> $testroot/stdout.expected
1428 echo "M passwd.link" >> $testroot/stdout.expected
1429 echo " D zeta.link" >> $testroot/stdout.expected
1430 echo "D zeta2.link" >> $testroot/stdout.expected
1431 echo "A zeta3.link" >> $testroot/stdout.expected
1432 cmp -s $testroot/stdout.expected $testroot/stdout
1433 ret=$?
1434 if [ $ret -ne 0 ]; then
1435 diff -u $testroot/stdout.expected $testroot/stdout
1436 return 1
1438 test_done "$testroot" "$ret"
1441 test_parseargs "$@"
1442 run_test test_unstage_basic
1443 run_test test_unstage_unversioned
1444 run_test test_unstage_nonexistent
1445 run_test test_unstage_patch
1446 run_test test_unstage_patch_added
1447 run_test test_unstage_patch_removed
1448 run_test test_unstage_patch_quit
1449 run_test test_unstage_symlink
1450 run_test test_unstage_patch_symlink