3 # Copyright (c) 2019 Stefan Sperling <stsp@openbsd.org>
5 # Permission to use, copy, modify, and distribute this software for any
6 # purpose with or without fee is hereby granted, provided that the above
7 # copyright notice and this permission notice appear in all copies.
9 # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 # disable automatic packing for these tests
20 export GOT_TEST_PACK=""
23 local testroot=`test_init stage_basic`
25 got checkout $testroot/repo $testroot/wt > /dev/null
27 if [ $ret -ne 0 ]; then
28 test_done "$testroot" "$ret"
32 echo "modified file" > $testroot/wt/alpha
33 (cd $testroot/wt && got rm beta > /dev/null)
34 echo "new file" > $testroot/wt/foo
35 (cd $testroot/wt && got add foo > /dev/null)
37 echo ' M alpha' > $testroot/stdout.expected
38 echo ' D beta' >> $testroot/stdout.expected
39 echo ' A foo' >> $testroot/stdout.expected
40 (cd $testroot/wt && got stage -R > $testroot/stdout)
42 cmp -s $testroot/stdout.expected $testroot/stdout
44 if [ $ret -ne 0 ]; then
45 diff -u $testroot/stdout.expected $testroot/stdout
47 test_done "$testroot" "$ret"
50 test_stage_directory() {
51 local testroot=`test_init stage_directory`
53 got checkout $testroot/repo $testroot/wt > /dev/null
55 if [ $ret -ne 0 ]; then
56 test_done "$testroot" "$ret"
60 (cd $testroot/wt && echo -n > test && got add test > /dev/null)
61 (cd $testroot/wt && got stage . > $testroot/stdout 2> $testroot/stderr)
63 echo "got: staging directories requires -R option" \
64 > $testroot/stderr.expected
65 cmp -s $testroot/stderr.expected $testroot/stderr
67 if [ $ret -ne 0 ]; then
68 diff -u $testroot/stderr.expected $testroot/stderr
69 test_done "$testroot" "$ret"
73 (cd $testroot/wt && got stage -R . > $testroot/stdout)
75 echo ' A test' >> $testroot/stdout.expected
76 cmp -s $testroot/stdout.expected $testroot/stdout
78 if [ $ret -ne 0 ]; then
79 diff -u $testroot/stdout.expected $testroot/stdout
81 test_done "$testroot" "$ret"
84 test_stage_no_changes() {
85 local testroot=`test_init stage_no_changes`
87 got checkout $testroot/repo $testroot/wt > /dev/null
89 if [ $ret -ne 0 ]; then
90 test_done "$testroot" "$ret"
94 (cd $testroot/wt && got stage alpha beta > $testroot/stdout \
97 if [ $ret -eq 0 ]; then
98 echo "got stage command succeeded unexpectedly" >&2
99 test_done "$testroot" "1"
103 echo "got: no changes to stage" > $testroot/stderr.expected
105 cmp -s $testroot/stderr.expected $testroot/stderr
107 if [ $ret -ne 0 ]; then
108 diff -u $testroot/stderr.expected $testroot/stderr
109 test_done "$testroot" "$ret"
113 echo -n > $testroot/stdout.expected
114 cmp -s $testroot/stdout.expected $testroot/stdout
116 if [ $ret -ne 0 ]; then
117 diff -u $testroot/stdout.expected $testroot/stdout
119 test_done "$testroot" "$ret"
122 test_stage_unversioned() {
123 local testroot=`test_init stage_unversioned`
125 got checkout $testroot/repo $testroot/wt > /dev/null
127 if [ $ret -ne 0 ]; then
128 test_done "$testroot" "$ret"
132 echo "modified file" > $testroot/wt/alpha
133 touch $testroot/wt/unversioned-file
135 (cd $testroot/wt && got status > $testroot/stdout)
136 echo "M alpha" > $testroot/stdout.expected
137 echo "? unversioned-file" >> $testroot/stdout.expected
138 cmp -s $testroot/stdout.expected $testroot/stdout
140 if [ $ret -ne 0 ]; then
141 diff -u $testroot/stdout.expected $testroot/stdout
142 test_done "$testroot" "$ret"
146 (cd $testroot/wt && got stage -R > $testroot/stdout)
148 if [ $ret -ne 0 ]; then
149 echo "got stage command failed unexpectedly" >&2
150 test_done "$testroot" "$ret"
154 echo " M alpha" > $testroot/stdout.expected
155 cmp -s $testroot/stdout.expected $testroot/stdout
157 if [ $ret -ne 0 ]; then
158 diff -u $testroot/stdout.expected $testroot/stdout
159 test_done "$testroot" "$ret"
163 echo "modified file again" > $testroot/wt/alpha
165 (cd $testroot/wt && got stage unversioned-file > $testroot/stdout \
168 if [ $ret -eq 0 ]; then
169 echo "got stage command succeed unexpectedly" >&2
170 test_done "$testroot" "1"
174 echo "got: no changes to stage" > $testroot/stderr.expected
175 cmp -s $testroot/stderr.expected $testroot/stderr
177 if [ $ret -ne 0 ]; then
178 diff -u $testroot/stderr.expected $testroot/stderr
180 test_done "$testroot" "$ret"
184 test_stage_nonexistent() {
185 local testroot=`test_init stage_nonexistent`
187 got checkout $testroot/repo $testroot/wt > /dev/null
189 if [ $ret -ne 0 ]; then
190 test_done "$testroot" "$ret"
194 (cd $testroot/wt && got stage nonexistent-file \
195 > $testroot/stdout 2> $testroot/stderr)
196 echo "got: nonexistent-file: No such file or directory" \
197 > $testroot/stderr.expected
198 cmp -s $testroot/stderr.expected $testroot/stderr
200 if [ $ret -ne 0 ]; then
201 diff -u $testroot/stderr.expected $testroot/stderr
203 test_done "$testroot" "$ret"
207 local testroot=`test_init stage_list`
209 got checkout $testroot/repo $testroot/wt > /dev/null
211 if [ $ret -ne 0 ]; then
212 test_done "$testroot" "$ret"
216 echo "modified file" > $testroot/wt/alpha
217 (cd $testroot/wt && got rm beta > /dev/null)
218 echo "new file" > $testroot/wt/foo
219 (cd $testroot/wt && got add foo > /dev/null)
221 echo ' M alpha' > $testroot/stdout.expected
222 echo ' D beta' >> $testroot/stdout.expected
223 echo ' A foo' >> $testroot/stdout.expected
224 (cd $testroot/wt && got stage alpha beta foo > /dev/null)
226 (cd $testroot/wt && got stage -Rl > $testroot/stdout)
227 (cd $testroot/wt && got diff -s alpha | grep '^blob +' | \
228 cut -d' ' -f3 | tr -d '\n' > $testroot/stdout.expected)
229 echo " M alpha" >> $testroot/stdout.expected
230 (cd $testroot/wt && got diff -s beta | grep '^blob -' | \
231 cut -d' ' -f3 | tr -d '\n' >> $testroot/stdout.expected)
232 echo " D beta" >> $testroot/stdout.expected
233 (cd $testroot/wt && got diff -s foo | grep '^blob +' | \
234 cut -d' ' -f3 | tr -d '\n' >> $testroot/stdout.expected)
235 echo " A foo" >> $testroot/stdout.expected
236 cmp -s $testroot/stdout.expected $testroot/stdout
238 if [ $ret -ne 0 ]; then
239 diff -u $testroot/stdout.expected $testroot/stdout
240 test_done "$testroot" "$ret"
244 (cd $testroot/wt && got stage -l epsilon nonexistent \
247 echo -n > $testroot/stdout.expected
248 cmp -s $testroot/stdout.expected $testroot/stdout
250 if [ $ret -ne 0 ]; then
251 diff -u $testroot/stdout.expected $testroot/stdout
252 test_done "$testroot" "$ret"
256 (cd $testroot/wt && got stage -l alpha > $testroot/stdout)
258 (cd $testroot/wt && got diff -s alpha | grep '^blob +' | \
259 cut -d' ' -f3 | tr -d '\n' > $testroot/stdout.expected)
260 echo " M alpha" >> $testroot/stdout.expected
261 cmp -s $testroot/stdout.expected $testroot/stdout
263 if [ $ret -ne 0 ]; then
264 diff -u $testroot/stdout.expected $testroot/stdout
266 test_done "$testroot" "$ret"
270 test_stage_conflict() {
271 local testroot=`test_init stage_conflict`
272 local initial_commit=`git_show_head $testroot/repo`
274 got checkout $testroot/repo $testroot/wt > /dev/null
276 if [ $ret -ne 0 ]; then
277 test_done "$testroot" "$ret"
281 echo "modified alpha" > $testroot/wt/alpha
282 (cd $testroot/wt && got commit -m "modified alpha" >/dev/null)
284 (cd $testroot/wt && got update -c $initial_commit > /dev/null)
286 echo "modified alpha, too" > $testroot/wt/alpha
288 echo "C alpha" > $testroot/stdout.expected
289 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
290 git_show_head $testroot/repo >> $testroot/stdout.expected
291 echo >> $testroot/stdout.expected
292 echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
294 (cd $testroot/wt && got update > $testroot/stdout)
296 cmp -s $testroot/stdout.expected $testroot/stdout
298 if [ $ret -ne 0 ]; then
299 diff -u $testroot/stdout.expected $testroot/stdout
300 test_done "$testroot" "$ret"
304 (cd $testroot/wt && got stage alpha > $testroot/stdout \
307 if [ $ret -eq 0 ]; then
308 echo "got stage command succeeded unexpectedly" >&2
309 test_done "$testroot" "1"
313 echo -n > $testroot/stdout.expected
314 echo "got: alpha: cannot stage file in conflicted status" \
315 > $testroot/stderr.expected
317 cmp -s $testroot/stdout.expected $testroot/stdout
319 if [ $ret -ne 0 ]; then
320 diff -u $testroot/stdout.expected $testroot/stdout
321 test_done "$testroot" "$ret"
324 cmp -s $testroot/stderr.expected $testroot/stderr
326 if [ $ret -ne 0 ]; then
327 diff -u $testroot/stderr.expected $testroot/stderr
329 test_done "$testroot" "$ret"
332 test_stage_out_of_date() {
333 local testroot=`test_init stage_out_of_date`
334 local initial_commit=`git_show_head $testroot/repo`
336 got checkout $testroot/repo $testroot/wt > /dev/null
338 if [ $ret -ne 0 ]; then
339 test_done "$testroot" "$ret"
343 echo "modified alpha" > $testroot/wt/alpha
344 (cd $testroot/wt && got commit -m "modified alpha" >/dev/null)
346 (cd $testroot/wt && got update -c $initial_commit > /dev/null)
348 echo "modified alpha again" > $testroot/wt/alpha
349 (cd $testroot/wt && got stage alpha > $testroot/stdout \
352 if [ $ret -eq 0 ]; then
353 echo "got stage command succeeded unexpectedly" >&2
354 test_done "$testroot" "1"
358 echo -n > $testroot/stdout.expected
359 echo "got: work tree must be updated before changes can be staged" \
360 > $testroot/stderr.expected
362 cmp -s $testroot/stdout.expected $testroot/stdout
364 if [ $ret -ne 0 ]; then
365 diff -u $testroot/stdout.expected $testroot/stdout
366 test_done "$testroot" "$ret"
369 cmp -s $testroot/stderr.expected $testroot/stderr
371 if [ $ret -ne 0 ]; then
372 diff -u $testroot/stderr.expected $testroot/stderr
374 test_done "$testroot" "$ret"
378 test_double_stage() {
379 local testroot=`test_init double_stage`
381 got checkout $testroot/repo $testroot/wt > /dev/null
383 if [ $ret -ne 0 ]; then
384 test_done "$testroot" "$ret"
387 echo "modified file" > $testroot/wt/alpha
388 (cd $testroot/wt && got rm beta > /dev/null)
389 echo "new file" > $testroot/wt/foo
390 (cd $testroot/wt && got add foo > /dev/null)
391 (cd $testroot/wt && got stage alpha beta foo > /dev/null)
393 echo "got: no changes to stage" > $testroot/stderr.expected
394 (cd $testroot/wt && got stage alpha 2> $testroot/stderr)
395 cmp -s $testroot/stderr.expected $testroot/stderr
397 if [ $ret -ne 0 ]; then
398 diff -u $testroot/stderr.expected $testroot/stderr
399 test_done "$testroot" "$ret"
403 (cd $testroot/wt && got stage beta \
404 > $testroot/stdout 2> $testroot/stderr)
406 if [ $ret -eq 0 ]; then
407 echo "got stage command succeeded unexpectedly" >&2
408 test_done "$testroot" "1"
411 echo -n > $testroot/stdout.expected
412 cmp -s $testroot/stdout.expected $testroot/stdout
414 if [ $ret -ne 0 ]; then
415 diff -u $testroot/stdout.expected $testroot/stdout
416 test_done "$testroot" "$ret"
420 echo "got: no changes to stage" > $testroot/stderr.expected
421 (cd $testroot/wt && got stage foo 2> $testroot/stderr)
422 cmp -s $testroot/stderr.expected $testroot/stderr
424 if [ $ret -ne 0 ]; then
425 diff -u $testroot/stderr.expected $testroot/stderr
426 test_done "$testroot" "$ret"
430 printf "q\n" > $testroot/patchscript
431 (cd $testroot/wt && got stage -F $testroot/patchscript -p \
432 > $testroot/stdout 2> $testroot/stderr)
434 if [ $ret -eq 0 ]; then
435 echo "got stage command succeeded unexpectedly" >&2
436 test_done "$testroot" "1"
439 echo -n > $testroot/stdout.expected
440 cmp -s $testroot/stdout.expected $testroot/stdout
442 if [ $ret -ne 0 ]; then
443 diff -u $testroot/stdout.expected $testroot/stdout
444 test_done "$testroot" "$ret"
448 echo "got: no changes to stage" > $testroot/stderr.expected
449 (cd $testroot/wt && got stage foo 2> $testroot/stderr)
450 cmp -s $testroot/stderr.expected $testroot/stderr
452 if [ $ret -ne 0 ]; then
453 diff -u $testroot/stderr.expected $testroot/stderr
454 test_done "$testroot" "$ret"
458 echo "modified file again" > $testroot/wt/alpha
459 echo "modified new file" > $testroot/wt/foo
461 echo ' M alpha' > $testroot/stdout.expected
462 echo ' A foo' >> $testroot/stdout.expected
463 (cd $testroot/wt && got stage alpha beta foo > $testroot/stdout)
464 cmp -s $testroot/stdout.expected $testroot/stdout
466 if [ $ret -ne 0 ]; then
467 diff -u $testroot/stdout.expected $testroot/stdout
468 test_done "$testroot" "$ret"
472 echo ' M alpha' > $testroot/stdout.expected
473 echo ' D beta' >> $testroot/stdout.expected
474 echo ' A foo' >> $testroot/stdout.expected
476 (cd $testroot/wt && got status > $testroot/stdout)
477 cmp -s $testroot/stdout.expected $testroot/stdout
479 if [ $ret -ne 0 ]; then
480 diff -u $testroot/stdout.expected $testroot/stdout
482 test_done "$testroot" "$ret"
485 test_stage_status() {
486 local testroot=`test_init stage_status`
488 got checkout $testroot/repo $testroot/wt > /dev/null
490 if [ $ret -ne 0 ]; then
491 test_done "$testroot" "$ret"
495 echo "modified file" > $testroot/wt/alpha
496 (cd $testroot/wt && got rm beta > /dev/null)
497 echo "new file" > $testroot/wt/foo
498 (cd $testroot/wt && got add foo > /dev/null)
499 echo "new file" > $testroot/wt/epsilon/new
500 (cd $testroot/wt && got add epsilon/new > /dev/null)
501 echo "modified file" > $testroot/wt/epsilon/zeta
502 (cd $testroot/wt && got rm gamma/delta > /dev/null)
504 echo ' M alpha' > $testroot/stdout.expected
505 echo ' D beta' >> $testroot/stdout.expected
506 echo 'A epsilon/new' >> $testroot/stdout.expected
507 echo 'M epsilon/zeta' >> $testroot/stdout.expected
508 echo ' A foo' >> $testroot/stdout.expected
509 echo 'D gamma/delta' >> $testroot/stdout.expected
510 (cd $testroot/wt && got stage alpha beta foo > /dev/null)
512 (cd $testroot/wt && got status > $testroot/stdout)
513 cmp -s $testroot/stdout.expected $testroot/stdout
515 if [ $ret -ne 0 ]; then
516 diff -u $testroot/stdout.expected $testroot/stdout
517 test_done "$testroot" "$ret"
521 echo "modified file again" >> $testroot/wt/alpha
522 echo "modified added file again" >> $testroot/wt/foo
524 echo 'MM alpha' > $testroot/stdout.expected
525 echo ' D beta' >> $testroot/stdout.expected
526 echo 'A epsilon/new' >> $testroot/stdout.expected
527 echo 'M epsilon/zeta' >> $testroot/stdout.expected
528 echo 'MA foo' >> $testroot/stdout.expected
529 echo 'D gamma/delta' >> $testroot/stdout.expected
531 (cd $testroot/wt && got status > $testroot/stdout)
532 cmp -s $testroot/stdout.expected $testroot/stdout
534 if [ $ret -ne 0 ]; then
535 diff -u $testroot/stdout.expected $testroot/stdout
536 test_done "$testroot" "$ret"
540 # test no-op change of added file with new stat(2) timestamp
541 echo "new file" > $testroot/wt/foo
542 echo ' A foo' > $testroot/stdout.expected
543 (cd $testroot/wt && got status foo > $testroot/stdout)
544 cmp -s $testroot/stdout.expected $testroot/stdout
546 if [ $ret -ne 0 ]; then
547 diff -u $testroot/stdout.expected $testroot/stdout
548 test_done "$testroot" "$ret"
552 # test staged deleted file which is restored on disk
553 echo "new file" > $testroot/wt/beta
554 echo ' D beta' > $testroot/stdout.expected
555 (cd $testroot/wt && got status beta > $testroot/stdout)
556 cmp -s $testroot/stdout.expected $testroot/stdout
558 if [ $ret -ne 0 ]; then
559 diff -u $testroot/stdout.expected $testroot/stdout
561 test_done "$testroot" "$ret"
565 test_stage_add_already_staged_file() {
566 local testroot=`test_init stage_add_already_staged_file`
568 got checkout $testroot/repo $testroot/wt > /dev/null
570 if [ $ret -ne 0 ]; then
571 test_done "$testroot" "$ret"
575 echo "modified file" > $testroot/wt/alpha
576 (cd $testroot/wt && got rm beta > /dev/null)
577 echo "new file" > $testroot/wt/foo
578 (cd $testroot/wt && got add foo > /dev/null)
580 (cd $testroot/wt && got stage alpha beta foo > $testroot/stdout)
582 echo -n > $testroot/stdout.expected
583 for f in alpha beta foo; do
584 (cd $testroot/wt && got add $f \
585 > $testroot/stdout 2> $testroot/stderr)
586 echo "got: $f: file has unexpected status" \
587 > $testroot/stderr.expected
588 cmp -s $testroot/stderr.expected $testroot/stderr
590 if [ $ret -ne 0 ]; then
591 diff -u $testroot/stderr.expected $testroot/stderr
592 test_done "$testroot" "$ret"
595 cmp -s $testroot/stdout.expected $testroot/stdout
597 if [ $ret -ne 0 ]; then
598 diff -u $testroot/stdout.expected $testroot/stdout
599 test_done "$testroot" "$ret"
604 echo ' M alpha' > $testroot/stdout.expected
605 echo ' D beta' >> $testroot/stdout.expected
606 echo ' A foo' >> $testroot/stdout.expected
608 (cd $testroot/wt && got status > $testroot/stdout)
609 cmp -s $testroot/stdout.expected $testroot/stdout
611 if [ $ret -ne 0 ]; then
612 diff -u $testroot/stdout.expected $testroot/stdout
614 test_done "$testroot" "$ret"
617 test_stage_rm_already_staged_file() {
618 local testroot=`test_init stage_rm_already_staged_file`
620 got checkout $testroot/repo $testroot/wt > /dev/null
622 if [ $ret -ne 0 ]; then
623 test_done "$testroot" "$ret"
627 echo "modified file" > $testroot/wt/alpha
628 (cd $testroot/wt && got rm beta > /dev/null)
629 echo "new file" > $testroot/wt/foo
630 (cd $testroot/wt && got add foo > /dev/null)
632 (cd $testroot/wt && got stage alpha beta foo > $testroot/stdout)
634 (cd $testroot/wt && got rm beta \
635 > $testroot/stdout 2> $testroot/stderr)
637 if [ $ret -ne 0 ]; then
638 echo "got rm command failed unexpectedly" >&2
639 test_done "$testroot" "1"
642 echo -n > $testroot/stdout.expected
643 cmp -s $testroot/stdout.expected $testroot/stdout
645 if [ $ret -ne 0 ]; then
646 diff -u $testroot/stdout.expected $testroot/stdout
647 test_done "$testroot" "$ret"
650 echo -n > $testroot/stderr.expected
651 cmp -s $testroot/stderr.expected $testroot/stderr
653 if [ $ret -ne 0 ]; then
654 diff -u $testroot/stderr.expected $testroot/stderr
655 test_done "$testroot" "$ret"
659 for f in alpha foo; do
660 echo "got: $f: file is staged" > $testroot/stderr.expected
661 (cd $testroot/wt && got rm $f \
662 > $testroot/stdout 2> $testroot/stderr)
664 if [ $ret -eq 0 ]; then
665 echo "got rm command succeeded unexpectedly" >&2
666 test_done "$testroot" "1"
669 cmp -s $testroot/stderr.expected $testroot/stderr
671 if [ $ret -ne 0 ]; then
672 diff -u $testroot/stderr.expected $testroot/stderr
673 test_done "$testroot" "$ret"
678 echo ' M alpha' > $testroot/stdout.expected
679 echo ' D beta' >> $testroot/stdout.expected
680 echo ' A foo' >> $testroot/stdout.expected
682 (cd $testroot/wt && got status > $testroot/stdout)
683 cmp -s $testroot/stdout.expected $testroot/stdout
685 if [ $ret -ne 0 ]; then
686 diff -u $testroot/stdout.expected $testroot/stdout
688 test_done "$testroot" "$ret"
691 test_stage_revert() {
692 local testroot=`test_init stage_revert`
694 got checkout $testroot/repo $testroot/wt > /dev/null
696 if [ $ret -ne 0 ]; then
697 test_done "$testroot" "$ret"
701 echo "modified alpha" > $testroot/wt/alpha
702 (cd $testroot/wt && got rm beta > /dev/null)
703 echo "new file" > $testroot/wt/foo
704 (cd $testroot/wt && got add foo > /dev/null)
705 (cd $testroot/wt && got stage alpha beta foo > /dev/null)
707 echo "modified file again" >> $testroot/wt/alpha
708 echo "modified added file again" >> $testroot/wt/foo
710 (cd $testroot/wt && got revert alpha > $testroot/stdout)
712 if [ $ret -ne 0 ]; then
713 echo "revert command failed unexpectedly" >&2
714 test_done "$testroot" "$ret"
718 echo "R alpha" > $testroot/stdout.expected
719 cmp -s $testroot/stdout.expected $testroot/stdout
721 if [ $ret -ne 0 ]; then
722 diff -u $testroot/stdout.expected $testroot/stdout
723 test_done "$testroot" "$ret"
727 echo "modified alpha" > $testroot/content.expected
728 cat $testroot/wt/alpha > $testroot/content
729 cmp -s $testroot/content.expected $testroot/content
731 if [ $ret -ne 0 ]; then
732 diff -u $testroot/content.expected $testroot/content
733 test_done "$testroot" "$ret"
737 echo ' M alpha' > $testroot/stdout.expected
738 echo ' D beta' >> $testroot/stdout.expected
739 echo 'MA foo' >> $testroot/stdout.expected
740 (cd $testroot/wt && got status > $testroot/stdout)
741 cmp -s $testroot/stdout.expected $testroot/stdout
743 if [ $ret -ne 0 ]; then
744 diff -u $testroot/stdout.expected $testroot/stdout
745 test_done "$testroot" "$ret"
749 (cd $testroot/wt && got revert alpha > $testroot/stdout)
751 if [ $ret -ne 0 ]; then
752 echo "revert command failed unexpectedly" >&2
753 test_done "$testroot" "$ret"
757 echo -n > $testroot/stdout.expected
758 cmp -s $testroot/stdout.expected $testroot/stdout
760 if [ $ret -ne 0 ]; then
761 diff -u $testroot/stdout.expected $testroot/stdout
762 test_done "$testroot" "$ret"
766 echo "modified alpha" > $testroot/content.expected
767 cat $testroot/wt/alpha > $testroot/content
768 cmp -s $testroot/content.expected $testroot/content
770 if [ $ret -ne 0 ]; then
771 diff -u $testroot/content.expected $testroot/content
772 test_done "$testroot" "$ret"
776 (cd $testroot/wt && got revert beta > $testroot/stdout \
779 if [ $ret -ne 0 ]; then
780 echo "revert command failed unexpectedly" >&2
781 test_done "$testroot" "$ret"
785 echo -n > $testroot/stdout.expected
786 cmp -s $testroot/stdout.expected $testroot/stdout
788 if [ $ret -ne 0 ]; then
789 diff -u $testroot/stdout.expected $testroot/stdout
790 test_done "$testroot" "$ret"
794 echo -n > $testroot/stderr.expected
795 cmp -s $testroot/stderr.expected $testroot/stderr
797 if [ $ret -ne 0 ]; then
798 diff -u $testroot/stderr.expected $testroot/stderr
799 test_done "$testroot" "$ret"
803 (cd $testroot/wt && got revert foo > $testroot/stdout)
805 if [ $ret -ne 0 ]; then
806 echo "revert command failed unexpectedly" >&2
807 test_done "$testroot" "$ret"
811 echo "R foo" > $testroot/stdout.expected
812 cmp -s $testroot/stdout.expected $testroot/stdout
814 if [ $ret -ne 0 ]; then
815 diff -u $testroot/stdout.expected $testroot/stdout
816 test_done "$testroot" "$ret"
820 echo "new file" > $testroot/content.expected
821 cat $testroot/wt/foo > $testroot/content
822 cmp -s $testroot/content.expected $testroot/content
824 if [ $ret -ne 0 ]; then
825 diff -u $testroot/content.expected $testroot/content
826 test_done "$testroot" "$ret"
830 echo ' M alpha' > $testroot/stdout.expected
831 echo ' D beta' >> $testroot/stdout.expected
832 echo ' A foo' >> $testroot/stdout.expected
833 (cd $testroot/wt && got status > $testroot/stdout)
834 cmp -s $testroot/stdout.expected $testroot/stdout
836 if [ $ret -ne 0 ]; then
837 diff -u $testroot/stdout.expected $testroot/stdout
838 test_done "$testroot" "$ret"
842 (cd $testroot/wt && got revert foo > $testroot/stdout)
844 if [ $ret -ne 0 ]; then
845 echo "revert command failed unexpectedly" >&2
846 test_done "$testroot" "$ret"
850 echo -n > $testroot/stdout.expected
851 cmp -s $testroot/stdout.expected $testroot/stdout
853 if [ $ret -ne 0 ]; then
854 diff -u $testroot/stdout.expected $testroot/stdout
855 test_done "$testroot" "$ret"
859 echo "new file" > $testroot/content.expected
860 cat $testroot/wt/foo > $testroot/content
861 cmp -s $testroot/content.expected $testroot/content
863 if [ $ret -ne 0 ]; then
864 diff -u $testroot/content.expected $testroot/content
865 test_done "$testroot" "$ret"
869 echo ' M alpha' > $testroot/stdout.expected
870 echo ' D beta' >> $testroot/stdout.expected
871 echo ' A foo' >> $testroot/stdout.expected
872 (cd $testroot/wt && got status > $testroot/stdout)
873 cmp -s $testroot/stdout.expected $testroot/stdout
875 if [ $ret -ne 0 ]; then
876 diff -u $testroot/stdout.expected $testroot/stdout
877 test_done "$testroot" "$ret"
881 echo "modified file again" >> $testroot/wt/alpha
882 echo "modified added file again" >> $testroot/wt/foo
884 (cd $testroot/wt && got revert -R . > $testroot/stdout \
887 if [ $ret -ne 0 ]; then
888 echo "revert command failed unexpectedly" >&2
889 test_done "$testroot" "$ret"
893 echo "R alpha" > $testroot/stdout.expected
894 echo "R foo" >> $testroot/stdout.expected
895 cmp -s $testroot/stdout.expected $testroot/stdout
897 if [ $ret -ne 0 ]; then
898 diff -u $testroot/stdout.expected $testroot/stdout
899 test_done "$testroot" "$ret"
903 echo -n > $testroot/stderr.expected
904 cmp -s $testroot/stderr.expected $testroot/stderr
906 if [ $ret -ne 0 ]; then
907 diff -u $testroot/stderr.expected $testroot/stderr
908 test_done "$testroot" "$ret"
912 echo ' M alpha' > $testroot/stdout.expected
913 echo ' D beta' >> $testroot/stdout.expected
914 echo ' A foo' >> $testroot/stdout.expected
915 (cd $testroot/wt && got status > $testroot/stdout)
916 cmp -s $testroot/stdout.expected $testroot/stdout
918 if [ $ret -ne 0 ]; then
919 diff -u $testroot/stdout.expected $testroot/stdout
921 test_done "$testroot" "$ret"
925 local testroot=`test_init stage_diff`
926 local head_commit=`git_show_head $testroot/repo`
928 got checkout $testroot/repo $testroot/wt > /dev/null
930 if [ $ret -ne 0 ]; then
931 test_done "$testroot" "$ret"
935 echo "modified file" > $testroot/wt/alpha
936 (cd $testroot/wt && got rm beta > /dev/null)
937 echo "new file" > $testroot/wt/foo
938 (cd $testroot/wt && got add foo > /dev/null)
940 (cd $testroot/wt && got diff -s > $testroot/stdout)
941 echo -n > $testroot/stdout.expected
942 cmp -s $testroot/stdout.expected $testroot/stdout
944 if [ $ret -ne 0 ]; then
945 diff -u $testroot/stdout.expected $testroot/stdout
946 test_done "$testroot" "$ret"
950 echo ' M alpha' > $testroot/stdout.expected
951 echo ' D beta' >> $testroot/stdout.expected
952 echo ' A foo' >> $testroot/stdout.expected
953 (cd $testroot/wt && got stage alpha beta foo > /dev/null)
955 (cd $testroot/wt && got diff > $testroot/stdout)
956 echo -n > $testroot/stdout.expected
957 cmp -s $testroot/stdout.expected $testroot/stdout
959 if [ $ret -ne 0 ]; then
960 diff -u $testroot/stdout.expected $testroot/stdout
961 test_done "$testroot" "$ret"
965 echo "modified file again" > $testroot/wt/alpha
966 echo "new file changed" > $testroot/wt/foo
968 (cd $testroot/wt && got diff > $testroot/stdout)
970 echo "diff $testroot/wt" > $testroot/stdout.expected
971 echo "commit - $head_commit" >> $testroot/stdout.expected
972 echo "path + $testroot/wt" >> $testroot/stdout.expected
973 echo -n 'blob - ' >> $testroot/stdout.expected
974 (cd $testroot/wt && got stage -l alpha) | cut -d' ' -f 1 | tr -d '\n' \
975 >> $testroot/stdout.expected
976 echo ' (staged)' >> $testroot/stdout.expected
977 echo 'file + alpha' >> $testroot/stdout.expected
978 echo '--- alpha' >> $testroot/stdout.expected
979 echo '+++ alpha' >> $testroot/stdout.expected
980 echo '@@ -1 +1 @@' >> $testroot/stdout.expected
981 echo '-modified file' >> $testroot/stdout.expected
982 echo '+modified file again' >> $testroot/stdout.expected
983 echo -n 'blob - ' >> $testroot/stdout.expected
984 (cd $testroot/wt && got stage -l foo) | cut -d' ' -f 1 | tr -d '\n' \
985 >> $testroot/stdout.expected
986 echo " (staged)" >> $testroot/stdout.expected
987 echo 'file + foo' >> $testroot/stdout.expected
988 echo '--- foo' >> $testroot/stdout.expected
989 echo '+++ foo' >> $testroot/stdout.expected
990 echo '@@ -1 +1 @@' >> $testroot/stdout.expected
991 echo '-new file' >> $testroot/stdout.expected
992 echo '+new file changed' >> $testroot/stdout.expected
994 cmp -s $testroot/stdout.expected $testroot/stdout
996 if [ $ret -ne 0 ]; then
997 diff -u $testroot/stdout.expected $testroot/stdout
998 test_done "$testroot" "$ret"
1002 (cd $testroot/wt && got diff -s > $testroot/stdout)
1004 echo "diff -s $testroot/wt" > $testroot/stdout.expected
1005 echo "commit - $head_commit" >> $testroot/stdout.expected
1006 echo "path + $testroot/wt (staged changes)" >> $testroot/stdout.expected
1007 echo -n 'blob - ' >> $testroot/stdout.expected
1008 got tree -r $testroot/repo -i | grep 'alpha$' | cut -d' ' -f 1 \
1009 >> $testroot/stdout.expected
1010 echo -n 'blob + ' >> $testroot/stdout.expected
1011 (cd $testroot/wt && got stage -l alpha) | cut -d' ' -f 1 \
1012 >> $testroot/stdout.expected
1013 echo '--- alpha' >> $testroot/stdout.expected
1014 echo '+++ alpha' >> $testroot/stdout.expected
1015 echo '@@ -1 +1 @@' >> $testroot/stdout.expected
1016 echo '-alpha' >> $testroot/stdout.expected
1017 echo '+modified file' >> $testroot/stdout.expected
1018 echo -n 'blob - ' >> $testroot/stdout.expected
1019 got tree -r $testroot/repo -i | grep 'beta$' | cut -d' ' -f 1 \
1020 >> $testroot/stdout.expected
1021 echo 'blob + /dev/null' >> $testroot/stdout.expected
1022 echo '--- beta' >> $testroot/stdout.expected
1023 echo '+++ /dev/null' >> $testroot/stdout.expected
1024 echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
1025 echo '-beta' >> $testroot/stdout.expected
1026 echo 'blob - /dev/null' >> $testroot/stdout.expected
1027 echo -n 'blob + ' >> $testroot/stdout.expected
1028 (cd $testroot/wt && got stage -l foo) | cut -d' ' -f 1 \
1029 >> $testroot/stdout.expected
1030 echo '--- /dev/null' >> $testroot/stdout.expected
1031 echo '+++ foo' >> $testroot/stdout.expected
1032 echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
1033 echo '+new file' >> $testroot/stdout.expected
1035 cmp -s $testroot/stdout.expected $testroot/stdout
1037 if [ $ret -ne 0 ]; then
1038 diff -u $testroot/stdout.expected $testroot/stdout
1040 test_done "$testroot" "$ret"
1044 test_stage_histedit() {
1045 local testroot=`test_init stage_histedit`
1046 local orig_commit=`git_show_head $testroot/repo`
1048 got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1050 if [ $ret -ne 0 ]; then
1051 test_done "$testroot" "$ret"
1055 echo "modified file" > $testroot/wt/alpha
1056 (cd $testroot/wt && got stage alpha > /dev/null)
1058 echo "modified alpha on master" > $testroot/repo/alpha
1059 git -C $testroot/repo rm -q beta
1060 echo "new file on master" > $testroot/repo/epsilon/new
1061 git -C $testroot/repo add epsilon/new
1062 git_commit $testroot/repo -m "committing changes"
1063 local old_commit1=`git_show_head $testroot/repo`
1065 echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1066 git_commit $testroot/repo -m "committing to zeta on master"
1067 local old_commit2=`git_show_head $testroot/repo`
1069 echo "pick $old_commit1" > $testroot/histedit-script
1070 echo "pick $old_commit2" >> $testroot/histedit-script
1072 (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1073 > $testroot/stdout 2> $testroot/stderr)
1075 if [ $ret -eq 0 ]; then
1076 echo "got histedit command succeeded unexpectedly" >&2
1077 test_done "$testroot" "1"
1081 echo -n > $testroot/stdout.expected
1082 echo "got: alpha: file is staged" > $testroot/stderr.expected
1084 cmp -s $testroot/stderr.expected $testroot/stderr
1086 if [ $ret -ne 0 ]; then
1087 diff -u $testroot/stderr.expected $testroot/stderr
1088 test_done "$testroot" "$ret"
1091 cmp -s $testroot/stdout.expected $testroot/stdout
1093 if [ $ret -ne 0 ]; then
1094 diff -u $testroot/stdout.expected $testroot/stdout
1096 test_done "$testroot" "$ret"
1100 test_stage_rebase() {
1101 local testroot=`test_init stage_rebase`
1103 git -C $testroot/repo checkout -q -b newbranch
1104 echo "modified delta on branch" > $testroot/repo/gamma/delta
1105 git_commit $testroot/repo -m "committing to delta on newbranch"
1107 echo "modified alpha on branch" > $testroot/repo/alpha
1108 git -C $testroot/repo rm -q beta
1109 echo "new file on branch" > $testroot/repo/epsilon/new
1110 git -C $testroot/repo add epsilon/new
1111 git_commit $testroot/repo -m "committing more changes on newbranch"
1113 local orig_commit1=`git_show_parent_commit $testroot/repo`
1114 local orig_commit2=`git_show_head $testroot/repo`
1116 git -C $testroot/repo checkout -q master
1117 echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1118 git_commit $testroot/repo -m "committing to zeta on master"
1119 local master_commit=`git_show_head $testroot/repo`
1121 got checkout $testroot/repo $testroot/wt > /dev/null
1123 if [ $ret -ne 0 ]; then
1124 test_done "$testroot" "$ret"
1128 echo "modified file" > $testroot/wt/alpha
1129 (cd $testroot/wt && got stage alpha > /dev/null)
1131 (cd $testroot/wt && got rebase newbranch \
1132 > $testroot/stdout 2> $testroot/stderr)
1134 if [ $ret -eq 0 ]; then
1135 echo "got rebase command succeeded unexpectedly" >&2
1136 test_done "$testroot" "1"
1140 echo -n > $testroot/stdout.expected
1141 echo "got: alpha: file is staged" > $testroot/stderr.expected
1143 cmp -s $testroot/stderr.expected $testroot/stderr
1145 if [ $ret -ne 0 ]; then
1146 diff -u $testroot/stderr.expected $testroot/stderr
1147 test_done "$testroot" "$ret"
1150 cmp -s $testroot/stdout.expected $testroot/stdout
1152 if [ $ret -ne 0 ]; then
1153 diff -u $testroot/stdout.expected $testroot/stdout
1155 test_done "$testroot" "$ret"
1158 test_stage_update() {
1159 local testroot=`test_init stage_update`
1161 got checkout $testroot/repo $testroot/wt > /dev/null
1163 if [ $ret -ne 0 ]; then
1164 test_done "$testroot" "$ret"
1168 echo "modified file" > $testroot/wt/alpha
1169 (cd $testroot/wt && got stage alpha > /dev/null)
1171 echo "modified alpha" > $testroot/repo/alpha
1172 git_commit $testroot/repo -m "modified alpha"
1174 (cd $testroot/wt && got update > $testroot/stdout \
1175 2> $testroot/stderr)
1177 if [ $ret -eq 0 ]; then
1178 echo "got update command succeeded unexpectedly" >&2
1179 test_done "$testroot" "1"
1183 echo -n > $testroot/stdout.expected
1184 echo "got: alpha: file is staged" > $testroot/stderr.expected
1186 cmp -s $testroot/stderr.expected $testroot/stderr
1188 if [ $ret -ne 0 ]; then
1189 diff -u $testroot/stderr.expected $testroot/stderr
1190 test_done "$testroot" "$ret"
1193 cmp -s $testroot/stdout.expected $testroot/stdout
1195 if [ $ret -ne 0 ]; then
1196 diff -u $testroot/stdout.expected $testroot/stdout
1198 test_done "$testroot" "$ret"
1201 test_stage_commit_non_staged() {
1202 local testroot=`test_init stage_commit_non_staged`
1204 got checkout $testroot/repo $testroot/wt > /dev/null
1206 if [ $ret -ne 0 ]; then
1207 test_done "$testroot" "$ret"
1211 echo "modified file" > $testroot/wt/alpha
1212 (cd $testroot/wt && got rm beta > /dev/null)
1213 echo "new file" > $testroot/wt/foo
1214 (cd $testroot/wt && got add foo > /dev/null)
1215 (cd $testroot/wt && got stage alpha beta foo > /dev/null)
1217 echo "modified file" > $testroot/wt/gamma/delta
1218 (cd $testroot/wt && got commit -m "change delta" gamma/delta \
1219 > $testroot/stdout 2> $testroot/stderr)
1221 if [ $ret -eq 0 ]; then
1222 echo "got commit command succeeded unexpectedly" >&2
1223 test_done "$testroot" "1"
1227 echo -n > $testroot/stdout.expected
1228 echo "got: gamma/delta: file is not staged" > $testroot/stderr.expected
1230 cmp -s $testroot/stderr.expected $testroot/stderr
1232 if [ $ret -ne 0 ]; then
1233 diff -u $testroot/stderr.expected $testroot/stderr
1234 test_done "$testroot" "$ret"
1237 cmp -s $testroot/stdout.expected $testroot/stdout
1239 if [ $ret -ne 0 ]; then
1240 diff -u $testroot/stdout.expected $testroot/stdout
1242 test_done "$testroot" "$ret"
1245 test_stage_commit_out_of_date() {
1246 local testroot=`test_init stage_commit_out_of_date`
1248 got checkout $testroot/repo $testroot/wt > /dev/null
1250 if [ $ret -ne 0 ]; then
1251 test_done "$testroot" "$ret"
1255 echo "modified file" > $testroot/wt/alpha
1256 (cd $testroot/wt && got rm beta > /dev/null)
1257 echo "new file" > $testroot/wt/foo
1258 (cd $testroot/wt && got add foo > /dev/null)
1259 (cd $testroot/wt && got stage alpha beta foo > /dev/null)
1261 echo "changed file" > $testroot/repo/alpha
1262 git_commit $testroot/repo -m "changed alpha in repo"
1264 (cd $testroot/wt && got commit -m "try to commit" > $testroot/stdout \
1265 2> $testroot/stderr)
1267 if [ $ret -eq 0 ]; then
1268 echo "got commit command succeeded unexpectedly" >&2
1269 test_done "$testroot" "1"
1273 echo -n > $testroot/stdout.expected
1274 echo -n "got: work tree must be updated before these changes " \
1275 > $testroot/stderr.expected
1276 echo "can be committed" >> $testroot/stderr.expected
1278 cmp -s $testroot/stderr.expected $testroot/stderr
1280 if [ $ret -ne 0 ]; then
1281 diff -u $testroot/stderr.expected $testroot/stderr
1282 test_done "$testroot" "$ret"
1285 cmp -s $testroot/stdout.expected $testroot/stdout
1287 if [ $ret -ne 0 ]; then
1288 diff -u $testroot/stdout.expected $testroot/stdout
1289 test_done "$testroot" "$ret"
1293 (cd $testroot/wt && got update > $testroot/stdout \
1294 2> $testroot/stderr)
1295 echo -n > $testroot/stdout.expected
1296 echo "got: alpha: file is staged" > $testroot/stderr.expected
1298 cmp -s $testroot/stderr.expected $testroot/stderr
1300 if [ $ret -ne 0 ]; then
1301 diff -u $testroot/stderr.expected $testroot/stderr
1302 test_done "$testroot" "$ret"
1305 cmp -s $testroot/stdout.expected $testroot/stdout
1307 if [ $ret -ne 0 ]; then
1308 diff -u $testroot/stdout.expected $testroot/stdout
1309 test_done "$testroot" "$ret"
1313 (cd $testroot/wt && got unstage -R > /dev/null)
1314 (cd $testroot/wt && got update > $testroot/stdout)
1316 if [ $ret -ne 0 ]; then
1317 echo "got update command failed unexpectedly" >&2
1318 test_done "$testroot" "$ret"
1322 (cd $testroot/wt && got status > $testroot/stdout)
1323 echo "C alpha" > $testroot/stdout.expected
1324 echo "D beta" >> $testroot/stdout.expected
1325 echo "A foo" >> $testroot/stdout.expected
1326 cmp -s $testroot/stdout.expected $testroot/stdout
1328 if [ $ret -ne 0 ]; then
1329 diff -u $testroot/stdout.expected $testroot/stdout
1330 test_done "$testroot" "$ret"
1335 echo "resolved file" > $testroot/wt/alpha
1337 (cd $testroot/wt && got stage -R > /dev/null)
1339 (cd $testroot/wt && got commit -m "try again" > $testroot/stdout)
1341 if [ $ret -ne 0 ]; then
1342 echo "got commit command failed unexpectedly" >&2
1343 test_done "$testroot" "$ret"
1347 local commit_id=`git_show_head $testroot/repo`
1348 echo "A foo" > $testroot/stdout.expected
1349 echo "M alpha" >> $testroot/stdout.expected
1350 echo "D beta" >> $testroot/stdout.expected
1351 echo "Created commit $commit_id" >> $testroot/stdout.expected
1352 cmp -s $testroot/stdout.expected $testroot/stdout
1354 if [ $ret -ne 0 ]; then
1355 diff -u $testroot/stdout.expected $testroot/stdout
1357 test_done "$testroot" "$ret"
1361 test_stage_commit() {
1362 local testroot=`test_init stage_commit`
1363 local first_commit=`git_show_head $testroot/repo`
1365 got checkout $testroot/repo $testroot/wt > /dev/null
1367 if [ $ret -ne 0 ]; then
1368 test_done "$testroot" "$ret"
1372 echo "modified file" > $testroot/wt/alpha
1373 (cd $testroot/wt && got rm beta > /dev/null)
1374 echo "new file" > $testroot/wt/foo
1375 (cd $testroot/wt && got add foo > /dev/null)
1376 echo "modified file" > $testroot/wt/alpha
1377 (cd $testroot/wt && got stage alpha beta foo > /dev/null)
1379 echo "modified file again" > $testroot/wt/alpha
1380 echo "new file changed" > $testroot/wt/foo
1381 echo "non-staged change" > $testroot/wt/gamma/delta
1382 echo "non-staged new file" > $testroot/wt/epsilon/new
1383 (cd $testroot/wt && got add epsilon/new > /dev/null)
1384 (cd $testroot/wt && got rm epsilon/zeta > /dev/null)
1386 (cd $testroot/wt && got stage -l alpha) | cut -d' ' -f 1 \
1387 > $testroot/blob_id_alpha
1388 (cd $testroot/wt && got stage -l foo) | cut -d' ' -f 1 \
1389 > $testroot/blob_id_foo
1391 (cd $testroot/wt && got commit -m "staged changes" \
1394 if [ $ret -ne 0 ]; then
1395 echo "got commit command failed unexpectedly" >&2
1396 test_done "$testroot" "1"
1400 local head_commit=`git_show_head $testroot/repo`
1401 echo "A foo" > $testroot/stdout.expected
1402 echo "M alpha" >> $testroot/stdout.expected
1403 echo "D beta" >> $testroot/stdout.expected
1404 echo "Created commit $head_commit" >> $testroot/stdout.expected
1406 cmp -s $testroot/stdout.expected $testroot/stdout
1408 if [ $ret -ne 0 ]; then
1409 diff -u $testroot/stdout.expected $testroot/stdout
1410 test_done "$testroot" "$ret"
1414 got diff -r $testroot/repo $first_commit $head_commit \
1417 echo "diff $first_commit $head_commit" \
1418 > $testroot/stdout.expected
1419 echo "commit - $first_commit" >> $testroot/stdout.expected
1420 echo "commit + $head_commit" >> $testroot/stdout.expected
1421 echo -n 'blob - ' >> $testroot/stdout.expected
1422 got tree -r $testroot/repo -i -c $first_commit | \
1423 grep 'alpha$' | cut -d' ' -f 1 \
1424 >> $testroot/stdout.expected
1425 echo -n 'blob + ' >> $testroot/stdout.expected
1426 cat $testroot/blob_id_alpha >> $testroot/stdout.expected
1427 echo '--- alpha' >> $testroot/stdout.expected
1428 echo '+++ alpha' >> $testroot/stdout.expected
1429 echo '@@ -1 +1 @@' >> $testroot/stdout.expected
1430 echo '-alpha' >> $testroot/stdout.expected
1431 echo '+modified file' >> $testroot/stdout.expected
1432 echo -n 'blob - ' >> $testroot/stdout.expected
1433 got tree -r $testroot/repo -i -c $first_commit \
1434 | grep 'beta$' | cut -d' ' -f 1 | tr -d '\n' \
1435 >> $testroot/stdout.expected
1436 echo " (mode 644)" >> $testroot/stdout.expected
1437 echo 'blob + /dev/null' >> $testroot/stdout.expected
1438 echo '--- beta' >> $testroot/stdout.expected
1439 echo '+++ /dev/null' >> $testroot/stdout.expected
1440 echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
1441 echo '-beta' >> $testroot/stdout.expected
1442 echo 'blob - /dev/null' >> $testroot/stdout.expected
1443 echo -n 'blob + ' >> $testroot/stdout.expected
1444 cat $testroot/blob_id_foo | tr -d '\n' >> $testroot/stdout.expected
1445 echo " (mode 644)" >> $testroot/stdout.expected
1446 echo '--- /dev/null' >> $testroot/stdout.expected
1447 echo '+++ foo' >> $testroot/stdout.expected
1448 echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
1449 echo '+new file' >> $testroot/stdout.expected
1451 cmp -s $testroot/stdout.expected $testroot/stdout
1453 if [ $ret -ne 0 ]; then
1454 diff -u $testroot/stdout.expected $testroot/stdout
1455 test_done "$testroot" "$ret"
1459 echo 'M alpha' > $testroot/stdout.expected
1460 echo 'A epsilon/new' >> $testroot/stdout.expected
1461 echo 'D epsilon/zeta' >> $testroot/stdout.expected
1462 echo 'M foo' >> $testroot/stdout.expected
1463 echo 'M gamma/delta' >> $testroot/stdout.expected
1465 (cd $testroot/wt && got status > $testroot/stdout)
1466 cmp -s $testroot/stdout.expected $testroot/stdout
1468 if [ $ret -ne 0 ]; then
1469 diff -u $testroot/stdout.expected $testroot/stdout
1471 test_done "$testroot" "$ret"
1474 test_stage_patch() {
1475 local testroot=`test_init stage_patch`
1477 seq 16 > $testroot/repo/numbers
1478 git -C $testroot/repo add numbers
1479 git_commit $testroot/repo -m "added numbers file"
1480 local commit_id=`git_show_head $testroot/repo`
1482 got checkout $testroot/repo $testroot/wt > /dev/null
1484 if [ $ret -ne 0 ]; then
1485 test_done "$testroot" "$ret"
1489 ed -s $testroot/wt/numbers <<-\EOF
1496 # don't stage any hunks
1497 printf "n\nn\nn\n" > $testroot/patchscript
1498 (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1499 numbers > $testroot/stdout 2> $testroot/stderr)
1501 if [ $ret -eq 0 ]; then
1502 echo "got stage command succeeded unexpectedly" >&2
1503 test_done "$testroot" "1"
1506 cat > $testroot/stdout.expected <<EOF
1507 -----------------------------------------------
1515 -----------------------------------------------
1516 M numbers (change 1 of 3)
1517 stage this change? [y/n/q] n
1518 -----------------------------------------------
1528 -----------------------------------------------
1529 M numbers (change 2 of 3)
1530 stage this change? [y/n/q] n
1531 -----------------------------------------------
1538 -----------------------------------------------
1539 M numbers (change 3 of 3)
1540 stage this change? [y/n/q] n
1542 cmp -s $testroot/stdout.expected $testroot/stdout
1544 if [ $ret -ne 0 ]; then
1545 diff -u $testroot/stdout.expected $testroot/stdout
1546 test_done "$testroot" "$ret"
1550 echo "got: no changes to stage" > $testroot/stderr.expected
1551 cmp -s $testroot/stderr.expected $testroot/stderr
1553 if [ $ret -ne 0 ]; then
1554 diff -u $testroot/stderr.expected $testroot/stderr
1555 test_done "$testroot" "$ret"
1560 (cd $testroot/wt && got status > $testroot/stdout)
1561 echo "M numbers" > $testroot/stdout.expected
1562 cmp -s $testroot/stdout.expected $testroot/stdout
1564 if [ $ret -ne 0 ]; then
1565 diff -u $testroot/stdout.expected $testroot/stdout
1566 test_done "$testroot" "$ret"
1571 printf "n\ny\nn\n" > $testroot/patchscript
1572 (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1573 numbers > $testroot/stdout)
1575 cat > $testroot/stdout.expected <<EOF
1576 -----------------------------------------------
1584 -----------------------------------------------
1585 M numbers (change 1 of 3)
1586 stage this change? [y/n/q] n
1587 -----------------------------------------------
1597 -----------------------------------------------
1598 M numbers (change 2 of 3)
1599 stage this change? [y/n/q] y
1600 -----------------------------------------------
1607 -----------------------------------------------
1608 M numbers (change 3 of 3)
1609 stage this change? [y/n/q] n
1611 cmp -s $testroot/stdout.expected $testroot/stdout
1613 if [ $ret -ne 0 ]; then
1614 diff -u $testroot/stdout.expected $testroot/stdout
1615 test_done "$testroot" "$ret"
1619 (cd $testroot/wt && got status > $testroot/stdout)
1620 echo "MM numbers" > $testroot/stdout.expected
1621 cmp -s $testroot/stdout.expected $testroot/stdout
1623 if [ $ret -ne 0 ]; then
1624 diff -u $testroot/stdout.expected $testroot/stdout
1625 test_done "$testroot" "$ret"
1629 (cd $testroot/wt && got diff -s > $testroot/stdout)
1631 echo "diff -s $testroot/wt" > $testroot/stdout.expected
1632 echo "commit - $commit_id" >> $testroot/stdout.expected
1633 echo "path + $testroot/wt (staged changes)" >> $testroot/stdout.expected
1634 echo -n 'blob - ' >> $testroot/stdout.expected
1635 got tree -r $testroot/repo -i -c $commit_id \
1636 | grep 'numbers$' | cut -d' ' -f 1 \
1637 >> $testroot/stdout.expected
1638 echo -n 'blob + ' >> $testroot/stdout.expected
1639 (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 \
1640 >> $testroot/stdout.expected
1641 echo "--- numbers" >> $testroot/stdout.expected
1642 echo "+++ numbers" >> $testroot/stdout.expected
1643 echo "@@ -4,7 +4,7 @@" >> $testroot/stdout.expected
1644 echo " 4" >> $testroot/stdout.expected
1645 echo " 5" >> $testroot/stdout.expected
1646 echo " 6" >> $testroot/stdout.expected
1647 echo "-7" >> $testroot/stdout.expected
1648 echo "+b" >> $testroot/stdout.expected
1649 echo " 8" >> $testroot/stdout.expected
1650 echo " 9" >> $testroot/stdout.expected
1651 echo " 10" >> $testroot/stdout.expected
1652 cmp -s $testroot/stdout.expected $testroot/stdout
1654 if [ $ret -ne 0 ]; then
1655 diff -u $testroot/stdout.expected $testroot/stdout
1656 test_done "$testroot" "$ret"
1660 (cd $testroot/wt && got unstage -R >/dev/null)
1662 if [ $ret -ne 0 ]; then
1663 echo "got stage command failed unexpectedly" >&2
1664 test_done "$testroot" "1"
1667 (cd $testroot/wt && got status > $testroot/stdout)
1668 echo "M numbers" > $testroot/stdout.expected
1669 cmp -s $testroot/stdout.expected $testroot/stdout
1671 if [ $ret -ne 0 ]; then
1672 diff -u $testroot/stdout.expected $testroot/stdout
1673 test_done "$testroot" "$ret"
1678 printf "n\nn\ny\n" > $testroot/patchscript
1679 (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1680 numbers > $testroot/stdout)
1682 cat > $testroot/stdout.expected <<EOF
1683 -----------------------------------------------
1691 -----------------------------------------------
1692 M numbers (change 1 of 3)
1693 stage this change? [y/n/q] n
1694 -----------------------------------------------
1704 -----------------------------------------------
1705 M numbers (change 2 of 3)
1706 stage this change? [y/n/q] n
1707 -----------------------------------------------
1714 -----------------------------------------------
1715 M numbers (change 3 of 3)
1716 stage this change? [y/n/q] y
1718 cmp -s $testroot/stdout.expected $testroot/stdout
1720 if [ $ret -ne 0 ]; then
1721 diff -u $testroot/stdout.expected $testroot/stdout
1722 test_done "$testroot" "$ret"
1726 (cd $testroot/wt && got status > $testroot/stdout)
1727 echo "MM numbers" > $testroot/stdout.expected
1728 cmp -s $testroot/stdout.expected $testroot/stdout
1730 if [ $ret -ne 0 ]; then
1731 diff -u $testroot/stdout.expected $testroot/stdout
1732 test_done "$testroot" "$ret"
1736 (cd $testroot/wt && got diff -s > $testroot/stdout)
1738 echo "diff -s $testroot/wt" > $testroot/stdout.expected
1739 echo "commit - $commit_id" >> $testroot/stdout.expected
1740 echo "path + $testroot/wt (staged changes)" >> $testroot/stdout.expected
1741 echo -n 'blob - ' >> $testroot/stdout.expected
1742 got tree -r $testroot/repo -i -c $commit_id \
1743 | grep 'numbers$' | cut -d' ' -f 1 \
1744 >> $testroot/stdout.expected
1745 echo -n 'blob + ' >> $testroot/stdout.expected
1746 (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 \
1747 >> $testroot/stdout.expected
1748 echo "--- numbers" >> $testroot/stdout.expected
1749 echo "+++ numbers" >> $testroot/stdout.expected
1750 echo "@@ -13,4 +13,4 @@" >> $testroot/stdout.expected
1751 echo " 13" >> $testroot/stdout.expected
1752 echo " 14" >> $testroot/stdout.expected
1753 echo " 15" >> $testroot/stdout.expected
1754 echo "-16" >> $testroot/stdout.expected
1755 echo "+c" >> $testroot/stdout.expected
1756 cmp -s $testroot/stdout.expected $testroot/stdout
1758 if [ $ret -ne 0 ]; then
1759 diff -u $testroot/stdout.expected $testroot/stdout
1761 test_done "$testroot" "$ret"
1764 test_stage_patch_twice() {
1765 local testroot=`test_init stage_patch_twice`
1767 seq 16 > $testroot/repo/numbers
1768 git -C $testroot/repo add numbers
1769 git_commit $testroot/repo -m "added numbers file"
1770 local commit_id=`git_show_head $testroot/repo`
1772 got checkout $testroot/repo $testroot/wt > /dev/null
1774 if [ $ret -ne 0 ]; then
1775 test_done "$testroot" "$ret"
1779 ed -s $testroot/wt/numbers <<-\EOF
1787 printf "n\ny\nn\n" > $testroot/patchscript
1788 (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1789 numbers > $testroot/stdout)
1791 cat > $testroot/stdout.expected <<EOF
1792 -----------------------------------------------
1800 -----------------------------------------------
1801 M numbers (change 1 of 3)
1802 stage this change? [y/n/q] n
1803 -----------------------------------------------
1813 -----------------------------------------------
1814 M numbers (change 2 of 3)
1815 stage this change? [y/n/q] y
1816 -----------------------------------------------
1823 -----------------------------------------------
1824 M numbers (change 3 of 3)
1825 stage this change? [y/n/q] n
1827 cmp -s $testroot/stdout.expected $testroot/stdout
1829 if [ $ret -ne 0 ]; then
1830 diff -u $testroot/stdout.expected $testroot/stdout
1831 test_done "$testroot" "$ret"
1835 (cd $testroot/wt && got status > $testroot/stdout)
1836 echo "MM numbers" > $testroot/stdout.expected
1837 cmp -s $testroot/stdout.expected $testroot/stdout
1839 if [ $ret -ne 0 ]; then
1840 diff -u $testroot/stdout.expected $testroot/stdout
1841 test_done "$testroot" "$ret"
1846 printf "n\ny\n" > $testroot/patchscript
1847 (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1848 numbers > $testroot/stdout)
1850 cat > $testroot/stdout.expected <<EOF
1851 -----------------------------------------------
1859 -----------------------------------------------
1860 M numbers (change 1 of 2)
1861 stage this change? [y/n/q] n
1862 -----------------------------------------------
1869 -----------------------------------------------
1870 M numbers (change 2 of 2)
1871 stage this change? [y/n/q] y
1873 cmp -s $testroot/stdout.expected $testroot/stdout
1875 if [ $ret -ne 0 ]; then
1876 diff -u $testroot/stdout.expected $testroot/stdout
1877 test_done "$testroot" "$ret"
1881 (cd $testroot/wt && got status > $testroot/stdout)
1882 echo "MM numbers" > $testroot/stdout.expected
1883 cmp -s $testroot/stdout.expected $testroot/stdout
1885 if [ $ret -ne 0 ]; then
1886 diff -u $testroot/stdout.expected $testroot/stdout
1887 test_done "$testroot" "$ret"
1891 (cd $testroot/wt && got diff -s > $testroot/stdout)
1893 echo "diff -s $testroot/wt" > $testroot/stdout.expected
1894 echo "commit - $commit_id" >> $testroot/stdout.expected
1895 echo "path + $testroot/wt (staged changes)" >> $testroot/stdout.expected
1896 echo -n 'blob - ' >> $testroot/stdout.expected
1897 got tree -r $testroot/repo -i -c $commit_id \
1898 | grep 'numbers$' | cut -d' ' -f 1 \
1899 >> $testroot/stdout.expected
1900 echo -n 'blob + ' >> $testroot/stdout.expected
1901 (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 \
1902 >> $testroot/stdout.expected
1903 echo "--- numbers" >> $testroot/stdout.expected
1904 echo "+++ numbers" >> $testroot/stdout.expected
1905 cat >> $testroot/stdout.expected <<EOF
1922 cmp -s $testroot/stdout.expected $testroot/stdout
1924 if [ $ret -ne 0 ]; then
1925 diff -u $testroot/stdout.expected $testroot/stdout
1926 test_done "$testroot" "$ret"
1930 (cd $testroot/wt && got diff > $testroot/stdout)
1932 echo "diff $testroot/wt" > $testroot/stdout.expected
1933 echo "commit - $commit_id" >> $testroot/stdout.expected
1934 echo "path + $testroot/wt" >> $testroot/stdout.expected
1935 echo -n 'blob - ' >> $testroot/stdout.expected
1936 (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 | \
1937 tr -d '\n' >> $testroot/stdout.expected
1938 echo " (staged)" >> $testroot/stdout.expected
1939 echo 'file + numbers' >> $testroot/stdout.expected
1940 echo "--- numbers" >> $testroot/stdout.expected
1941 echo "+++ numbers" >> $testroot/stdout.expected
1942 cat >> $testroot/stdout.expected <<EOF
1951 cmp -s $testroot/stdout.expected $testroot/stdout
1953 if [ $ret -ne 0 ]; then
1954 diff -u $testroot/stdout.expected $testroot/stdout
1956 test_done "$testroot" "$ret"
1959 test_stage_patch_added() {
1960 local testroot=`test_init stage_patch_added`
1961 local commit_id=`git_show_head $testroot/repo`
1963 got checkout $testroot/repo $testroot/wt > /dev/null
1965 if [ $ret -ne 0 ]; then
1966 test_done "$testroot" "$ret"
1970 echo "new" > $testroot/wt/epsilon/new
1971 (cd $testroot/wt && got add epsilon/new > /dev/null)
1973 printf "y\n" > $testroot/patchscript
1974 (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1975 epsilon/new > $testroot/stdout)
1977 echo "A epsilon/new" > $testroot/stdout.expected
1978 echo "stage this addition? [y/n] y" >> $testroot/stdout.expected
1979 cmp -s $testroot/stdout.expected $testroot/stdout
1981 if [ $ret -ne 0 ]; then
1982 diff -u $testroot/stdout.expected $testroot/stdout
1983 test_done "$testroot" "$ret"
1987 (cd $testroot/wt && got status > $testroot/stdout)
1988 echo " A epsilon/new" > $testroot/stdout.expected
1989 cmp -s $testroot/stdout.expected $testroot/stdout
1991 if [ $ret -ne 0 ]; then
1992 diff -u $testroot/stdout.expected $testroot/stdout
1993 test_done "$testroot" "$ret"
1997 (cd $testroot/wt && got diff -s > $testroot/stdout)
1999 echo "diff -s $testroot/wt" > $testroot/stdout.expected
2000 echo "commit - $commit_id" >> $testroot/stdout.expected
2001 echo "path + $testroot/wt (staged changes)" >> $testroot/stdout.expected
2002 echo 'blob - /dev/null' >> $testroot/stdout.expected
2003 echo -n 'blob + ' >> $testroot/stdout.expected
2004 (cd $testroot/wt && got stage -l epsilon/new) | cut -d' ' -f 1 \
2005 >> $testroot/stdout.expected
2006 echo "--- /dev/null" >> $testroot/stdout.expected
2007 echo "+++ epsilon/new" >> $testroot/stdout.expected
2008 echo "@@ -0,0 +1 @@" >> $testroot/stdout.expected
2009 echo "+new" >> $testroot/stdout.expected
2010 cmp -s $testroot/stdout.expected $testroot/stdout
2012 if [ $ret -ne 0 ]; then
2013 diff -u $testroot/stdout.expected $testroot/stdout
2015 test_done "$testroot" "$ret"
2018 test_stage_patch_added_twice() {
2019 local testroot=`test_init stage_patch_added_twice`
2020 local commit_id=`git_show_head $testroot/repo`
2022 got checkout $testroot/repo $testroot/wt > /dev/null
2024 if [ $ret -ne 0 ]; then
2025 test_done "$testroot" "$ret"
2029 echo "new" > $testroot/wt/epsilon/new
2030 (cd $testroot/wt && got add epsilon/new > /dev/null)
2032 printf "y\n" > $testroot/patchscript
2033 (cd $testroot/wt && got stage -F $testroot/patchscript -p \
2034 epsilon/new > $testroot/stdout)
2036 echo "A epsilon/new" > $testroot/stdout.expected
2037 echo "stage this addition? [y/n] y" >> $testroot/stdout.expected
2038 cmp -s $testroot/stdout.expected $testroot/stdout
2040 if [ $ret -ne 0 ]; then
2041 diff -u $testroot/stdout.expected $testroot/stdout
2042 test_done "$testroot" "$ret"
2046 (cd $testroot/wt && got status > $testroot/stdout)
2047 echo " A epsilon/new" > $testroot/stdout.expected
2048 cmp -s $testroot/stdout.expected $testroot/stdout
2050 if [ $ret -ne 0 ]; then
2051 diff -u $testroot/stdout.expected $testroot/stdout
2052 test_done "$testroot" "$ret"
2056 (cd $testroot/wt && got stage -F $testroot/patchscript -p \
2057 epsilon/new > $testroot/stdout 2> $testroot/stderr)
2059 if [ $ret -eq 0 ]; then
2060 echo "got stage command succeeded unexpectedly" >&2
2061 test_done "$testroot" "1"
2065 echo "got: no changes to stage" > $testroot/stderr.expected
2066 cmp -s $testroot/stderr.expected $testroot/stderr
2068 if [ $ret -ne 0 ]; then
2069 diff -u $testroot/stderr.expected $testroot/stderr
2070 test_done "$testroot" "$ret"
2074 echo -n > $testroot/stdout.expected
2075 cmp -s $testroot/stdout.expected $testroot/stdout
2077 if [ $ret -ne 0 ]; then
2078 diff -u $testroot/stdout.expected $testroot/stdout
2080 test_done "$testroot" "$ret"
2083 test_stage_patch_removed() {
2084 local testroot=`test_init stage_patch_removed`
2085 local commit_id=`git_show_head $testroot/repo`
2087 got checkout $testroot/repo $testroot/wt > /dev/null
2089 if [ $ret -ne 0 ]; then
2090 test_done "$testroot" "$ret"
2094 (cd $testroot/wt && got rm beta > /dev/null)
2096 printf "y\n" > $testroot/patchscript
2097 (cd $testroot/wt && got stage -F $testroot/patchscript -p \
2098 beta > $testroot/stdout)
2100 echo -n > $testroot/stdout.expected
2102 echo "D beta" > $testroot/stdout.expected
2103 echo "stage this deletion? [y/n] y" >> $testroot/stdout.expected
2104 cmp -s $testroot/stdout.expected $testroot/stdout
2106 if [ $ret -ne 0 ]; then
2107 diff -u $testroot/stdout.expected $testroot/stdout
2108 test_done "$testroot" "$ret"
2112 (cd $testroot/wt && got status > $testroot/stdout)
2113 echo " D beta" > $testroot/stdout.expected
2114 cmp -s $testroot/stdout.expected $testroot/stdout
2116 if [ $ret -ne 0 ]; then
2117 diff -u $testroot/stdout.expected $testroot/stdout
2118 test_done "$testroot" "$ret"
2122 (cd $testroot/wt && got diff -s > $testroot/stdout)
2124 echo "diff -s $testroot/wt" > $testroot/stdout.expected
2125 echo "commit - $commit_id" >> $testroot/stdout.expected
2126 echo "path + $testroot/wt (staged changes)" >> $testroot/stdout.expected
2127 echo -n 'blob - ' >> $testroot/stdout.expected
2128 (cd $testroot/wt && got stage -l beta) | cut -d' ' -f 1 \
2129 >> $testroot/stdout.expected
2130 echo 'blob + /dev/null' >> $testroot/stdout.expected
2131 echo "--- beta" >> $testroot/stdout.expected
2132 echo "+++ /dev/null" >> $testroot/stdout.expected
2133 echo "@@ -1 +0,0 @@" >> $testroot/stdout.expected
2134 echo "-beta" >> $testroot/stdout.expected
2135 cmp -s $testroot/stdout.expected $testroot/stdout
2137 if [ $ret -ne 0 ]; then
2138 diff -u $testroot/stdout.expected $testroot/stdout
2140 test_done "$testroot" "$ret"
2143 test_stage_patch_removed_twice() {
2144 local testroot=`test_init stage_patch_removed_twice`
2145 local commit_id=`git_show_head $testroot/repo`
2147 got checkout $testroot/repo $testroot/wt > /dev/null
2149 if [ $ret -ne 0 ]; then
2150 test_done "$testroot" "$ret"
2154 (cd $testroot/wt && got rm beta > /dev/null)
2156 printf "y\n" > $testroot/patchscript
2157 (cd $testroot/wt && got stage -F $testroot/patchscript -p \
2158 beta > $testroot/stdout)
2160 echo -n > $testroot/stdout.expected
2162 echo "D beta" > $testroot/stdout.expected
2163 echo "stage this deletion? [y/n] y" >> $testroot/stdout.expected
2164 cmp -s $testroot/stdout.expected $testroot/stdout
2166 if [ $ret -ne 0 ]; then
2167 diff -u $testroot/stdout.expected $testroot/stdout
2168 test_done "$testroot" "$ret"
2172 (cd $testroot/wt && got status > $testroot/stdout)
2173 echo " D beta" > $testroot/stdout.expected
2174 cmp -s $testroot/stdout.expected $testroot/stdout
2176 if [ $ret -ne 0 ]; then
2177 diff -u $testroot/stdout.expected $testroot/stdout
2178 test_done "$testroot" "$ret"
2182 (cd $testroot/wt && got stage -F $testroot/patchscript -p beta \
2183 > $testroot/stdout 2> $testroot/stderr)
2185 if [ $ret -eq 0 ]; then
2186 echo "got stage command succeeded unexpectedly" >&2
2187 test_done "$testroot" "1"
2191 echo "got: no changes to stage" > $testroot/stderr.expected
2192 cmp -s $testroot/stderr.expected $testroot/stderr
2194 if [ $ret -ne 0 ]; then
2195 diff -u $testroot/stderr.expected $testroot/stderr
2196 test_done "$testroot" "$ret"
2200 echo -n > $testroot/stdout.expected
2201 cmp -s $testroot/stdout.expected $testroot/stdout
2203 if [ $ret -ne 0 ]; then
2204 diff -u $testroot/stdout.expected $testroot/stdout
2206 test_done "$testroot" "$ret"
2209 test_stage_patch_reversed() {
2210 local testroot=`test_init stage_patch_reversed`
2212 got checkout $testroot/repo $testroot/wt > /dev/null
2214 if [ $ret -ne 0 ]; then
2215 test_done "$testroot" "$ret"
2219 echo 'ALPHA' > $testroot/wt/alpha
2220 (cd $testroot/wt && got stage alpha > $testroot/stdout)
2222 if [ $ret -ne 0 ]; then
2223 test_done "$testroot" "$ret"
2227 echo ' M alpha' > $testroot/stdout.expected
2228 cmp -s $testroot/stdout.expected $testroot/stdout
2230 if [ $ret -ne 0 ]; then
2231 diff -u $testroot/stdout.expected $testroot/stdout
2232 test_done "$testroot" "$ret"
2236 echo 'alpha' > $testroot/wt/alpha
2237 (cd $testroot/wt && got stage alpha > $testroot/stdout)
2239 if [ $ret -ne 0 ]; then
2240 test_done "$testroot" "$ret"
2244 echo ' M alpha' > $testroot/stdout.expected
2245 cmp -s $testroot/stdout.expected $testroot/stdout
2247 if [ $ret -ne 0 ]; then
2248 diff -u $testroot/stdout.expected $testroot/stdout
2249 test_done "$testroot" "$ret"
2253 (cd $testroot/wt && got status > $testroot/stdout)
2254 cmp -s /dev/null $testroot/stdout
2256 if [ $ret -ne 0 ]; then
2257 diff -u /dev/null $testroot/stdout
2259 test_done "$testroot" "$ret"
2262 test_stage_patch_quit() {
2263 local testroot=`test_init stage_patch_quit`
2265 seq 16 > $testroot/repo/numbers
2266 echo zzz > $testroot/repo/zzz
2267 git -C $testroot/repo add numbers zzz
2268 git_commit $testroot/repo -m "added files"
2269 local commit_id=`git_show_head $testroot/repo`
2271 got checkout $testroot/repo $testroot/wt > /dev/null
2273 if [ $ret -ne 0 ]; then
2274 test_done "$testroot" "$ret"
2278 ed -s $testroot/wt/numbers <<-\EOF
2284 (cd $testroot/wt && got rm zzz > /dev/null)
2286 # stage first hunk and quit; and don't pass a path argument to
2287 # ensure that we don't skip asking about the 'zzz' file after 'quit'
2288 printf "y\nq\nn\n" > $testroot/patchscript
2289 (cd $testroot/wt && got stage -R -F $testroot/patchscript -p \
2292 if [ $ret -ne 0 ]; then
2293 echo "got stage command failed unexpectedly" >&2
2294 test_done "$testroot" "1"
2297 cat > $testroot/stdout.expected <<EOF
2298 -----------------------------------------------
2306 -----------------------------------------------
2307 M numbers (change 1 of 3)
2308 stage this change? [y/n/q] y
2309 -----------------------------------------------
2319 -----------------------------------------------
2320 M numbers (change 2 of 3)
2321 stage this change? [y/n/q] q
2323 stage this deletion? [y/n] n
2325 cmp -s $testroot/stdout.expected $testroot/stdout
2327 if [ $ret -ne 0 ]; then
2328 diff -u $testroot/stdout.expected $testroot/stdout
2329 test_done "$testroot" "$ret"
2333 (cd $testroot/wt && got status > $testroot/stdout)
2334 echo "MM numbers" > $testroot/stdout.expected
2335 echo "D zzz" >> $testroot/stdout.expected
2336 cmp -s $testroot/stdout.expected $testroot/stdout
2338 if [ $ret -ne 0 ]; then
2339 diff -u $testroot/stdout.expected $testroot/stdout
2340 test_done "$testroot" "$ret"
2344 (cd $testroot/wt && got diff -s > $testroot/stdout)
2346 echo "diff -s $testroot/wt" > $testroot/stdout.expected
2347 echo "commit - $commit_id" >> $testroot/stdout.expected
2348 echo "path + $testroot/wt (staged changes)" >> $testroot/stdout.expected
2349 echo -n 'blob - ' >> $testroot/stdout.expected
2350 got tree -r $testroot/repo -i -c $commit_id \
2351 | grep 'numbers$' | cut -d' ' -f 1 \
2352 >> $testroot/stdout.expected
2353 echo -n 'blob + ' >> $testroot/stdout.expected
2354 (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 \
2355 >> $testroot/stdout.expected
2356 echo "--- numbers" >> $testroot/stdout.expected
2357 echo "+++ numbers" >> $testroot/stdout.expected
2358 echo "@@ -1,5 +1,5 @@" >> $testroot/stdout.expected
2359 echo " 1" >> $testroot/stdout.expected
2360 echo "-2" >> $testroot/stdout.expected
2361 echo "+a" >> $testroot/stdout.expected
2362 echo " 3" >> $testroot/stdout.expected
2363 echo " 4" >> $testroot/stdout.expected
2364 echo " 5" >> $testroot/stdout.expected
2365 cmp -s $testroot/stdout.expected $testroot/stdout
2367 if [ $ret -ne 0 ]; then
2368 diff -u $testroot/stdout.expected $testroot/stdout
2370 test_done "$testroot" "$ret"
2374 test_stage_patch_incomplete_script() {
2375 local testroot=`test_init stage_incomplete_script`
2377 seq 16 > $testroot/repo/numbers
2378 echo zzz > $testroot/repo/zzz
2379 git -C $testroot/repo add numbers zzz
2380 git_commit $testroot/repo -m "added files"
2381 local commit_id=`git_show_head $testroot/repo`
2383 got checkout $testroot/repo $testroot/wt > /dev/null
2385 if [ $ret -ne 0 ]; then
2386 test_done "$testroot" "$ret"
2390 ed -s $testroot/wt/numbers <<-\EOF
2397 # stage first hunk and then stop responding; got should error out
2398 printf "y\n" > $testroot/patchscript
2399 (cd $testroot/wt && got stage -R -F $testroot/patchscript -p \
2400 > $testroot/stdout 2> $testroot/stderr)
2402 if [ $ret -eq 0 ]; then
2403 echo "got stage command succeeded unexpectedly" >&2
2404 test_done "$testroot" "1"
2407 cat > $testroot/stdout.expected <<EOF
2408 -----------------------------------------------
2416 -----------------------------------------------
2417 M numbers (change 1 of 3)
2418 stage this change? [y/n/q] y
2419 -----------------------------------------------
2429 -----------------------------------------------
2430 M numbers (change 2 of 3)
2432 echo -n "stage this change? [y/n/q] " >> $testroot/stdout.expected
2433 echo "got: invalid patch choice" > $testroot/stderr.expected
2434 cmp -s $testroot/stderr.expected $testroot/stderr
2436 if [ $ret -ne 0 ]; then
2437 diff -u $testroot/stderr.expected $testroot/stderr
2438 test_done "$testroot" "$ret"
2442 cmp -s $testroot/stdout.expected $testroot/stdout
2444 if [ $ret -ne 0 ]; then
2445 diff -u $testroot/stdout.expected $testroot/stdout
2446 test_done "$testroot" "$ret"
2450 (cd $testroot/wt && got status > $testroot/stdout)
2451 echo "M numbers" > $testroot/stdout.expected
2452 cmp -s $testroot/stdout.expected $testroot/stdout
2454 if [ $ret -ne 0 ]; then
2455 diff -u $testroot/stdout.expected $testroot/stdout
2456 test_done "$testroot" "$ret"
2460 (cd $testroot/wt && got diff -s > $testroot/stdout)
2461 echo -n > $testroot/stdout.expected
2462 cmp -s $testroot/stdout.expected $testroot/stdout
2464 if [ $ret -ne 0 ]; then
2465 diff -u $testroot/stdout.expected $testroot/stdout
2467 test_done "$testroot" "$ret"
2471 test_stage_symlink() {
2472 local testroot=`test_init stage_symlink`
2474 (cd $testroot/repo && ln -s alpha alpha.link)
2475 (cd $testroot/repo && ln -s epsilon epsilon.link)
2476 (cd $testroot/repo && ln -s /etc/passwd passwd.link)
2477 (cd $testroot/repo && ln -s ../beta epsilon/beta.link)
2478 (cd $testroot/repo && ln -s nonexistent nonexistent.link)
2479 git -C $testroot/repo add .
2480 git_commit $testroot/repo -m "add symlinks"
2481 local head_commit=`git_show_head $testroot/repo`
2483 got checkout $testroot/repo $testroot/wt > /dev/null
2485 if [ $ret -ne 0 ]; then
2486 test_done "$testroot" "$ret"
2490 (cd $testroot/wt && ln -sf beta alpha.link)
2491 (cd $testroot/wt && rm epsilon.link && ln -s gamma epsilon.link)
2492 (cd $testroot/wt && ln -sf ../gamma/delta epsilon/beta.link)
2493 echo 'this is regular file foo' > $testroot/wt/dotgotfoo.link
2494 (cd $testroot/wt && got add dotgotfoo.link > /dev/null)
2495 (cd $testroot/wt && ln -sf .got/bar dotgotbar.link)
2496 (cd $testroot/wt && got add dotgotbar.link > /dev/null)
2497 (cd $testroot/wt && got rm nonexistent.link > /dev/null)
2498 (cd $testroot/wt && ln -sf gamma/delta zeta.link)
2499 (cd $testroot/wt && got add zeta.link > /dev/null)
2501 (cd $testroot/wt && got stage -R > $testroot/stdout 2> $testroot/stderr)
2503 if [ $ret -eq 0 ]; then
2504 echo "got stage succeeded unexpectedly" >&2
2505 test_done "$testroot" 1
2508 echo -n "got: $testroot/wt/dotgotbar.link: " > $testroot/stderr.expected
2509 echo "symbolic link points outside of paths under version control" \
2510 >> $testroot/stderr.expected
2511 cmp -s $testroot/stderr.expected $testroot/stderr
2513 if [ $ret -ne 0 ]; then
2514 diff -u $testroot/stderr.expected $testroot/stderr
2515 test_done "$testroot" "$ret"
2519 (cd $testroot/wt && got stage -RS > $testroot/stdout)
2521 cat > $testroot/stdout.expected <<EOF
2530 cmp -s $testroot/stdout.expected $testroot/stdout
2532 if [ $ret -ne 0 ]; then
2533 diff -u $testroot/stdout.expected $testroot/stdout
2534 test_done "$testroot" "$ret"
2538 rm $testroot/wt/alpha.link
2539 echo 'this is regular file alpha.link' > $testroot/wt/alpha.link
2541 (cd $testroot/wt && got diff -s > $testroot/stdout)
2543 echo "diff -s $testroot/wt" > $testroot/stdout.expected
2544 echo "commit - $head_commit" >> $testroot/stdout.expected
2545 echo "path + $testroot/wt (staged changes)" >> $testroot/stdout.expected
2546 echo -n 'blob - ' >> $testroot/stdout.expected
2547 got tree -r $testroot/repo -i | grep 'alpha.link@ -> alpha$' | \
2548 cut -d' ' -f 1 >> $testroot/stdout.expected
2549 echo -n 'blob + ' >> $testroot/stdout.expected
2550 (cd $testroot/wt && got stage -l alpha.link) | cut -d' ' -f 1 \
2551 >> $testroot/stdout.expected
2552 echo '--- alpha.link' >> $testroot/stdout.expected
2553 echo '+++ alpha.link' >> $testroot/stdout.expected
2554 echo '@@ -1 +1 @@' >> $testroot/stdout.expected
2555 echo '-alpha' >> $testroot/stdout.expected
2556 echo '\ No newline at end of file' >> $testroot/stdout.expected
2557 echo '+beta' >> $testroot/stdout.expected
2558 echo '\ No newline at end of file' >> $testroot/stdout.expected
2559 echo 'blob - /dev/null' >> $testroot/stdout.expected
2560 echo -n 'blob + ' >> $testroot/stdout.expected
2561 (cd $testroot/wt && got stage -l dotgotbar.link) | cut -d' ' -f 1 \
2562 >> $testroot/stdout.expected
2563 echo '--- /dev/null' >> $testroot/stdout.expected
2564 echo '+++ dotgotbar.link' >> $testroot/stdout.expected
2565 echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
2566 echo '+.got/bar' >> $testroot/stdout.expected
2567 echo '\ No newline at end of file' >> $testroot/stdout.expected
2568 echo 'blob - /dev/null' >> $testroot/stdout.expected
2569 echo -n 'blob + ' >> $testroot/stdout.expected
2570 (cd $testroot/wt && got stage -l dotgotfoo.link) | cut -d' ' -f 1 \
2571 >> $testroot/stdout.expected
2572 echo '--- /dev/null' >> $testroot/stdout.expected
2573 echo '+++ dotgotfoo.link' >> $testroot/stdout.expected
2574 echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
2575 echo '+this is regular file foo' >> $testroot/stdout.expected
2576 echo -n 'blob - ' >> $testroot/stdout.expected
2577 got tree -r $testroot/repo -i epsilon | grep 'beta.link@ -> ../beta$' | \
2578 cut -d' ' -f 1 >> $testroot/stdout.expected
2579 echo -n 'blob + ' >> $testroot/stdout.expected
2580 (cd $testroot/wt && got stage -l epsilon/beta.link) | cut -d' ' -f 1 \
2581 >> $testroot/stdout.expected
2582 echo '--- epsilon/beta.link' >> $testroot/stdout.expected
2583 echo '+++ epsilon/beta.link' >> $testroot/stdout.expected
2584 echo '@@ -1 +1 @@' >> $testroot/stdout.expected
2585 echo '-../beta' >> $testroot/stdout.expected
2586 echo '\ No newline at end of file' >> $testroot/stdout.expected
2587 echo '+../gamma/delta' >> $testroot/stdout.expected
2588 echo '\ No newline at end of file' >> $testroot/stdout.expected
2589 echo -n 'blob - ' >> $testroot/stdout.expected
2590 got tree -r $testroot/repo -i | grep 'epsilon.link@ -> epsilon$' | \
2591 cut -d' ' -f 1 >> $testroot/stdout.expected
2592 echo -n 'blob + ' >> $testroot/stdout.expected
2593 (cd $testroot/wt && got stage -l epsilon.link) | cut -d' ' -f 1 \
2594 >> $testroot/stdout.expected
2595 echo '--- epsilon.link' >> $testroot/stdout.expected
2596 echo '+++ epsilon.link' >> $testroot/stdout.expected
2597 echo '@@ -1 +1 @@' >> $testroot/stdout.expected
2598 echo '-epsilon' >> $testroot/stdout.expected
2599 echo '\ No newline at end of file' >> $testroot/stdout.expected
2600 echo '+gamma' >> $testroot/stdout.expected
2601 echo '\ No newline at end of file' >> $testroot/stdout.expected
2602 echo -n 'blob - ' >> $testroot/stdout.expected
2603 got tree -r $testroot/repo -i | grep 'nonexistent.link@ -> nonexistent$' | \
2604 cut -d' ' -f 1 >> $testroot/stdout.expected
2605 echo 'blob + /dev/null' >> $testroot/stdout.expected
2606 echo '--- nonexistent.link' >> $testroot/stdout.expected
2607 echo '+++ /dev/null' >> $testroot/stdout.expected
2608 echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
2609 echo '-nonexistent' >> $testroot/stdout.expected
2610 echo '\ No newline at end of file' >> $testroot/stdout.expected
2611 echo 'blob - /dev/null' >> $testroot/stdout.expected
2612 echo -n 'blob + ' >> $testroot/stdout.expected
2613 (cd $testroot/wt && got stage -l zeta.link) | cut -d' ' -f 1 \
2614 >> $testroot/stdout.expected
2615 echo '--- /dev/null' >> $testroot/stdout.expected
2616 echo '+++ zeta.link' >> $testroot/stdout.expected
2617 echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
2618 echo '+gamma/delta' >> $testroot/stdout.expected
2619 echo '\ No newline at end of file' >> $testroot/stdout.expected
2621 cmp -s $testroot/stdout.expected $testroot/stdout
2623 if [ $ret -ne 0 ]; then
2624 diff -u $testroot/stdout.expected $testroot/stdout
2625 test_done "$testroot" "$ret"
2629 (cd $testroot/wt && got commit -m "staged symlink" \
2632 if [ $ret -ne 0 ]; then
2633 echo "got commit command failed unexpectedly" >&2
2634 test_done "$testroot" "1"
2638 local commit_id=`git_show_head $testroot/repo`
2639 echo "A dotgotbar.link" > $testroot/stdout.expected
2640 echo "A dotgotfoo.link" >> $testroot/stdout.expected
2641 echo "A zeta.link" >> $testroot/stdout.expected
2642 echo "M alpha.link" >> $testroot/stdout.expected
2643 echo "M epsilon/beta.link" >> $testroot/stdout.expected
2644 echo "M epsilon.link" >> $testroot/stdout.expected
2645 echo "D nonexistent.link" >> $testroot/stdout.expected
2646 echo "Created commit $commit_id" >> $testroot/stdout.expected
2647 cmp -s $testroot/stdout.expected $testroot/stdout
2649 if [ $ret -ne 0 ]; then
2650 diff -u $testroot/stdout.expected $testroot/stdout
2651 test_done "$testroot" "$ret"
2655 got tree -r $testroot/repo -c $commit_id > $testroot/stdout
2657 if [ $ret -ne 0 ]; then
2658 echo "got tree command failed unexpectedly" >&2
2659 test_done "$testroot" "1"
2663 cat > $testroot/stdout.expected <<EOF
2667 dotgotbar.link@ -> .got/bar
2670 epsilon.link@ -> gamma
2672 passwd.link@ -> /etc/passwd
2673 zeta.link@ -> gamma/delta
2675 cmp -s $testroot/stdout.expected $testroot/stdout
2677 if [ $ret -ne 0 ]; then
2678 diff -u $testroot/stdout.expected $testroot/stdout
2682 if [ -h $testroot/wt/alpha.link ]; then
2683 echo "alpha.link is a symlink"
2684 test_done "$testroot" "1"
2688 echo 'this is regular file alpha.link' > $testroot/content.expected
2689 cp $testroot/wt/alpha.link $testroot/content
2690 cmp -s $testroot/content.expected $testroot/content
2692 if [ $ret -ne 0 ]; then
2693 diff -u $testroot/content.expected $testroot/content
2694 test_done "$testroot" "$ret"
2698 if [ ! -h $testroot/wt/dotgotbar.link ]; then
2699 echo "dotgotbar.link is not a symlink"
2700 test_done "$testroot" "1"
2703 (cd $testroot/wt && got update > /dev/null)
2704 if [ -h $testroot/wt/dotgotbar.link ]; then
2705 echo "dotgotbar.link is a symlink"
2706 test_done "$testroot" "1"
2709 echo -n ".got/bar" > $testroot/content.expected
2710 cp $testroot/wt/dotgotbar.link $testroot/content
2711 cmp -s $testroot/content.expected $testroot/content
2713 if [ $ret -ne 0 ]; then
2714 diff -u $testroot/content.expected $testroot/content
2715 test_done "$testroot" "$ret"
2719 if [ -h $testroot/wt/dotgotfoo.link ]; then
2720 echo "dotgotfoo.link is a symlink"
2721 test_done "$testroot" "1"
2724 echo "this is regular file foo" > $testroot/content.expected
2725 cp $testroot/wt/dotgotfoo.link $testroot/content
2726 cmp -s $testroot/content.expected $testroot/content
2728 if [ $ret -ne 0 ]; then
2729 diff -u $testroot/content.expected $testroot/content
2730 test_done "$testroot" "$ret"
2734 if ! [ -h $testroot/wt/epsilon.link ]; then
2735 echo "epsilon.link is not a symlink"
2736 test_done "$testroot" "1"
2740 readlink $testroot/wt/epsilon.link > $testroot/stdout
2741 echo "gamma" > $testroot/stdout.expected
2742 cmp -s $testroot/stdout.expected $testroot/stdout
2744 if [ $ret -ne 0 ]; then
2745 diff -u $testroot/stdout.expected $testroot/stdout
2746 test_done "$testroot" "$ret"
2750 if [ -h $testroot/wt/passwd.link ]; then
2751 echo "passwd.link is a symlink"
2752 test_done "$testroot" "1"
2755 echo -n "/etc/passwd" > $testroot/content.expected
2756 cp $testroot/wt/passwd.link $testroot/content
2757 cmp -s $testroot/content.expected $testroot/content
2759 if [ $ret -ne 0 ]; then
2760 diff -u $testroot/content.expected $testroot/content
2761 test_done "$testroot" "$ret"
2765 if ! [ -h $testroot/wt/zeta.link ]; then
2766 echo "zeta.link is not a symlink"
2767 test_done "$testroot" "1"
2771 readlink $testroot/wt/zeta.link > $testroot/stdout
2772 echo "gamma/delta" > $testroot/stdout.expected
2773 cmp -s $testroot/stdout.expected $testroot/stdout
2775 if [ $ret -ne 0 ]; then
2776 diff -u $testroot/stdout.expected $testroot/stdout
2777 test_done "$testroot" "$ret"
2781 test_done "$testroot" "0"
2784 test_stage_patch_symlink() {
2785 local testroot=`test_init stage_patch_symlink`
2787 (cd $testroot/repo && ln -s alpha alpha.link)
2788 (cd $testroot/repo && ln -s epsilon epsilon.link)
2789 (cd $testroot/repo && ln -s /etc/passwd passwd.link)
2790 (cd $testroot/repo && ln -s ../beta epsilon/beta.link)
2791 (cd $testroot/repo && ln -s nonexistent nonexistent.link)
2792 git -C $testroot/repo add .
2793 git_commit $testroot/repo -m "add symlinks"
2794 local head_commit=`git_show_head $testroot/repo`
2796 got checkout $testroot/repo $testroot/wt > /dev/null
2798 if [ $ret -ne 0 ]; then
2799 test_done "$testroot" "$ret"
2803 (cd $testroot/wt && ln -sf beta alpha.link)
2804 (cd $testroot/wt && rm epsilon.link && ln -s gamma epsilon.link)
2805 (cd $testroot/wt && ln -sf ../gamma/delta epsilon/beta.link)
2806 echo 'this is regular file foo' > $testroot/wt/dotgotfoo.link
2807 (cd $testroot/wt && got add dotgotfoo.link > /dev/null)
2808 (cd $testroot/wt && ln -sf .got/bar dotgotbar.link)
2809 (cd $testroot/wt && got add dotgotbar.link > /dev/null)
2810 (cd $testroot/wt && got rm nonexistent.link > /dev/null)
2811 (cd $testroot/wt && ln -sf gamma/delta zeta.link)
2812 (cd $testroot/wt && got add zeta.link > /dev/null)
2814 printf "y\nn\ny\nn\ny\ny\ny" > $testroot/patchscript
2815 (cd $testroot/wt && got stage -R -F $testroot/patchscript -p \
2818 cat > $testroot/stdout.expected <<EOF
2819 -----------------------------------------------
2822 \ No newline at end of file
2824 \ No newline at end of file
2825 -----------------------------------------------
2826 M alpha.link (change 1 of 1)
2827 stage this change? [y/n/q] y
2829 stage this addition? [y/n] n
2831 stage this addition? [y/n] y
2832 -----------------------------------------------
2835 \ No newline at end of file
2837 \ No newline at end of file
2838 -----------------------------------------------
2839 M epsilon/beta.link (change 1 of 1)
2840 stage this change? [y/n/q] n
2841 -----------------------------------------------
2844 \ No newline at end of file
2846 \ No newline at end of file
2847 -----------------------------------------------
2848 M epsilon.link (change 1 of 1)
2849 stage this change? [y/n/q] y
2851 stage this deletion? [y/n] y
2853 stage this addition? [y/n] y
2855 cmp -s $testroot/stdout.expected $testroot/stdout
2857 if [ $ret -ne 0 ]; then
2858 diff -u $testroot/stdout.expected $testroot/stdout
2859 test_done "$testroot" "$ret"
2863 rm $testroot/wt/alpha.link
2864 echo 'this is regular file alpha.link' > $testroot/wt/alpha.link
2866 (cd $testroot/wt && got diff -s > $testroot/stdout)
2868 echo "diff -s $testroot/wt" > $testroot/stdout.expected
2869 echo "commit - $head_commit" >> $testroot/stdout.expected
2870 echo "path + $testroot/wt (staged changes)" >> $testroot/stdout.expected
2871 echo -n 'blob - ' >> $testroot/stdout.expected
2872 got tree -r $testroot/repo -i | grep 'alpha.link@ -> alpha$' | \
2873 cut -d' ' -f 1 >> $testroot/stdout.expected
2874 echo -n 'blob + ' >> $testroot/stdout.expected
2875 (cd $testroot/wt && got stage -l alpha.link) | cut -d' ' -f 1 \
2876 >> $testroot/stdout.expected
2877 echo '--- alpha.link' >> $testroot/stdout.expected
2878 echo '+++ alpha.link' >> $testroot/stdout.expected
2879 echo '@@ -1 +1 @@' >> $testroot/stdout.expected
2880 echo '-alpha' >> $testroot/stdout.expected
2881 echo '\ No newline at end of file' >> $testroot/stdout.expected
2882 echo '+beta' >> $testroot/stdout.expected
2883 echo '\ No newline at end of file' >> $testroot/stdout.expected
2884 echo 'blob - /dev/null' >> $testroot/stdout.expected
2885 echo -n 'blob + ' >> $testroot/stdout.expected
2886 (cd $testroot/wt && got stage -l dotgotfoo.link) | cut -d' ' -f 1 \
2887 >> $testroot/stdout.expected
2888 echo '--- /dev/null' >> $testroot/stdout.expected
2889 echo '+++ dotgotfoo.link' >> $testroot/stdout.expected
2890 echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
2891 echo '+this is regular file foo' >> $testroot/stdout.expected
2892 echo -n 'blob - ' >> $testroot/stdout.expected
2893 got tree -r $testroot/repo -i | grep 'epsilon.link@ -> epsilon$' | \
2894 cut -d' ' -f 1 >> $testroot/stdout.expected
2895 echo -n 'blob + ' >> $testroot/stdout.expected
2896 (cd $testroot/wt && got stage -l epsilon.link) | cut -d' ' -f 1 \
2897 >> $testroot/stdout.expected
2898 echo '--- epsilon.link' >> $testroot/stdout.expected
2899 echo '+++ epsilon.link' >> $testroot/stdout.expected
2900 echo '@@ -1 +1 @@' >> $testroot/stdout.expected
2901 echo '-epsilon' >> $testroot/stdout.expected
2902 echo '\ No newline at end of file' >> $testroot/stdout.expected
2903 echo '+gamma' >> $testroot/stdout.expected
2904 echo '\ No newline at end of file' >> $testroot/stdout.expected
2905 echo -n 'blob - ' >> $testroot/stdout.expected
2906 got tree -r $testroot/repo -i | grep 'nonexistent.link@ -> nonexistent$' | \
2907 cut -d' ' -f 1 >> $testroot/stdout.expected
2908 echo 'blob + /dev/null' >> $testroot/stdout.expected
2909 echo '--- nonexistent.link' >> $testroot/stdout.expected
2910 echo '+++ /dev/null' >> $testroot/stdout.expected
2911 echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
2912 echo '-nonexistent' >> $testroot/stdout.expected
2913 echo '\ No newline at end of file' >> $testroot/stdout.expected
2914 echo 'blob - /dev/null' >> $testroot/stdout.expected
2915 echo -n 'blob + ' >> $testroot/stdout.expected
2916 (cd $testroot/wt && got stage -l zeta.link) | cut -d' ' -f 1 \
2917 >> $testroot/stdout.expected
2918 echo '--- /dev/null' >> $testroot/stdout.expected
2919 echo '+++ zeta.link' >> $testroot/stdout.expected
2920 echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
2921 echo '+gamma/delta' >> $testroot/stdout.expected
2922 echo '\ No newline at end of file' >> $testroot/stdout.expected
2924 cmp -s $testroot/stdout.expected $testroot/stdout
2926 if [ $ret -ne 0 ]; then
2927 diff -u $testroot/stdout.expected $testroot/stdout
2928 test_done "$testroot" "$ret"
2932 (cd $testroot/wt && got commit -m "staged symlink" \
2935 if [ $ret -ne 0 ]; then
2936 echo "got commit command failed unexpectedly" >&2
2937 test_done "$testroot" "1"
2941 local commit_id=`git_show_head $testroot/repo`
2942 echo "A dotgotfoo.link" > $testroot/stdout.expected
2943 echo "A zeta.link" >> $testroot/stdout.expected
2944 echo "M alpha.link" >> $testroot/stdout.expected
2945 echo "M epsilon.link" >> $testroot/stdout.expected
2946 echo "D nonexistent.link" >> $testroot/stdout.expected
2947 echo "Created commit $commit_id" >> $testroot/stdout.expected
2948 cmp -s $testroot/stdout.expected $testroot/stdout
2950 if [ $ret -ne 0 ]; then
2951 diff -u $testroot/stdout.expected $testroot/stdout
2952 test_done "$testroot" "$ret"
2956 got tree -r $testroot/repo -c $commit_id > $testroot/stdout
2958 if [ $ret -ne 0 ]; then
2959 echo "got tree command failed unexpectedly" >&2
2960 test_done "$testroot" "1"
2964 cat > $testroot/stdout.expected <<EOF
2970 epsilon.link@ -> gamma
2972 passwd.link@ -> /etc/passwd
2973 zeta.link@ -> gamma/delta
2975 cmp -s $testroot/stdout.expected $testroot/stdout
2977 if [ $ret -ne 0 ]; then
2978 diff -u $testroot/stdout.expected $testroot/stdout
2982 if [ -h $testroot/wt/alpha.link ]; then
2983 echo "alpha.link is a symlink"
2984 test_done "$testroot" "1"
2988 echo 'this is regular file alpha.link' > $testroot/content.expected
2989 cp $testroot/wt/alpha.link $testroot/content
2990 cmp -s $testroot/content.expected $testroot/content
2992 if [ $ret -ne 0 ]; then
2993 diff -u $testroot/content.expected $testroot/content
2994 test_done "$testroot" "$ret"
2998 if [ ! -h $testroot/wt/dotgotbar.link ]; then
2999 echo "dotgotbar.link is not a symlink"
3000 test_done "$testroot" "1"
3003 readlink $testroot/wt/dotgotbar.link > $testroot/stdout
3004 echo ".got/bar" > $testroot/stdout.expected
3005 cmp -s $testroot/stdout.expected $testroot/stdout
3007 if [ $ret -ne 0 ]; then
3008 diff -u $testroot/stdout.expected $testroot/stdout
3009 test_done "$testroot" "$ret"
3013 if [ -h $testroot/wt/dotgotfoo.link ]; then
3014 echo "dotgotfoo.link is a symlink"
3015 test_done "$testroot" "1"
3018 echo "this is regular file foo" > $testroot/content.expected
3019 cp $testroot/wt/dotgotfoo.link $testroot/content
3020 cmp -s $testroot/content.expected $testroot/content
3022 if [ $ret -ne 0 ]; then
3023 diff -u $testroot/content.expected $testroot/content
3024 test_done "$testroot" "$ret"
3028 if ! [ -h $testroot/wt/epsilon.link ]; then
3029 echo "epsilon.link is not a symlink"
3030 test_done "$testroot" "1"
3034 readlink $testroot/wt/epsilon.link > $testroot/stdout
3035 echo "gamma" > $testroot/stdout.expected
3036 cmp -s $testroot/stdout.expected $testroot/stdout
3038 if [ $ret -ne 0 ]; then
3039 diff -u $testroot/stdout.expected $testroot/stdout
3040 test_done "$testroot" "$ret"
3044 if [ -h $testroot/wt/passwd.link ]; then
3045 echo "passwd.link is a symlink"
3046 test_done "$testroot" "1"
3049 echo -n "/etc/passwd" > $testroot/content.expected
3050 cp $testroot/wt/passwd.link $testroot/content
3051 cmp -s $testroot/content.expected $testroot/content
3053 if [ $ret -ne 0 ]; then
3054 diff -u $testroot/content.expected $testroot/content
3055 test_done "$testroot" "$ret"
3059 if ! [ -h $testroot/wt/zeta.link ]; then
3060 echo "zeta.link is not a symlink"
3061 test_done "$testroot" "1"
3065 readlink $testroot/wt/zeta.link > $testroot/stdout
3066 echo "gamma/delta" > $testroot/stdout.expected
3067 cmp -s $testroot/stdout.expected $testroot/stdout
3069 if [ $ret -ne 0 ]; then
3070 diff -u $testroot/stdout.expected $testroot/stdout
3071 test_done "$testroot" "$ret"
3075 test_done "$testroot" "0"
3079 run_test test_stage_basic
3080 run_test test_stage_directory
3081 run_test test_stage_no_changes
3082 run_test test_stage_unversioned
3083 run_test test_stage_nonexistent
3084 run_test test_stage_list
3085 run_test test_stage_conflict
3086 run_test test_stage_out_of_date
3087 run_test test_double_stage
3088 run_test test_stage_status
3089 run_test test_stage_add_already_staged_file
3090 run_test test_stage_rm_already_staged_file
3091 run_test test_stage_revert
3092 run_test test_stage_diff
3093 run_test test_stage_histedit
3094 run_test test_stage_rebase
3095 run_test test_stage_update
3096 run_test test_stage_commit_non_staged
3097 run_test test_stage_commit_out_of_date
3098 run_test test_stage_commit
3099 run_test test_stage_patch
3100 run_test test_stage_patch_twice
3101 run_test test_stage_patch_added
3102 run_test test_stage_patch_added_twice
3103 run_test test_stage_patch_removed
3104 run_test test_stage_patch_removed_twice
3105 run_test test_stage_patch_reversed
3106 run_test test_stage_patch_quit
3107 run_test test_stage_patch_incomplete_script
3108 run_test test_stage_symlink
3109 run_test test_stage_patch_symlink