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.
20 local testroot
=`test_init stage_basic`
22 got checkout
$testroot/repo
$testroot/wt
> /dev
/null
24 if [ "$ret" != "0" ]; then
25 test_done
"$testroot" "$ret"
29 echo "modified file" > $testroot/wt
/alpha
30 (cd $testroot/wt
&& got
rm beta
> /dev
/null
)
31 echo "new file" > $testroot/wt
/foo
32 (cd $testroot/wt
&& got add foo
> /dev
/null
)
34 echo ' M alpha' > $testroot/stdout.expected
35 echo ' D beta' >> $testroot/stdout.expected
36 echo ' A foo' >> $testroot/stdout.expected
37 (cd $testroot/wt
&& got stage
> $testroot/stdout
)
39 cmp -s $testroot/stdout.expected
$testroot/stdout
41 if [ "$ret" != "0" ]; then
42 diff -u $testroot/stdout.expected
$testroot/stdout
44 test_done
"$testroot" "$ret"
47 test_stage_no_changes
() {
48 local testroot
=`test_init stage_no_changes`
50 got checkout
$testroot/repo
$testroot/wt
> /dev
/null
52 if [ "$ret" != "0" ]; then
53 test_done
"$testroot" "$ret"
57 (cd $testroot/wt
&& got stage alpha beta
> $testroot/stdout \
60 if [ "$ret" = "0" ]; then
61 echo "got stage command succeeded unexpectedly" >&2
62 test_done
"$testroot" "1"
66 echo "got: no changes to stage" > $testroot/stderr.expected
68 cmp -s $testroot/stderr.expected
$testroot/stderr
70 if [ "$ret" != "0" ]; then
71 diff -u $testroot/stderr.expected
$testroot/stderr
72 test_done
"$testroot" "$ret"
76 echo -n > $testroot/stdout.expected
77 cmp -s $testroot/stdout.expected
$testroot/stdout
79 if [ "$ret" != "0" ]; then
80 diff -u $testroot/stdout.expected
$testroot/stdout
82 test_done
"$testroot" "$ret"
85 test_stage_unversioned
() {
86 local testroot
=`test_init stage_unversioned`
88 got checkout
$testroot/repo
$testroot/wt
> /dev
/null
90 if [ "$ret" != "0" ]; then
91 test_done
"$testroot" "$ret"
95 echo "modified file" > $testroot/wt
/alpha
96 touch $testroot/wt
/unversioned-file
98 (cd $testroot/wt
&& got status
> $testroot/stdout
)
99 echo "M alpha" > $testroot/stdout.expected
100 echo "? unversioned-file" >> $testroot/stdout.expected
101 cmp -s $testroot/stdout.expected
$testroot/stdout
103 if [ "$ret" != "0" ]; then
104 diff -u $testroot/stdout.expected
$testroot/stdout
105 test_done
"$testroot" "$ret"
109 (cd $testroot/wt
&& got stage
> $testroot/stdout
)
111 if [ "$ret" != "0" ]; then
112 echo "got stage command failed unexpectedly" >&2
113 test_done
"$testroot" "$ret"
117 echo " M alpha" > $testroot/stdout.expected
118 cmp -s $testroot/stdout.expected
$testroot/stdout
120 if [ "$ret" != "0" ]; then
121 diff -u $testroot/stdout.expected
$testroot/stdout
122 test_done
"$testroot" "$ret"
126 echo "modified file again" > $testroot/wt
/alpha
128 (cd $testroot/wt
&& got stage unversioned-file
> $testroot/stdout \
131 if [ "$ret" = "0" ]; then
132 echo "got stage command succeed unexpectedly" >&2
133 test_done
"$testroot" "1"
137 echo "got: no changes to stage" > $testroot/stderr.expected
138 cmp -s $testroot/stderr.expected
$testroot/stderr
140 if [ "$ret" != "0" ]; then
141 diff -u $testroot/stderr.expected
$testroot/stderr
143 test_done
"$testroot" "$ret"
147 test_stage_nonexistent
() {
148 local testroot
=`test_init stage_nonexistent`
150 got checkout
$testroot/repo
$testroot/wt
> /dev
/null
152 if [ "$ret" != "0" ]; then
153 test_done
"$testroot" "$ret"
157 (cd $testroot/wt
&& got stage nonexistent-file \
158 > $testroot/stdout
2> $testroot/stderr
)
159 echo "got: nonexistent-file: No such file or directory" \
160 > $testroot/stderr.expected
161 cmp -s $testroot/stderr.expected
$testroot/stderr
163 if [ "$ret" != "0" ]; then
164 diff -u $testroot/stderr.expected
$testroot/stderr
166 test_done
"$testroot" "$ret"
170 local testroot
=`test_init stage_list`
172 got checkout
$testroot/repo
$testroot/wt
> /dev
/null
174 if [ "$ret" != "0" ]; then
175 test_done
"$testroot" "$ret"
179 echo "modified file" > $testroot/wt
/alpha
180 (cd $testroot/wt
&& got
rm beta
> /dev
/null
)
181 echo "new file" > $testroot/wt
/foo
182 (cd $testroot/wt
&& got add foo
> /dev
/null
)
184 echo ' M alpha' > $testroot/stdout.expected
185 echo ' D beta' >> $testroot/stdout.expected
186 echo ' A foo' >> $testroot/stdout.expected
187 (cd $testroot/wt
&& got stage alpha beta foo
> /dev
/null
)
189 (cd $testroot/wt
&& got stage
-l > $testroot/stdout
)
190 (cd $testroot/wt
&& got
diff -s alpha |
grep '^blob +' | \
191 cut
-d' ' -f3 |
tr -d '\n' > $testroot/stdout.expected
)
192 echo " M alpha" >> $testroot/stdout.expected
193 (cd $testroot/wt
&& got
diff -s beta |
grep '^blob -' | \
194 cut
-d' ' -f3 |
tr -d '\n' >> $testroot/stdout.expected
)
195 echo " D beta" >> $testroot/stdout.expected
196 (cd $testroot/wt
&& got
diff -s foo |
grep '^blob +' | \
197 cut
-d' ' -f3 |
tr -d '\n' >> $testroot/stdout.expected
)
198 echo " A foo" >> $testroot/stdout.expected
199 cmp -s $testroot/stdout.expected
$testroot/stdout
201 if [ "$ret" != "0" ]; then
202 diff -u $testroot/stdout.expected
$testroot/stdout
203 test_done
"$testroot" "$ret"
207 (cd $testroot/wt
&& got stage
-l epsilon nonexistent \
210 echo -n > $testroot/stdout.expected
211 cmp -s $testroot/stdout.expected
$testroot/stdout
213 if [ "$ret" != "0" ]; then
214 diff -u $testroot/stdout.expected
$testroot/stdout
215 test_done
"$testroot" "$ret"
219 (cd $testroot/wt
&& got stage
-l alpha
> $testroot/stdout
)
221 (cd $testroot/wt
&& got
diff -s alpha |
grep '^blob +' | \
222 cut
-d' ' -f3 |
tr -d '\n' > $testroot/stdout.expected
)
223 echo " M alpha" >> $testroot/stdout.expected
224 cmp -s $testroot/stdout.expected
$testroot/stdout
226 if [ "$ret" != "0" ]; then
227 diff -u $testroot/stdout.expected
$testroot/stdout
229 test_done
"$testroot" "$ret"
233 test_stage_conflict
() {
234 local testroot
=`test_init stage_conflict`
235 local initial_commit
=`git_show_head $testroot/repo`
237 got checkout
$testroot/repo
$testroot/wt
> /dev
/null
239 if [ "$ret" != "0" ]; then
240 test_done
"$testroot" "$ret"
244 echo "modified alpha" > $testroot/wt
/alpha
245 (cd $testroot/wt
&& got commit
-m "modified alpha" >/dev
/null
)
247 (cd $testroot/wt
&& got update
-c $initial_commit > /dev
/null
)
249 echo "modified alpha, too" > $testroot/wt
/alpha
251 echo "C alpha" > $testroot/stdout.expected
252 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
253 git_show_head
$testroot/repo
>> $testroot/stdout.expected
254 echo >> $testroot/stdout.expected
255 echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
257 (cd $testroot/wt
&& got update
> $testroot/stdout
)
259 cmp -s $testroot/stdout.expected
$testroot/stdout
261 if [ "$ret" != "0" ]; then
262 diff -u $testroot/stdout.expected
$testroot/stdout
263 test_done
"$testroot" "$ret"
267 (cd $testroot/wt
&& got stage alpha
> $testroot/stdout \
270 if [ "$ret" = "0" ]; then
271 echo "got stage command succeeded unexpectedly" >&2
272 test_done
"$testroot" "1"
276 echo -n > $testroot/stdout.expected
277 echo "got: alpha: cannot stage file in conflicted status" \
278 > $testroot/stderr.expected
280 cmp -s $testroot/stdout.expected
$testroot/stdout
282 if [ "$ret" != "0" ]; then
283 diff -u $testroot/stdout.expected
$testroot/stdout
284 test_done
"$testroot" "$ret"
287 cmp -s $testroot/stderr.expected
$testroot/stderr
289 if [ "$ret" != "0" ]; then
290 diff -u $testroot/stderr.expected
$testroot/stderr
292 test_done
"$testroot" "$ret"
295 test_stage_out_of_date
() {
296 local testroot
=`test_init stage_out_of_date`
297 local initial_commit
=`git_show_head $testroot/repo`
299 got checkout
$testroot/repo
$testroot/wt
> /dev
/null
301 if [ "$ret" != "0" ]; then
302 test_done
"$testroot" "$ret"
306 echo "modified alpha" > $testroot/wt
/alpha
307 (cd $testroot/wt
&& got commit
-m "modified alpha" >/dev
/null
)
309 (cd $testroot/wt
&& got update
-c $initial_commit > /dev
/null
)
311 echo "modified alpha again" > $testroot/wt
/alpha
312 (cd $testroot/wt
&& got stage alpha
> $testroot/stdout \
315 if [ "$ret" = "0" ]; then
316 echo "got stage command succeeded unexpectedly" >&2
317 test_done
"$testroot" "1"
321 echo -n > $testroot/stdout.expected
322 echo "got: work tree must be updated before changes can be staged" \
323 > $testroot/stderr.expected
325 cmp -s $testroot/stdout.expected
$testroot/stdout
327 if [ "$ret" != "0" ]; then
328 diff -u $testroot/stdout.expected
$testroot/stdout
329 test_done
"$testroot" "$ret"
332 cmp -s $testroot/stderr.expected
$testroot/stderr
334 if [ "$ret" != "0" ]; then
335 diff -u $testroot/stderr.expected
$testroot/stderr
337 test_done
"$testroot" "$ret"
341 test_double_stage
() {
342 local testroot
=`test_init double_stage`
344 got checkout
$testroot/repo
$testroot/wt
> /dev
/null
346 if [ "$ret" != "0" ]; then
347 test_done
"$testroot" "$ret"
350 echo "modified file" > $testroot/wt
/alpha
351 (cd $testroot/wt
&& got
rm beta
> /dev
/null
)
352 echo "new file" > $testroot/wt
/foo
353 (cd $testroot/wt
&& got add foo
> /dev
/null
)
354 (cd $testroot/wt
&& got stage alpha beta foo
> /dev
/null
)
356 echo "got: no changes to stage" > $testroot/stderr.expected
357 (cd $testroot/wt
&& got stage alpha
2> $testroot/stderr
)
358 cmp -s $testroot/stderr.expected
$testroot/stderr
360 if [ "$ret" != "0" ]; then
361 diff -u $testroot/stderr.expected
$testroot/stderr
362 test_done
"$testroot" "$ret"
366 (cd $testroot/wt
&& got stage beta \
367 > $testroot/stdout
2> $testroot/stderr
)
369 if [ "$ret" = "0" ]; then
370 echo "got stage command succeeded unexpectedly" >&2
371 test_done
"$testroot" "1"
374 echo -n > $testroot/stdout.expected
375 cmp -s $testroot/stdout.expected
$testroot/stdout
377 if [ "$ret" != "0" ]; then
378 diff -u $testroot/stdout.expected
$testroot/stdout
379 test_done
"$testroot" "$ret"
383 echo "got: no changes to stage" > $testroot/stderr.expected
384 (cd $testroot/wt
&& got stage foo
2> $testroot/stderr
)
385 cmp -s $testroot/stderr.expected
$testroot/stderr
387 if [ "$ret" != "0" ]; then
388 diff -u $testroot/stderr.expected
$testroot/stderr
389 test_done
"$testroot" "$ret"
393 printf "q\n" > $testroot/patchscript
394 (cd $testroot/wt
&& got stage
-F $testroot/patchscript
-p \
395 > $testroot/stdout
2> $testroot/stderr
)
397 if [ "$ret" = "0" ]; then
398 echo "got stage command succeeded unexpectedly" >&2
399 test_done
"$testroot" "1"
402 echo -n > $testroot/stdout.expected
403 cmp -s $testroot/stdout.expected
$testroot/stdout
405 if [ "$ret" != "0" ]; then
406 diff -u $testroot/stdout.expected
$testroot/stdout
407 test_done
"$testroot" "$ret"
411 echo "got: no changes to stage" > $testroot/stderr.expected
412 (cd $testroot/wt
&& got stage foo
2> $testroot/stderr
)
413 cmp -s $testroot/stderr.expected
$testroot/stderr
415 if [ "$ret" != "0" ]; then
416 diff -u $testroot/stderr.expected
$testroot/stderr
417 test_done
"$testroot" "$ret"
421 echo "modified file again" > $testroot/wt
/alpha
422 echo "modified new file" > $testroot/wt
/foo
424 echo ' M alpha' > $testroot/stdout.expected
425 echo ' A foo' >> $testroot/stdout.expected
426 (cd $testroot/wt
&& got stage alpha beta foo
> $testroot/stdout
)
427 cmp -s $testroot/stdout.expected
$testroot/stdout
429 if [ "$ret" != "0" ]; then
430 diff -u $testroot/stdout.expected
$testroot/stdout
431 test_done
"$testroot" "$ret"
435 echo ' M alpha' > $testroot/stdout.expected
436 echo ' D beta' >> $testroot/stdout.expected
437 echo ' A foo' >> $testroot/stdout.expected
439 (cd $testroot/wt
&& got status
> $testroot/stdout
)
440 cmp -s $testroot/stdout.expected
$testroot/stdout
442 if [ "$ret" != "0" ]; then
443 diff -u $testroot/stdout.expected
$testroot/stdout
445 test_done
"$testroot" "$ret"
448 test_stage_status
() {
449 local testroot
=`test_init stage_status`
451 got checkout
$testroot/repo
$testroot/wt
> /dev
/null
453 if [ "$ret" != "0" ]; then
454 test_done
"$testroot" "$ret"
458 echo "modified file" > $testroot/wt
/alpha
459 (cd $testroot/wt
&& got
rm beta
> /dev
/null
)
460 echo "new file" > $testroot/wt
/foo
461 (cd $testroot/wt
&& got add foo
> /dev
/null
)
462 echo "new file" > $testroot/wt
/epsilon
/new
463 (cd $testroot/wt
&& got add epsilon
/new
> /dev
/null
)
464 echo "modified file" > $testroot/wt
/epsilon
/zeta
465 (cd $testroot/wt
&& got
rm gamma
/delta
> /dev
/null
)
467 echo ' M alpha' > $testroot/stdout.expected
468 echo ' D beta' >> $testroot/stdout.expected
469 echo 'A epsilon/new' >> $testroot/stdout.expected
470 echo 'M epsilon/zeta' >> $testroot/stdout.expected
471 echo ' A foo' >> $testroot/stdout.expected
472 echo 'D gamma/delta' >> $testroot/stdout.expected
473 (cd $testroot/wt
&& got stage alpha beta foo
> /dev
/null
)
475 (cd $testroot/wt
&& got status
> $testroot/stdout
)
476 cmp -s $testroot/stdout.expected
$testroot/stdout
478 if [ "$ret" != "0" ]; then
479 diff -u $testroot/stdout.expected
$testroot/stdout
480 test_done
"$testroot" "$ret"
484 echo "modified file again" >> $testroot/wt
/alpha
485 echo "modified added file again" >> $testroot/wt
/foo
487 echo 'MM alpha' > $testroot/stdout.expected
488 echo ' D beta' >> $testroot/stdout.expected
489 echo 'A epsilon/new' >> $testroot/stdout.expected
490 echo 'M epsilon/zeta' >> $testroot/stdout.expected
491 echo 'MA foo' >> $testroot/stdout.expected
492 echo 'D gamma/delta' >> $testroot/stdout.expected
494 (cd $testroot/wt
&& got status
> $testroot/stdout
)
495 cmp -s $testroot/stdout.expected
$testroot/stdout
497 if [ "$ret" != "0" ]; then
498 diff -u $testroot/stdout.expected
$testroot/stdout
499 test_done
"$testroot" "$ret"
503 # test no-op change of added file with new stat(2) timestamp
504 echo "new file" > $testroot/wt
/foo
505 echo ' A foo' > $testroot/stdout.expected
506 (cd $testroot/wt
&& got status foo
> $testroot/stdout
)
507 cmp -s $testroot/stdout.expected
$testroot/stdout
509 if [ "$ret" != "0" ]; then
510 diff -u $testroot/stdout.expected
$testroot/stdout
511 test_done
"$testroot" "$ret"
515 # test staged deleted file which is restored on disk
516 echo "new file" > $testroot/wt
/beta
517 echo ' D beta' > $testroot/stdout.expected
518 (cd $testroot/wt
&& got status beta
> $testroot/stdout
)
519 cmp -s $testroot/stdout.expected
$testroot/stdout
521 if [ "$ret" != "0" ]; then
522 diff -u $testroot/stdout.expected
$testroot/stdout
524 test_done
"$testroot" "$ret"
528 test_stage_add_already_staged_file
() {
529 local testroot
=`test_init stage_add_already_staged_file`
531 got checkout
$testroot/repo
$testroot/wt
> /dev
/null
533 if [ "$ret" != "0" ]; then
534 test_done
"$testroot" "$ret"
538 echo "modified file" > $testroot/wt
/alpha
539 (cd $testroot/wt
&& got
rm beta
> /dev
/null
)
540 echo "new file" > $testroot/wt
/foo
541 (cd $testroot/wt
&& got add foo
> /dev
/null
)
543 (cd $testroot/wt
&& got stage alpha beta foo
> $testroot/stdout
)
545 echo -n > $testroot/stdout.expected
546 for f
in alpha beta foo
; do
547 (cd $testroot/wt
&& got add
$f \
548 > $testroot/stdout
2> $testroot/stderr
)
549 echo "got: $f: file has unexpected status" \
550 > $testroot/stderr.expected
551 cmp -s $testroot/stderr.expected
$testroot/stderr
553 if [ "$ret" != "0" ]; then
554 diff -u $testroot/stderr.expected
$testroot/stderr
555 test_done
"$testroot" "$ret"
558 cmp -s $testroot/stdout.expected
$testroot/stdout
560 if [ "$ret" != "0" ]; then
561 diff -u $testroot/stdout.expected
$testroot/stdout
562 test_done
"$testroot" "$ret"
567 echo ' M alpha' > $testroot/stdout.expected
568 echo ' D beta' >> $testroot/stdout.expected
569 echo ' A foo' >> $testroot/stdout.expected
571 (cd $testroot/wt
&& got status
> $testroot/stdout
)
572 cmp -s $testroot/stdout.expected
$testroot/stdout
574 if [ "$ret" != "0" ]; then
575 diff -u $testroot/stdout.expected
$testroot/stdout
577 test_done
"$testroot" "$ret"
580 test_stage_rm_already_staged_file
() {
581 local testroot
=`test_init stage_rm_already_staged_file`
583 got checkout
$testroot/repo
$testroot/wt
> /dev
/null
585 if [ "$ret" != "0" ]; then
586 test_done
"$testroot" "$ret"
590 echo "modified file" > $testroot/wt
/alpha
591 (cd $testroot/wt
&& got
rm beta
> /dev
/null
)
592 echo "new file" > $testroot/wt
/foo
593 (cd $testroot/wt
&& got add foo
> /dev
/null
)
595 (cd $testroot/wt
&& got stage alpha beta foo
> $testroot/stdout
)
597 (cd $testroot/wt
&& got
rm beta \
598 > $testroot/stdout
2> $testroot/stderr
)
600 if [ "$ret" != "0" ]; then
601 echo "got rm command failed unexpectedly" >&2
602 test_done
"$testroot" "1"
605 echo -n > $testroot/stdout.expected
606 cmp -s $testroot/stdout.expected
$testroot/stdout
608 if [ "$ret" != "0" ]; then
609 diff -u $testroot/stdout.expected
$testroot/stdout
610 test_done
"$testroot" "$ret"
613 echo -n > $testroot/stderr.expected
614 cmp -s $testroot/stderr.expected
$testroot/stderr
616 if [ "$ret" != "0" ]; then
617 diff -u $testroot/stderr.expected
$testroot/stderr
618 test_done
"$testroot" "$ret"
622 for f
in alpha foo
; do
623 echo "got: $f: file is staged" > $testroot/stderr.expected
624 (cd $testroot/wt
&& got
rm $f \
625 > $testroot/stdout
2> $testroot/stderr
)
627 if [ "$ret" = "0" ]; then
628 echo "got rm command succeeded unexpectedly" >&2
629 test_done
"$testroot" "1"
632 cmp -s $testroot/stderr.expected
$testroot/stderr
634 if [ "$ret" != "0" ]; then
635 diff -u $testroot/stderr.expected
$testroot/stderr
636 test_done
"$testroot" "$ret"
641 echo ' M alpha' > $testroot/stdout.expected
642 echo ' D beta' >> $testroot/stdout.expected
643 echo ' A foo' >> $testroot/stdout.expected
645 (cd $testroot/wt
&& got status
> $testroot/stdout
)
646 cmp -s $testroot/stdout.expected
$testroot/stdout
648 if [ "$ret" != "0" ]; then
649 diff -u $testroot/stdout.expected
$testroot/stdout
651 test_done
"$testroot" "$ret"
654 test_stage_revert
() {
655 local testroot
=`test_init stage_revert`
657 got checkout
$testroot/repo
$testroot/wt
> /dev
/null
659 if [ "$ret" != "0" ]; then
660 test_done
"$testroot" "$ret"
664 echo "modified alpha" > $testroot/wt
/alpha
665 (cd $testroot/wt
&& got
rm beta
> /dev
/null
)
666 echo "new file" > $testroot/wt
/foo
667 (cd $testroot/wt
&& got add foo
> /dev
/null
)
668 (cd $testroot/wt
&& got stage alpha beta foo
> /dev
/null
)
670 echo "modified file again" >> $testroot/wt
/alpha
671 echo "modified added file again" >> $testroot/wt
/foo
673 (cd $testroot/wt
&& got revert alpha
> $testroot/stdout
)
675 if [ "$ret" != "0" ]; then
676 echo "revert command failed unexpectedly" >&2
677 test_done
"$testroot" "$ret"
681 echo "R alpha" > $testroot/stdout.expected
682 cmp -s $testroot/stdout.expected
$testroot/stdout
684 if [ "$ret" != "0" ]; then
685 diff -u $testroot/stdout.expected
$testroot/stdout
686 test_done
"$testroot" "$ret"
690 echo "modified alpha" > $testroot/content.expected
691 cat $testroot/wt
/alpha
> $testroot/content
692 cmp -s $testroot/content.expected
$testroot/content
694 if [ "$ret" != "0" ]; then
695 diff -u $testroot/content.expected
$testroot/content
696 test_done
"$testroot" "$ret"
700 echo ' M alpha' > $testroot/stdout.expected
701 echo ' D beta' >> $testroot/stdout.expected
702 echo 'MA foo' >> $testroot/stdout.expected
703 (cd $testroot/wt
&& got status
> $testroot/stdout
)
704 cmp -s $testroot/stdout.expected
$testroot/stdout
706 if [ "$ret" != "0" ]; then
707 diff -u $testroot/stdout.expected
$testroot/stdout
708 test_done
"$testroot" "$ret"
712 (cd $testroot/wt
&& got revert alpha
> $testroot/stdout
)
714 if [ "$ret" != "0" ]; then
715 echo "revert command failed unexpectedly" >&2
716 test_done
"$testroot" "$ret"
720 echo -n > $testroot/stdout.expected
721 cmp -s $testroot/stdout.expected
$testroot/stdout
723 if [ "$ret" != "0" ]; then
724 diff -u $testroot/stdout.expected
$testroot/stdout
725 test_done
"$testroot" "$ret"
729 echo "modified alpha" > $testroot/content.expected
730 cat $testroot/wt
/alpha
> $testroot/content
731 cmp -s $testroot/content.expected
$testroot/content
733 if [ "$ret" != "0" ]; then
734 diff -u $testroot/content.expected
$testroot/content
735 test_done
"$testroot" "$ret"
739 (cd $testroot/wt
&& got revert beta
> $testroot/stdout \
742 if [ "$ret" != "0" ]; then
743 echo "revert command failed unexpectedly" >&2
744 test_done
"$testroot" "$ret"
748 echo -n > $testroot/stdout.expected
749 cmp -s $testroot/stdout.expected
$testroot/stdout
751 if [ "$ret" != "0" ]; then
752 diff -u $testroot/stdout.expected
$testroot/stdout
753 test_done
"$testroot" "$ret"
757 echo -n > $testroot/stderr.expected
758 cmp -s $testroot/stderr.expected
$testroot/stderr
760 if [ "$ret" != "0" ]; then
761 diff -u $testroot/stderr.expected
$testroot/stderr
762 test_done
"$testroot" "$ret"
766 (cd $testroot/wt
&& got revert foo
> $testroot/stdout
)
768 if [ "$ret" != "0" ]; then
769 echo "revert command failed unexpectedly" >&2
770 test_done
"$testroot" "$ret"
774 echo "R foo" > $testroot/stdout.expected
775 cmp -s $testroot/stdout.expected
$testroot/stdout
777 if [ "$ret" != "0" ]; then
778 diff -u $testroot/stdout.expected
$testroot/stdout
779 test_done
"$testroot" "$ret"
783 echo "new file" > $testroot/content.expected
784 cat $testroot/wt
/foo
> $testroot/content
785 cmp -s $testroot/content.expected
$testroot/content
787 if [ "$ret" != "0" ]; then
788 diff -u $testroot/content.expected
$testroot/content
789 test_done
"$testroot" "$ret"
793 echo ' M alpha' > $testroot/stdout.expected
794 echo ' D beta' >> $testroot/stdout.expected
795 echo ' A foo' >> $testroot/stdout.expected
796 (cd $testroot/wt
&& got status
> $testroot/stdout
)
797 cmp -s $testroot/stdout.expected
$testroot/stdout
799 if [ "$ret" != "0" ]; then
800 diff -u $testroot/stdout.expected
$testroot/stdout
801 test_done
"$testroot" "$ret"
805 (cd $testroot/wt
&& got revert foo
> $testroot/stdout
)
807 if [ "$ret" != "0" ]; then
808 echo "revert command failed unexpectedly" >&2
809 test_done
"$testroot" "$ret"
813 echo -n > $testroot/stdout.expected
814 cmp -s $testroot/stdout.expected
$testroot/stdout
816 if [ "$ret" != "0" ]; then
817 diff -u $testroot/stdout.expected
$testroot/stdout
818 test_done
"$testroot" "$ret"
822 echo "new file" > $testroot/content.expected
823 cat $testroot/wt
/foo
> $testroot/content
824 cmp -s $testroot/content.expected
$testroot/content
826 if [ "$ret" != "0" ]; then
827 diff -u $testroot/content.expected
$testroot/content
828 test_done
"$testroot" "$ret"
832 echo ' M alpha' > $testroot/stdout.expected
833 echo ' D beta' >> $testroot/stdout.expected
834 echo ' A foo' >> $testroot/stdout.expected
835 (cd $testroot/wt
&& got status
> $testroot/stdout
)
836 cmp -s $testroot/stdout.expected
$testroot/stdout
838 if [ "$ret" != "0" ]; then
839 diff -u $testroot/stdout.expected
$testroot/stdout
840 test_done
"$testroot" "$ret"
844 echo "modified file again" >> $testroot/wt
/alpha
845 echo "modified added file again" >> $testroot/wt
/foo
847 (cd $testroot/wt
&& got revert
-R .
> $testroot/stdout \
850 if [ "$ret" != "0" ]; then
851 echo "revert command failed unexpectedly" >&2
852 test_done
"$testroot" "$ret"
856 echo "R alpha" > $testroot/stdout.expected
857 echo "R foo" >> $testroot/stdout.expected
858 cmp -s $testroot/stdout.expected
$testroot/stdout
860 if [ "$ret" != "0" ]; then
861 diff -u $testroot/stdout.expected
$testroot/stdout
862 test_done
"$testroot" "$ret"
866 echo -n > $testroot/stderr.expected
867 cmp -s $testroot/stderr.expected
$testroot/stderr
869 if [ "$ret" != "0" ]; then
870 diff -u $testroot/stderr.expected
$testroot/stderr
871 test_done
"$testroot" "$ret"
875 echo ' M alpha' > $testroot/stdout.expected
876 echo ' D beta' >> $testroot/stdout.expected
877 echo ' A foo' >> $testroot/stdout.expected
878 (cd $testroot/wt
&& got status
> $testroot/stdout
)
879 cmp -s $testroot/stdout.expected
$testroot/stdout
881 if [ "$ret" != "0" ]; then
882 diff -u $testroot/stdout.expected
$testroot/stdout
884 test_done
"$testroot" "$ret"
888 local testroot
=`test_init stage_diff`
889 local head_commit
=`git_show_head $testroot/repo`
891 got checkout
$testroot/repo
$testroot/wt
> /dev
/null
893 if [ "$ret" != "0" ]; then
894 test_done
"$testroot" "$ret"
898 echo "modified file" > $testroot/wt
/alpha
899 (cd $testroot/wt
&& got
rm beta
> /dev
/null
)
900 echo "new file" > $testroot/wt
/foo
901 (cd $testroot/wt
&& got add foo
> /dev
/null
)
903 (cd $testroot/wt
&& got
diff -s > $testroot/stdout
)
904 echo -n > $testroot/stdout.expected
905 cmp -s $testroot/stdout.expected
$testroot/stdout
907 if [ "$ret" != "0" ]; then
908 diff -u $testroot/stdout.expected
$testroot/stdout
909 test_done
"$testroot" "$ret"
913 echo ' M alpha' > $testroot/stdout.expected
914 echo ' D beta' >> $testroot/stdout.expected
915 echo ' A foo' >> $testroot/stdout.expected
916 (cd $testroot/wt
&& got stage alpha beta foo
> /dev
/null
)
918 (cd $testroot/wt
&& got
diff > $testroot/stdout
)
919 echo -n > $testroot/stdout.expected
920 cmp -s $testroot/stdout.expected
$testroot/stdout
922 if [ "$ret" != "0" ]; then
923 diff -u $testroot/stdout.expected
$testroot/stdout
924 test_done
"$testroot" "$ret"
928 echo "modified file again" > $testroot/wt
/alpha
929 echo "new file changed" > $testroot/wt
/foo
931 (cd $testroot/wt
&& got
diff > $testroot/stdout
)
933 echo "diff $head_commit $testroot/wt" > $testroot/stdout.expected
934 echo -n 'blob - ' >> $testroot/stdout.expected
935 (cd $testroot/wt
&& got stage
-l alpha
) | cut
-d' ' -f 1 |
tr -d '\n' \
936 >> $testroot/stdout.expected
937 echo ' (staged)' >> $testroot/stdout.expected
938 echo 'file + alpha' >> $testroot/stdout.expected
939 echo '--- alpha' >> $testroot/stdout.expected
940 echo '+++ alpha' >> $testroot/stdout.expected
941 echo '@@ -1 +1 @@' >> $testroot/stdout.expected
942 echo '-modified file' >> $testroot/stdout.expected
943 echo '+modified file again' >> $testroot/stdout.expected
944 echo -n 'blob - ' >> $testroot/stdout.expected
945 (cd $testroot/wt
&& got stage
-l foo
) | cut
-d' ' -f 1 |
tr -d '\n' \
946 >> $testroot/stdout.expected
947 echo " (staged)" >> $testroot/stdout.expected
948 echo 'file + foo' >> $testroot/stdout.expected
949 echo '--- foo' >> $testroot/stdout.expected
950 echo '+++ foo' >> $testroot/stdout.expected
951 echo '@@ -1 +1 @@' >> $testroot/stdout.expected
952 echo '-new file' >> $testroot/stdout.expected
953 echo '+new file changed' >> $testroot/stdout.expected
955 cmp -s $testroot/stdout.expected
$testroot/stdout
957 if [ "$ret" != "0" ]; then
958 diff -u $testroot/stdout.expected
$testroot/stdout
959 test_done
"$testroot" "$ret"
963 (cd $testroot/wt
&& got
diff -s > $testroot/stdout
)
965 echo "diff $head_commit $testroot/wt (staged changes)" \
966 > $testroot/stdout.expected
967 echo -n 'blob - ' >> $testroot/stdout.expected
968 got tree
-r $testroot/repo
-i |
grep 'alpha$' | cut
-d' ' -f 1 \
969 >> $testroot/stdout.expected
970 echo -n 'blob + ' >> $testroot/stdout.expected
971 (cd $testroot/wt
&& got stage
-l alpha
) | cut
-d' ' -f 1 \
972 >> $testroot/stdout.expected
973 echo '--- alpha' >> $testroot/stdout.expected
974 echo '+++ alpha' >> $testroot/stdout.expected
975 echo '@@ -1 +1 @@' >> $testroot/stdout.expected
976 echo '-alpha' >> $testroot/stdout.expected
977 echo '+modified file' >> $testroot/stdout.expected
978 echo -n 'blob - ' >> $testroot/stdout.expected
979 got tree
-r $testroot/repo
-i |
grep 'beta$' | cut
-d' ' -f 1 \
980 >> $testroot/stdout.expected
981 echo 'blob + /dev/null' >> $testroot/stdout.expected
982 echo '--- beta' >> $testroot/stdout.expected
983 echo '+++ /dev/null' >> $testroot/stdout.expected
984 echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
985 echo '-beta' >> $testroot/stdout.expected
986 echo 'blob - /dev/null' >> $testroot/stdout.expected
987 echo -n 'blob + ' >> $testroot/stdout.expected
988 (cd $testroot/wt
&& got stage
-l foo
) | cut
-d' ' -f 1 \
989 >> $testroot/stdout.expected
990 echo '--- /dev/null' >> $testroot/stdout.expected
991 echo '+++ foo' >> $testroot/stdout.expected
992 echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
993 echo '+new file' >> $testroot/stdout.expected
995 cmp -s $testroot/stdout.expected
$testroot/stdout
997 if [ "$ret" != "0" ]; then
998 diff -u $testroot/stdout.expected
$testroot/stdout
1000 test_done
"$testroot" "$ret"
1004 test_stage_histedit
() {
1005 local testroot
=`test_init stage_histedit`
1006 local orig_commit
=`git_show_head $testroot/repo`
1008 got checkout
-c $orig_commit $testroot/repo
$testroot/wt
> /dev
/null
1010 if [ "$ret" != "0" ]; then
1011 test_done
"$testroot" "$ret"
1015 echo "modified file" > $testroot/wt
/alpha
1016 (cd $testroot/wt
&& got stage alpha
> /dev
/null
)
1018 echo "modified alpha on master" > $testroot/repo
/alpha
1019 (cd $testroot/repo
&& git
rm -q beta
)
1020 echo "new file on master" > $testroot/repo
/epsilon
/new
1021 (cd $testroot/repo
&& git add epsilon
/new
)
1022 git_commit
$testroot/repo
-m "committing changes"
1023 local old_commit1
=`git_show_head $testroot/repo`
1025 echo "modified zeta on master" > $testroot/repo
/epsilon
/zeta
1026 git_commit
$testroot/repo
-m "committing to zeta on master"
1027 local old_commit2
=`git_show_head $testroot/repo`
1029 echo "pick $old_commit1" > $testroot/histedit-script
1030 echo "pick $old_commit2" >> $testroot/histedit-script
1032 (cd $testroot/wt
&& got histedit
-F $testroot/histedit-script \
1033 > $testroot/stdout
2> $testroot/stderr
)
1035 if [ "$ret" = "0" ]; then
1036 echo "got histedit command succeeded unexpectedly" >&2
1037 test_done
"$testroot" "1"
1041 echo -n > $testroot/stdout.expected
1042 echo "got: alpha: file is staged" > $testroot/stderr.expected
1044 cmp -s $testroot/stderr.expected
$testroot/stderr
1046 if [ "$ret" != "0" ]; then
1047 diff -u $testroot/stderr.expected
$testroot/stderr
1048 test_done
"$testroot" "$ret"
1051 cmp -s $testroot/stdout.expected
$testroot/stdout
1053 if [ "$ret" != "0" ]; then
1054 diff -u $testroot/stdout.expected
$testroot/stdout
1056 test_done
"$testroot" "$ret"
1060 test_stage_rebase
() {
1061 local testroot
=`test_init stage_rebase`
1063 (cd $testroot/repo
&& git checkout
-q -b newbranch
)
1064 echo "modified delta on branch" > $testroot/repo
/gamma
/delta
1065 git_commit
$testroot/repo
-m "committing to delta on newbranch"
1067 echo "modified alpha on branch" > $testroot/repo
/alpha
1068 (cd $testroot/repo
&& git
rm -q beta
)
1069 echo "new file on branch" > $testroot/repo
/epsilon
/new
1070 (cd $testroot/repo
&& git add epsilon
/new
)
1071 git_commit
$testroot/repo
-m "committing more changes on newbranch"
1073 local orig_commit1
=`git_show_parent_commit $testroot/repo`
1074 local orig_commit2
=`git_show_head $testroot/repo`
1076 (cd $testroot/repo
&& git checkout
-q master
)
1077 echo "modified zeta on master" > $testroot/repo
/epsilon
/zeta
1078 git_commit
$testroot/repo
-m "committing to zeta on master"
1079 local master_commit
=`git_show_head $testroot/repo`
1081 got checkout
$testroot/repo
$testroot/wt
> /dev
/null
1083 if [ "$ret" != "0" ]; then
1084 test_done
"$testroot" "$ret"
1088 echo "modified file" > $testroot/wt
/alpha
1089 (cd $testroot/wt
&& got stage alpha
> /dev
/null
)
1091 (cd $testroot/wt
&& got rebase newbranch \
1092 > $testroot/stdout
2> $testroot/stderr
)
1094 if [ "$ret" = "0" ]; then
1095 echo "got rebase command succeeded unexpectedly" >&2
1096 test_done
"$testroot" "1"
1100 echo -n > $testroot/stdout.expected
1101 echo "got: alpha: file is staged" > $testroot/stderr.expected
1103 cmp -s $testroot/stderr.expected
$testroot/stderr
1105 if [ "$ret" != "0" ]; then
1106 diff -u $testroot/stderr.expected
$testroot/stderr
1107 test_done
"$testroot" "$ret"
1110 cmp -s $testroot/stdout.expected
$testroot/stdout
1112 if [ "$ret" != "0" ]; then
1113 diff -u $testroot/stdout.expected
$testroot/stdout
1115 test_done
"$testroot" "$ret"
1118 test_stage_update
() {
1119 local testroot
=`test_init stage_update`
1121 got checkout
$testroot/repo
$testroot/wt
> /dev
/null
1123 if [ "$ret" != "0" ]; then
1124 test_done
"$testroot" "$ret"
1128 echo "modified file" > $testroot/wt
/alpha
1129 (cd $testroot/wt
&& got stage alpha
> /dev
/null
)
1131 echo "modified alpha" > $testroot/repo
/alpha
1132 git_commit
$testroot/repo
-m "modified alpha"
1134 (cd $testroot/wt
&& got update
> $testroot/stdout \
1135 2> $testroot/stderr
)
1137 if [ "$ret" = "0" ]; then
1138 echo "got update command succeeded unexpectedly" >&2
1139 test_done
"$testroot" "1"
1143 echo -n > $testroot/stdout.expected
1144 echo "got: alpha: file is staged" > $testroot/stderr.expected
1146 cmp -s $testroot/stderr.expected
$testroot/stderr
1148 if [ "$ret" != "0" ]; then
1149 diff -u $testroot/stderr.expected
$testroot/stderr
1150 test_done
"$testroot" "$ret"
1153 cmp -s $testroot/stdout.expected
$testroot/stdout
1155 if [ "$ret" != "0" ]; then
1156 diff -u $testroot/stdout.expected
$testroot/stdout
1158 test_done
"$testroot" "$ret"
1161 test_stage_commit_non_staged
() {
1162 local testroot
=`test_init stage_commit_non_staged`
1164 got checkout
$testroot/repo
$testroot/wt
> /dev
/null
1166 if [ "$ret" != "0" ]; then
1167 test_done
"$testroot" "$ret"
1171 echo "modified file" > $testroot/wt
/alpha
1172 (cd $testroot/wt
&& got
rm beta
> /dev
/null
)
1173 echo "new file" > $testroot/wt
/foo
1174 (cd $testroot/wt
&& got add foo
> /dev
/null
)
1175 (cd $testroot/wt
&& got stage alpha beta foo
> /dev
/null
)
1177 echo "modified file" > $testroot/wt
/gamma
/delta
1178 (cd $testroot/wt
&& got commit
-m "change delta" gamma
/delta \
1179 > $testroot/stdout
2> $testroot/stderr
)
1181 if [ "$ret" = "0" ]; then
1182 echo "got commit command succeeded unexpectedly" >&2
1183 test_done
"$testroot" "1"
1187 echo -n > $testroot/stdout.expected
1188 echo "got: gamma/delta: file is not staged" > $testroot/stderr.expected
1190 cmp -s $testroot/stderr.expected
$testroot/stderr
1192 if [ "$ret" != "0" ]; then
1193 diff -u $testroot/stderr.expected
$testroot/stderr
1194 test_done
"$testroot" "$ret"
1197 cmp -s $testroot/stdout.expected
$testroot/stdout
1199 if [ "$ret" != "0" ]; then
1200 diff -u $testroot/stdout.expected
$testroot/stdout
1202 test_done
"$testroot" "$ret"
1205 test_stage_commit_out_of_date
() {
1206 local testroot
=`test_init stage_commit_out_of_date`
1208 got checkout
$testroot/repo
$testroot/wt
> /dev
/null
1210 if [ "$ret" != "0" ]; then
1211 test_done
"$testroot" "$ret"
1215 echo "modified file" > $testroot/wt
/alpha
1216 (cd $testroot/wt
&& got
rm beta
> /dev
/null
)
1217 echo "new file" > $testroot/wt
/foo
1218 (cd $testroot/wt
&& got add foo
> /dev
/null
)
1219 (cd $testroot/wt
&& got stage alpha beta foo
> /dev
/null
)
1221 echo "changed file" > $testroot/repo
/alpha
1222 git_commit
$testroot/repo
-m "changed alpha in repo"
1224 (cd $testroot/wt
&& got commit
-m "try to commit" > $testroot/stdout \
1225 2> $testroot/stderr
)
1227 if [ "$ret" = "0" ]; then
1228 echo "got commit command succeeded unexpectedly" >&2
1229 test_done
"$testroot" "1"
1233 echo -n > $testroot/stdout.expected
1234 echo -n "got: work tree must be updated before these changes " \
1235 > $testroot/stderr.expected
1236 echo "can be committed" >> $testroot/stderr.expected
1238 cmp -s $testroot/stderr.expected
$testroot/stderr
1240 if [ "$ret" != "0" ]; then
1241 diff -u $testroot/stderr.expected
$testroot/stderr
1242 test_done
"$testroot" "$ret"
1245 cmp -s $testroot/stdout.expected
$testroot/stdout
1247 if [ "$ret" != "0" ]; then
1248 diff -u $testroot/stdout.expected
$testroot/stdout
1249 test_done
"$testroot" "$ret"
1253 (cd $testroot/wt
&& got update
> $testroot/stdout \
1254 2> $testroot/stderr
)
1255 echo -n > $testroot/stdout.expected
1256 echo "got: alpha: file is staged" > $testroot/stderr.expected
1258 cmp -s $testroot/stderr.expected
$testroot/stderr
1260 if [ "$ret" != "0" ]; then
1261 diff -u $testroot/stderr.expected
$testroot/stderr
1262 test_done
"$testroot" "$ret"
1265 cmp -s $testroot/stdout.expected
$testroot/stdout
1267 if [ "$ret" != "0" ]; then
1268 diff -u $testroot/stdout.expected
$testroot/stdout
1269 test_done
"$testroot" "$ret"
1273 (cd $testroot/wt
&& got unstage
> /dev
/null
)
1274 (cd $testroot/wt
&& got update
> $testroot/stdout
)
1276 if [ "$ret" != "0" ]; then
1277 echo "got update command failed unexpectedly" >&2
1278 test_done
"$testroot" "$ret"
1282 (cd $testroot/wt
&& got status
> $testroot/stdout
)
1283 echo "C alpha" > $testroot/stdout.expected
1284 echo "D beta" >> $testroot/stdout.expected
1285 echo "A foo" >> $testroot/stdout.expected
1286 cmp -s $testroot/stdout.expected
$testroot/stdout
1288 if [ "$ret" != "0" ]; then
1289 diff -u $testroot/stdout.expected
$testroot/stdout
1290 test_done
"$testroot" "$ret"
1295 echo "resolved file" > $testroot/wt
/alpha
1297 (cd $testroot/wt
&& got stage
> /dev
/null
)
1299 (cd $testroot/wt
&& got commit
-m "try again" > $testroot/stdout
)
1301 if [ "$ret" != "0" ]; then
1302 echo "got commit command failed unexpectedly" >&2
1303 test_done
"$testroot" "$ret"
1307 local commit_id
=`git_show_head $testroot/repo`
1308 echo "A foo" > $testroot/stdout.expected
1309 echo "M alpha" >> $testroot/stdout.expected
1310 echo "D beta" >> $testroot/stdout.expected
1311 echo "Created commit $commit_id" >> $testroot/stdout.expected
1312 cmp -s $testroot/stdout.expected
$testroot/stdout
1314 if [ "$ret" != "0" ]; then
1315 diff -u $testroot/stdout.expected
$testroot/stdout
1317 test_done
"$testroot" "$ret"
1321 test_stage_commit
() {
1322 local testroot
=`test_init stage_commit`
1323 local first_commit
=`git_show_head $testroot/repo`
1325 got checkout
$testroot/repo
$testroot/wt
> /dev
/null
1327 if [ "$ret" != "0" ]; then
1328 test_done
"$testroot" "$ret"
1332 echo "modified file" > $testroot/wt
/alpha
1333 (cd $testroot/wt
&& got
rm beta
> /dev
/null
)
1334 echo "new file" > $testroot/wt
/foo
1335 (cd $testroot/wt
&& got add foo
> /dev
/null
)
1336 echo "modified file" > $testroot/wt
/alpha
1337 (cd $testroot/wt
&& got stage alpha beta foo
> /dev
/null
)
1339 echo "modified file again" > $testroot/wt
/alpha
1340 echo "new file changed" > $testroot/wt
/foo
1341 echo "non-staged change" > $testroot/wt
/gamma
/delta
1342 echo "non-staged new file" > $testroot/wt
/epsilon
/new
1343 (cd $testroot/wt
&& got add epsilon
/new
> /dev
/null
)
1344 (cd $testroot/wt
&& got
rm epsilon
/zeta
> /dev
/null
)
1346 (cd $testroot/wt
&& got stage
-l alpha
) | cut
-d' ' -f 1 \
1347 > $testroot/blob_id_alpha
1348 (cd $testroot/wt
&& got stage
-l foo
) | cut
-d' ' -f 1 \
1349 > $testroot/blob_id_foo
1351 (cd $testroot/wt
&& got commit
-m "staged changes" \
1354 if [ "$ret" != "0" ]; then
1355 echo "got commit command failed unexpectedly" >&2
1356 test_done
"$testroot" "1"
1360 local head_commit
=`git_show_head $testroot/repo`
1361 echo "A foo" > $testroot/stdout.expected
1362 echo "M alpha" >> $testroot/stdout.expected
1363 echo "D beta" >> $testroot/stdout.expected
1364 echo "Created commit $head_commit" >> $testroot/stdout.expected
1366 cmp -s $testroot/stdout.expected
$testroot/stdout
1368 if [ "$ret" != "0" ]; then
1369 diff -u $testroot/stdout.expected
$testroot/stdout
1370 test_done
"$testroot" "$ret"
1374 got
diff -r $testroot/repo
$first_commit $head_commit \
1377 echo "diff $first_commit $head_commit" \
1378 > $testroot/stdout.expected
1379 echo -n 'blob - ' >> $testroot/stdout.expected
1380 got tree
-r $testroot/repo
-i -c $first_commit | \
1381 grep 'alpha$' | cut
-d' ' -f 1 \
1382 >> $testroot/stdout.expected
1383 echo -n 'blob + ' >> $testroot/stdout.expected
1384 cat $testroot/blob_id_alpha
>> $testroot/stdout.expected
1385 echo '--- alpha' >> $testroot/stdout.expected
1386 echo '+++ alpha' >> $testroot/stdout.expected
1387 echo '@@ -1 +1 @@' >> $testroot/stdout.expected
1388 echo '-alpha' >> $testroot/stdout.expected
1389 echo '+modified file' >> $testroot/stdout.expected
1390 echo -n 'blob - ' >> $testroot/stdout.expected
1391 got tree
-r $testroot/repo
-i -c $first_commit \
1392 |
grep 'beta$' | cut
-d' ' -f 1 |
tr -d '\n' \
1393 >> $testroot/stdout.expected
1394 echo " (mode 644)" >> $testroot/stdout.expected
1395 echo 'blob + /dev/null' >> $testroot/stdout.expected
1396 echo '--- beta' >> $testroot/stdout.expected
1397 echo '+++ /dev/null' >> $testroot/stdout.expected
1398 echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
1399 echo '-beta' >> $testroot/stdout.expected
1400 echo 'blob - /dev/null' >> $testroot/stdout.expected
1401 echo -n 'blob + ' >> $testroot/stdout.expected
1402 cat $testroot/blob_id_foo |
tr -d '\n' >> $testroot/stdout.expected
1403 echo " (mode 644)" >> $testroot/stdout.expected
1404 echo '--- /dev/null' >> $testroot/stdout.expected
1405 echo '+++ foo' >> $testroot/stdout.expected
1406 echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
1407 echo '+new file' >> $testroot/stdout.expected
1409 cmp -s $testroot/stdout.expected
$testroot/stdout
1411 if [ "$ret" != "0" ]; then
1412 diff -u $testroot/stdout.expected
$testroot/stdout
1413 test_done
"$testroot" "$ret"
1417 echo 'M alpha' > $testroot/stdout.expected
1418 echo 'A epsilon/new' >> $testroot/stdout.expected
1419 echo 'D epsilon/zeta' >> $testroot/stdout.expected
1420 echo 'M foo' >> $testroot/stdout.expected
1421 echo 'M gamma/delta' >> $testroot/stdout.expected
1423 (cd $testroot/wt
&& got status
> $testroot/stdout
)
1424 cmp -s $testroot/stdout.expected
$testroot/stdout
1426 if [ "$ret" != "0" ]; then
1427 diff -u $testroot/stdout.expected
$testroot/stdout
1429 test_done
"$testroot" "$ret"
1432 test_stage_patch
() {
1433 local testroot
=`test_init stage_patch`
1435 jot 16 > $testroot/repo
/numbers
1436 (cd $testroot/repo
&& git add numbers
)
1437 git_commit
$testroot/repo
-m "added numbers file"
1438 local commit_id
=`git_show_head $testroot/repo`
1440 got checkout
$testroot/repo
$testroot/wt
> /dev
/null
1442 if [ "$ret" != "0" ]; then
1443 test_done
"$testroot" "$ret"
1447 sed -i '' -e 's/^2$/a/' $testroot/wt
/numbers
1448 sed -i '' -e 's/^7$/b/' $testroot/wt
/numbers
1449 sed -i '' -e 's/^16$/c/' $testroot/wt
/numbers
1451 # don't stage any hunks
1452 printf "n\nn\nn\n" > $testroot/patchscript
1453 (cd $testroot/wt
&& got stage
-F $testroot/patchscript
-p \
1454 numbers
> $testroot/stdout
2> $testroot/stderr
)
1456 if [ "$ret" = "0" ]; then
1457 echo "got stage command succeeded unexpectedly" >&2
1458 test_done
"$testroot" "1"
1461 cat > $testroot/stdout.expected
<<EOF
1462 -----------------------------------------------
1470 -----------------------------------------------
1471 M numbers (change 1 of 3)
1472 stage this change? [y/n/q] n
1473 -----------------------------------------------
1483 -----------------------------------------------
1484 M numbers (change 2 of 3)
1485 stage this change? [y/n/q] n
1486 -----------------------------------------------
1493 -----------------------------------------------
1494 M numbers (change 3 of 3)
1495 stage this change? [y/n/q] n
1497 cmp -s $testroot/stdout.expected
$testroot/stdout
1499 if [ "$ret" != "0" ]; then
1500 diff -u $testroot/stdout.expected
$testroot/stdout
1501 test_done
"$testroot" "$ret"
1505 echo "got: no changes to stage" > $testroot/stderr.expected
1506 cmp -s $testroot/stderr.expected
$testroot/stderr
1508 if [ "$ret" != "0" ]; then
1509 diff -u $testroot/stderr.expected
$testroot/stderr
1510 test_done
"$testroot" "$ret"
1515 (cd $testroot/wt
&& got status
> $testroot/stdout
)
1516 echo "M numbers" > $testroot/stdout.expected
1517 cmp -s $testroot/stdout.expected
$testroot/stdout
1519 if [ "$ret" != "0" ]; then
1520 diff -u $testroot/stdout.expected
$testroot/stdout
1521 test_done
"$testroot" "$ret"
1526 printf "n\ny\nn\n" > $testroot/patchscript
1527 (cd $testroot/wt
&& got stage
-F $testroot/patchscript
-p \
1528 numbers
> $testroot/stdout
)
1530 cat > $testroot/stdout.expected
<<EOF
1531 -----------------------------------------------
1539 -----------------------------------------------
1540 M numbers (change 1 of 3)
1541 stage this change? [y/n/q] n
1542 -----------------------------------------------
1552 -----------------------------------------------
1553 M numbers (change 2 of 3)
1554 stage this change? [y/n/q] y
1555 -----------------------------------------------
1562 -----------------------------------------------
1563 M numbers (change 3 of 3)
1564 stage this change? [y/n/q] n
1566 cmp -s $testroot/stdout.expected
$testroot/stdout
1568 if [ "$ret" != "0" ]; then
1569 diff -u $testroot/stdout.expected
$testroot/stdout
1570 test_done
"$testroot" "$ret"
1574 (cd $testroot/wt
&& got status
> $testroot/stdout
)
1575 echo "MM numbers" > $testroot/stdout.expected
1576 cmp -s $testroot/stdout.expected
$testroot/stdout
1578 if [ "$ret" != "0" ]; then
1579 diff -u $testroot/stdout.expected
$testroot/stdout
1580 test_done
"$testroot" "$ret"
1584 (cd $testroot/wt
&& got
diff -s > $testroot/stdout
)
1586 echo "diff $commit_id $testroot/wt (staged changes)" \
1587 > $testroot/stdout.expected
1588 echo -n 'blob - ' >> $testroot/stdout.expected
1589 got tree
-r $testroot/repo
-i -c $commit_id \
1590 |
grep 'numbers$' | cut
-d' ' -f 1 \
1591 >> $testroot/stdout.expected
1592 echo -n 'blob + ' >> $testroot/stdout.expected
1593 (cd $testroot/wt
&& got stage
-l numbers
) | cut
-d' ' -f 1 \
1594 >> $testroot/stdout.expected
1595 echo "--- numbers" >> $testroot/stdout.expected
1596 echo "+++ numbers" >> $testroot/stdout.expected
1597 echo "@@ -4,7 +4,7 @@" >> $testroot/stdout.expected
1598 echo " 4" >> $testroot/stdout.expected
1599 echo " 5" >> $testroot/stdout.expected
1600 echo " 6" >> $testroot/stdout.expected
1601 echo "-7" >> $testroot/stdout.expected
1602 echo "+b" >> $testroot/stdout.expected
1603 echo " 8" >> $testroot/stdout.expected
1604 echo " 9" >> $testroot/stdout.expected
1605 echo " 10" >> $testroot/stdout.expected
1606 cmp -s $testroot/stdout.expected
$testroot/stdout
1608 if [ "$ret" != "0" ]; then
1609 diff -u $testroot/stdout.expected
$testroot/stdout
1610 test_done
"$testroot" "$ret"
1614 (cd $testroot/wt
&& got unstage
>/dev
/null
)
1616 if [ "$ret" != "0" ]; then
1617 echo "got stage command failed unexpectedly" >&2
1618 test_done
"$testroot" "1"
1621 (cd $testroot/wt
&& got status
> $testroot/stdout
)
1622 echo "M numbers" > $testroot/stdout.expected
1623 cmp -s $testroot/stdout.expected
$testroot/stdout
1625 if [ "$ret" != "0" ]; then
1626 diff -u $testroot/stdout.expected
$testroot/stdout
1627 test_done
"$testroot" "$ret"
1632 printf "n\nn\ny\n" > $testroot/patchscript
1633 (cd $testroot/wt
&& got stage
-F $testroot/patchscript
-p \
1634 numbers
> $testroot/stdout
)
1636 cat > $testroot/stdout.expected
<<EOF
1637 -----------------------------------------------
1645 -----------------------------------------------
1646 M numbers (change 1 of 3)
1647 stage this change? [y/n/q] n
1648 -----------------------------------------------
1658 -----------------------------------------------
1659 M numbers (change 2 of 3)
1660 stage this change? [y/n/q] n
1661 -----------------------------------------------
1668 -----------------------------------------------
1669 M numbers (change 3 of 3)
1670 stage this change? [y/n/q] y
1672 cmp -s $testroot/stdout.expected
$testroot/stdout
1674 if [ "$ret" != "0" ]; then
1675 diff -u $testroot/stdout.expected
$testroot/stdout
1676 test_done
"$testroot" "$ret"
1680 (cd $testroot/wt
&& got status
> $testroot/stdout
)
1681 echo "MM numbers" > $testroot/stdout.expected
1682 cmp -s $testroot/stdout.expected
$testroot/stdout
1684 if [ "$ret" != "0" ]; then
1685 diff -u $testroot/stdout.expected
$testroot/stdout
1686 test_done
"$testroot" "$ret"
1690 (cd $testroot/wt
&& got
diff -s > $testroot/stdout
)
1692 echo "diff $commit_id $testroot/wt (staged changes)" \
1693 > $testroot/stdout.expected
1694 echo -n 'blob - ' >> $testroot/stdout.expected
1695 got tree
-r $testroot/repo
-i -c $commit_id \
1696 |
grep 'numbers$' | cut
-d' ' -f 1 \
1697 >> $testroot/stdout.expected
1698 echo -n 'blob + ' >> $testroot/stdout.expected
1699 (cd $testroot/wt
&& got stage
-l numbers
) | cut
-d' ' -f 1 \
1700 >> $testroot/stdout.expected
1701 echo "--- numbers" >> $testroot/stdout.expected
1702 echo "+++ numbers" >> $testroot/stdout.expected
1703 echo "@@ -13,4 +13,4 @@" >> $testroot/stdout.expected
1704 echo " 13" >> $testroot/stdout.expected
1705 echo " 14" >> $testroot/stdout.expected
1706 echo " 15" >> $testroot/stdout.expected
1707 echo "-16" >> $testroot/stdout.expected
1708 echo "+c" >> $testroot/stdout.expected
1709 cmp -s $testroot/stdout.expected
$testroot/stdout
1711 if [ "$ret" != "0" ]; then
1712 diff -u $testroot/stdout.expected
$testroot/stdout
1714 test_done
"$testroot" "$ret"
1717 test_stage_patch_twice
() {
1718 local testroot
=`test_init stage_patch_twice`
1720 jot 16 > $testroot/repo
/numbers
1721 (cd $testroot/repo
&& git add numbers
)
1722 git_commit
$testroot/repo
-m "added numbers file"
1723 local commit_id
=`git_show_head $testroot/repo`
1725 got checkout
$testroot/repo
$testroot/wt
> /dev
/null
1727 if [ "$ret" != "0" ]; then
1728 test_done
"$testroot" "$ret"
1732 sed -i '' -e 's/^2$/a/' $testroot/wt
/numbers
1733 sed -i '' -e 's/^7$/b/' $testroot/wt
/numbers
1734 sed -i '' -e 's/^16$/c/' $testroot/wt
/numbers
1737 printf "n\ny\nn\n" > $testroot/patchscript
1738 (cd $testroot/wt
&& got stage
-F $testroot/patchscript
-p \
1739 numbers
> $testroot/stdout
)
1741 cat > $testroot/stdout.expected
<<EOF
1742 -----------------------------------------------
1750 -----------------------------------------------
1751 M numbers (change 1 of 3)
1752 stage this change? [y/n/q] n
1753 -----------------------------------------------
1763 -----------------------------------------------
1764 M numbers (change 2 of 3)
1765 stage this change? [y/n/q] y
1766 -----------------------------------------------
1773 -----------------------------------------------
1774 M numbers (change 3 of 3)
1775 stage this change? [y/n/q] n
1777 cmp -s $testroot/stdout.expected
$testroot/stdout
1779 if [ "$ret" != "0" ]; then
1780 diff -u $testroot/stdout.expected
$testroot/stdout
1781 test_done
"$testroot" "$ret"
1785 (cd $testroot/wt
&& got status
> $testroot/stdout
)
1786 echo "MM numbers" > $testroot/stdout.expected
1787 cmp -s $testroot/stdout.expected
$testroot/stdout
1789 if [ "$ret" != "0" ]; then
1790 diff -u $testroot/stdout.expected
$testroot/stdout
1791 test_done
"$testroot" "$ret"
1796 printf "n\ny\n" > $testroot/patchscript
1797 (cd $testroot/wt
&& got stage
-F $testroot/patchscript
-p \
1798 numbers
> $testroot/stdout
)
1800 cat > $testroot/stdout.expected
<<EOF
1801 -----------------------------------------------
1809 -----------------------------------------------
1810 M numbers (change 1 of 2)
1811 stage this change? [y/n/q] n
1812 -----------------------------------------------
1819 -----------------------------------------------
1820 M numbers (change 2 of 2)
1821 stage this change? [y/n/q] y
1823 cmp -s $testroot/stdout.expected
$testroot/stdout
1825 if [ "$ret" != "0" ]; then
1826 diff -u $testroot/stdout.expected
$testroot/stdout
1827 test_done
"$testroot" "$ret"
1831 (cd $testroot/wt
&& got status
> $testroot/stdout
)
1832 echo "MM numbers" > $testroot/stdout.expected
1833 cmp -s $testroot/stdout.expected
$testroot/stdout
1835 if [ "$ret" != "0" ]; then
1836 diff -u $testroot/stdout.expected
$testroot/stdout
1837 test_done
"$testroot" "$ret"
1841 (cd $testroot/wt
&& got
diff -s > $testroot/stdout
)
1843 echo "diff $commit_id $testroot/wt (staged changes)" \
1844 > $testroot/stdout.expected
1845 echo -n 'blob - ' >> $testroot/stdout.expected
1846 got tree
-r $testroot/repo
-i -c $commit_id \
1847 |
grep 'numbers$' | cut
-d' ' -f 1 \
1848 >> $testroot/stdout.expected
1849 echo -n 'blob + ' >> $testroot/stdout.expected
1850 (cd $testroot/wt
&& got stage
-l numbers
) | cut
-d' ' -f 1 \
1851 >> $testroot/stdout.expected
1852 echo "--- numbers" >> $testroot/stdout.expected
1853 echo "+++ numbers" >> $testroot/stdout.expected
1854 cat >> $testroot/stdout.expected
<<EOF
1871 cmp -s $testroot/stdout.expected
$testroot/stdout
1873 if [ "$ret" != "0" ]; then
1874 diff -u $testroot/stdout.expected
$testroot/stdout
1875 test_done
"$testroot" "$ret"
1879 (cd $testroot/wt
&& got
diff > $testroot/stdout
)
1881 echo "diff $commit_id $testroot/wt" > $testroot/stdout.expected
1882 echo -n 'blob - ' >> $testroot/stdout.expected
1883 (cd $testroot/wt
&& got stage
-l numbers
) | cut
-d' ' -f 1 | \
1884 tr -d '\n' >> $testroot/stdout.expected
1885 echo " (staged)" >> $testroot/stdout.expected
1886 echo 'file + numbers' >> $testroot/stdout.expected
1887 echo "--- numbers" >> $testroot/stdout.expected
1888 echo "+++ numbers" >> $testroot/stdout.expected
1889 cat >> $testroot/stdout.expected
<<EOF
1898 cmp -s $testroot/stdout.expected
$testroot/stdout
1900 if [ "$ret" != "0" ]; then
1901 diff -u $testroot/stdout.expected
$testroot/stdout
1903 test_done
"$testroot" "$ret"
1906 test_stage_patch_added
() {
1907 local testroot
=`test_init stage_patch_added`
1908 local commit_id
=`git_show_head $testroot/repo`
1910 got checkout
$testroot/repo
$testroot/wt
> /dev
/null
1912 if [ "$ret" != "0" ]; then
1913 test_done
"$testroot" "$ret"
1917 echo "new" > $testroot/wt
/epsilon
/new
1918 (cd $testroot/wt
&& got add epsilon
/new
> /dev
/null
)
1920 printf "y\n" > $testroot/patchscript
1921 (cd $testroot/wt
&& got stage
-F $testroot/patchscript
-p \
1922 epsilon
/new
> $testroot/stdout
)
1924 echo "A epsilon/new" > $testroot/stdout.expected
1925 echo "stage this addition? [y/n] y" >> $testroot/stdout.expected
1926 cmp -s $testroot/stdout.expected
$testroot/stdout
1928 if [ "$ret" != "0" ]; then
1929 diff -u $testroot/stdout.expected
$testroot/stdout
1930 test_done
"$testroot" "$ret"
1934 (cd $testroot/wt
&& got status
> $testroot/stdout
)
1935 echo " A epsilon/new" > $testroot/stdout.expected
1936 cmp -s $testroot/stdout.expected
$testroot/stdout
1938 if [ "$ret" != "0" ]; then
1939 diff -u $testroot/stdout.expected
$testroot/stdout
1940 test_done
"$testroot" "$ret"
1944 (cd $testroot/wt
&& got
diff -s > $testroot/stdout
)
1946 echo "diff $commit_id $testroot/wt (staged changes)" \
1947 > $testroot/stdout.expected
1948 echo 'blob - /dev/null' >> $testroot/stdout.expected
1949 echo -n 'blob + ' >> $testroot/stdout.expected
1950 (cd $testroot/wt
&& got stage
-l epsilon
/new
) | cut
-d' ' -f 1 \
1951 >> $testroot/stdout.expected
1952 echo "--- /dev/null" >> $testroot/stdout.expected
1953 echo "+++ epsilon/new" >> $testroot/stdout.expected
1954 echo "@@ -0,0 +1 @@" >> $testroot/stdout.expected
1955 echo "+new" >> $testroot/stdout.expected
1956 cmp -s $testroot/stdout.expected
$testroot/stdout
1958 if [ "$ret" != "0" ]; then
1959 diff -u $testroot/stdout.expected
$testroot/stdout
1961 test_done
"$testroot" "$ret"
1964 test_stage_patch_added_twice
() {
1965 local testroot
=`test_init stage_patch_added_twice`
1966 local commit_id
=`git_show_head $testroot/repo`
1968 got checkout
$testroot/repo
$testroot/wt
> /dev
/null
1970 if [ "$ret" != "0" ]; then
1971 test_done
"$testroot" "$ret"
1975 echo "new" > $testroot/wt
/epsilon
/new
1976 (cd $testroot/wt
&& got add epsilon
/new
> /dev
/null
)
1978 printf "y\n" > $testroot/patchscript
1979 (cd $testroot/wt
&& got stage
-F $testroot/patchscript
-p \
1980 epsilon
/new
> $testroot/stdout
)
1982 echo "A epsilon/new" > $testroot/stdout.expected
1983 echo "stage this addition? [y/n] y" >> $testroot/stdout.expected
1984 cmp -s $testroot/stdout.expected
$testroot/stdout
1986 if [ "$ret" != "0" ]; then
1987 diff -u $testroot/stdout.expected
$testroot/stdout
1988 test_done
"$testroot" "$ret"
1992 (cd $testroot/wt
&& got status
> $testroot/stdout
)
1993 echo " A epsilon/new" > $testroot/stdout.expected
1994 cmp -s $testroot/stdout.expected
$testroot/stdout
1996 if [ "$ret" != "0" ]; then
1997 diff -u $testroot/stdout.expected
$testroot/stdout
1998 test_done
"$testroot" "$ret"
2002 (cd $testroot/wt
&& got stage
-F $testroot/patchscript
-p \
2003 epsilon
/new
> $testroot/stdout
2> $testroot/stderr
)
2005 if [ "$ret" = "0" ]; then
2006 echo "got stage command succeeded unexpectedly" >&2
2007 test_done
"$testroot" "1"
2011 echo "got: no changes to stage" > $testroot/stderr.expected
2012 cmp -s $testroot/stderr.expected
$testroot/stderr
2014 if [ "$ret" != "0" ]; then
2015 diff -u $testroot/stderr.expected
$testroot/stderr
2016 test_done
"$testroot" "$ret"
2020 echo -n > $testroot/stdout.expected
2021 cmp -s $testroot/stdout.expected
$testroot/stdout
2023 if [ "$ret" != "0" ]; then
2024 diff -u $testroot/stdout.expected
$testroot/stdout
2026 test_done
"$testroot" "$ret"
2029 test_stage_patch_removed
() {
2030 local testroot
=`test_init stage_patch_removed`
2031 local commit_id
=`git_show_head $testroot/repo`
2033 got checkout
$testroot/repo
$testroot/wt
> /dev
/null
2035 if [ "$ret" != "0" ]; then
2036 test_done
"$testroot" "$ret"
2040 (cd $testroot/wt
&& got
rm beta
> /dev
/null
)
2042 printf "y\n" > $testroot/patchscript
2043 (cd $testroot/wt
&& got stage
-F $testroot/patchscript
-p \
2044 beta
> $testroot/stdout
)
2046 echo -n > $testroot/stdout.expected
2048 echo "D beta" > $testroot/stdout.expected
2049 echo "stage this deletion? [y/n] y" >> $testroot/stdout.expected
2050 cmp -s $testroot/stdout.expected
$testroot/stdout
2052 if [ "$ret" != "0" ]; then
2053 diff -u $testroot/stdout.expected
$testroot/stdout
2054 test_done
"$testroot" "$ret"
2058 (cd $testroot/wt
&& got status
> $testroot/stdout
)
2059 echo " D beta" > $testroot/stdout.expected
2060 cmp -s $testroot/stdout.expected
$testroot/stdout
2062 if [ "$ret" != "0" ]; then
2063 diff -u $testroot/stdout.expected
$testroot/stdout
2064 test_done
"$testroot" "$ret"
2068 (cd $testroot/wt
&& got
diff -s > $testroot/stdout
)
2070 echo "diff $commit_id $testroot/wt (staged changes)" \
2071 > $testroot/stdout.expected
2072 echo -n 'blob - ' >> $testroot/stdout.expected
2073 (cd $testroot/wt
&& got stage
-l beta
) | cut
-d' ' -f 1 \
2074 >> $testroot/stdout.expected
2075 echo 'blob + /dev/null' >> $testroot/stdout.expected
2076 echo "--- beta" >> $testroot/stdout.expected
2077 echo "+++ /dev/null" >> $testroot/stdout.expected
2078 echo "@@ -1 +0,0 @@" >> $testroot/stdout.expected
2079 echo "-beta" >> $testroot/stdout.expected
2080 cmp -s $testroot/stdout.expected
$testroot/stdout
2082 if [ "$ret" != "0" ]; then
2083 diff -u $testroot/stdout.expected
$testroot/stdout
2085 test_done
"$testroot" "$ret"
2088 test_stage_patch_removed_twice
() {
2089 local testroot
=`test_init stage_patch_removed_twice`
2090 local commit_id
=`git_show_head $testroot/repo`
2092 got checkout
$testroot/repo
$testroot/wt
> /dev
/null
2094 if [ "$ret" != "0" ]; then
2095 test_done
"$testroot" "$ret"
2099 (cd $testroot/wt
&& got
rm beta
> /dev
/null
)
2101 printf "y\n" > $testroot/patchscript
2102 (cd $testroot/wt
&& got stage
-F $testroot/patchscript
-p \
2103 beta
> $testroot/stdout
)
2105 echo -n > $testroot/stdout.expected
2107 echo "D beta" > $testroot/stdout.expected
2108 echo "stage this deletion? [y/n] y" >> $testroot/stdout.expected
2109 cmp -s $testroot/stdout.expected
$testroot/stdout
2111 if [ "$ret" != "0" ]; then
2112 diff -u $testroot/stdout.expected
$testroot/stdout
2113 test_done
"$testroot" "$ret"
2117 (cd $testroot/wt
&& got status
> $testroot/stdout
)
2118 echo " D beta" > $testroot/stdout.expected
2119 cmp -s $testroot/stdout.expected
$testroot/stdout
2121 if [ "$ret" != "0" ]; then
2122 diff -u $testroot/stdout.expected
$testroot/stdout
2123 test_done
"$testroot" "$ret"
2127 (cd $testroot/wt
&& got stage
-F $testroot/patchscript
-p beta \
2128 > $testroot/stdout
2> $testroot/stderr
)
2130 if [ "$ret" = "0" ]; then
2131 echo "got stage command succeeded unexpectedly" >&2
2132 test_done
"$testroot" "$ret"
2136 echo "got: no changes to stage" > $testroot/stderr.expected
2137 cmp -s $testroot/stderr.expected
$testroot/stderr
2139 if [ "$ret" != "0" ]; then
2140 diff -u $testroot/stderr.expected
$testroot/stderr
2141 test_done
"$testroot" "$ret"
2145 echo -n > $testroot/stdout.expected
2146 cmp -s $testroot/stdout.expected
$testroot/stdout
2148 if [ "$ret" != "0" ]; then
2149 diff -u $testroot/stdout.expected
$testroot/stdout
2151 test_done
"$testroot" "$ret"
2154 test_stage_patch_quit
() {
2155 local testroot
=`test_init stage_patch_quit`
2157 jot 16 > $testroot/repo
/numbers
2158 echo zzz
> $testroot/repo
/zzz
2159 (cd $testroot/repo
&& git add numbers zzz
)
2160 git_commit
$testroot/repo
-m "added files"
2161 local commit_id
=`git_show_head $testroot/repo`
2163 got checkout
$testroot/repo
$testroot/wt
> /dev
/null
2165 if [ "$ret" != "0" ]; then
2166 test_done
"$testroot" "$ret"
2170 sed -i '' -e 's/^2$/a/' $testroot/wt
/numbers
2171 sed -i '' -e 's/^7$/b/' $testroot/wt
/numbers
2172 sed -i '' -e 's/^16$/c/' $testroot/wt
/numbers
2173 (cd $testroot/wt
&& got
rm zzz
> /dev
/null
)
2175 # stage first hunk and quit; and don't pass a path argument to
2176 # ensure that we don't skip asking about the 'zzz' file after 'quit'
2177 printf "y\nq\nn\n" > $testroot/patchscript
2178 (cd $testroot/wt
&& got stage
-F $testroot/patchscript
-p \
2181 if [ "$ret" != "0" ]; then
2182 echo "got stage command failed unexpectedly" >&2
2183 test_done
"$testroot" "1"
2186 cat > $testroot/stdout.expected
<<EOF
2187 -----------------------------------------------
2195 -----------------------------------------------
2196 M numbers (change 1 of 3)
2197 stage this change? [y/n/q] y
2198 -----------------------------------------------
2208 -----------------------------------------------
2209 M numbers (change 2 of 3)
2210 stage this change? [y/n/q] q
2212 stage this deletion? [y/n] n
2214 cmp -s $testroot/stdout.expected
$testroot/stdout
2216 if [ "$ret" != "0" ]; then
2217 diff -u $testroot/stdout.expected
$testroot/stdout
2218 test_done
"$testroot" "$ret"
2222 (cd $testroot/wt
&& got status
> $testroot/stdout
)
2223 echo "MM numbers" > $testroot/stdout.expected
2224 echo "D zzz" >> $testroot/stdout.expected
2225 cmp -s $testroot/stdout.expected
$testroot/stdout
2227 if [ "$ret" != "0" ]; then
2228 diff -u $testroot/stdout.expected
$testroot/stdout
2229 test_done
"$testroot" "$ret"
2233 (cd $testroot/wt
&& got
diff -s > $testroot/stdout
)
2235 echo "diff $commit_id $testroot/wt (staged changes)" \
2236 > $testroot/stdout.expected
2237 echo -n 'blob - ' >> $testroot/stdout.expected
2238 got tree
-r $testroot/repo
-i -c $commit_id \
2239 |
grep 'numbers$' | cut
-d' ' -f 1 \
2240 >> $testroot/stdout.expected
2241 echo -n 'blob + ' >> $testroot/stdout.expected
2242 (cd $testroot/wt
&& got stage
-l numbers
) | cut
-d' ' -f 1 \
2243 >> $testroot/stdout.expected
2244 echo "--- numbers" >> $testroot/stdout.expected
2245 echo "+++ numbers" >> $testroot/stdout.expected
2246 echo "@@ -1,5 +1,5 @@" >> $testroot/stdout.expected
2247 echo " 1" >> $testroot/stdout.expected
2248 echo "-2" >> $testroot/stdout.expected
2249 echo "+a" >> $testroot/stdout.expected
2250 echo " 3" >> $testroot/stdout.expected
2251 echo " 4" >> $testroot/stdout.expected
2252 echo " 5" >> $testroot/stdout.expected
2253 cmp -s $testroot/stdout.expected
$testroot/stdout
2255 if [ "$ret" != "0" ]; then
2256 diff -u $testroot/stdout.expected
$testroot/stdout
2258 test_done
"$testroot" "$ret"
2262 test_stage_patch_incomplete_script
() {
2263 local testroot
=`test_init stage_incomplete_script`
2265 jot 16 > $testroot/repo
/numbers
2266 echo zzz
> $testroot/repo
/zzz
2267 (cd $testroot/repo
&& git 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" != "0" ]; then
2274 test_done
"$testroot" "$ret"
2278 sed -i '' -e 's/^2$/a/' $testroot/wt
/numbers
2279 sed -i '' -e 's/^7$/b/' $testroot/wt
/numbers
2280 sed -i '' -e 's/^16$/c/' $testroot/wt
/numbers
2282 # stage first hunk and then stop responding; got should error out
2283 printf "y\n" > $testroot/patchscript
2284 (cd $testroot/wt
&& got stage
-F $testroot/patchscript
-p \
2285 > $testroot/stdout
2> $testroot/stderr
)
2287 if [ "$ret" = "0" ]; then
2288 echo "got stage command succeeded unexpectedly" >&2
2289 test_done
"$testroot" "1"
2292 cat > $testroot/stdout.expected
<<EOF
2293 -----------------------------------------------
2301 -----------------------------------------------
2302 M numbers (change 1 of 3)
2303 stage this change? [y/n/q] y
2304 -----------------------------------------------
2314 -----------------------------------------------
2315 M numbers (change 2 of 3)
2317 echo -n "stage this change? [y/n/q] " >> $testroot/stdout.expected
2318 echo "got: invalid patch choice" > $testroot/stderr.expected
2319 cmp -s $testroot/stderr.expected
$testroot/stderr
2321 if [ "$ret" != "0" ]; then
2322 diff -u $testroot/stderr.expected
$testroot/stderr
2323 test_done
"$testroot" "$ret"
2327 cmp -s $testroot/stdout.expected
$testroot/stdout
2329 if [ "$ret" != "0" ]; then
2330 diff -u $testroot/stdout.expected
$testroot/stdout
2331 test_done
"$testroot" "$ret"
2335 (cd $testroot/wt
&& got status
> $testroot/stdout
)
2336 echo "M numbers" > $testroot/stdout.expected
2337 cmp -s $testroot/stdout.expected
$testroot/stdout
2339 if [ "$ret" != "0" ]; then
2340 diff -u $testroot/stdout.expected
$testroot/stdout
2341 test_done
"$testroot" "$ret"
2345 (cd $testroot/wt
&& got
diff -s > $testroot/stdout
)
2346 echo -n > $testroot/stdout.expected
2347 cmp -s $testroot/stdout.expected
$testroot/stdout
2349 if [ "$ret" != "0" ]; then
2350 diff -u $testroot/stdout.expected
$testroot/stdout
2352 test_done
"$testroot" "$ret"
2356 test_stage_symlink
() {
2357 local testroot
=`test_init stage_symlink`
2359 (cd $testroot/repo
&& ln -s alpha alpha.link
)
2360 (cd $testroot/repo
&& ln -s epsilon epsilon.link
)
2361 (cd $testroot/repo
&& ln -s /etc
/passwd passwd.link
)
2362 (cd $testroot/repo
&& ln -s ..
/beta epsilon
/beta.link
)
2363 (cd $testroot/repo
&& ln -s nonexistent nonexistent.link
)
2364 (cd $testroot/repo
&& git add .
)
2365 git_commit
$testroot/repo
-m "add symlinks"
2366 local head_commit
=`git_show_head $testroot/repo`
2368 got checkout
$testroot/repo
$testroot/wt
> /dev
/null
2370 if [ "$ret" != "0" ]; then
2371 test_done
"$testroot" "$ret"
2375 (cd $testroot/wt
&& ln -sf beta alpha.link
)
2376 (cd $testroot/wt
&& ln -sfT gamma epsilon.link
)
2377 (cd $testroot/wt
&& ln -sf ..
/gamma
/delta epsilon
/beta.link
)
2378 echo 'this is regular file foo' > $testroot/wt
/dotgotfoo.link
2379 (cd $testroot/wt
&& got add dotgotfoo.link
> /dev
/null
)
2380 (cd $testroot/wt
&& ln -sf .got
/bar dotgotbar.link
)
2381 (cd $testroot/wt
&& got add dotgotbar.link
> /dev
/null
)
2382 (cd $testroot/wt
&& got
rm nonexistent.link
> /dev
/null
)
2383 (cd $testroot/wt
&& ln -sf gamma
/delta zeta.link
)
2384 (cd $testroot/wt
&& got add zeta.link
> /dev
/null
)
2386 (cd $testroot/wt
&& got stage
> $testroot/stdout
2> $testroot/stderr
)
2388 if [ "$ret" = "0" ]; then
2389 echo "got stage succeeded unexpectedly" >&2
2390 test_done
"$testroot" "$ret"
2393 echo -n "got: $testroot/wt/dotgotbar.link: " > $testroot/stderr.expected
2394 echo "symbolic link points outside of paths under version control" \
2395 >> $testroot/stderr.expected
2396 cmp -s $testroot/stderr.expected
$testroot/stderr
2398 if [ "$ret" != "0" ]; then
2399 diff -u $testroot/stderr.expected
$testroot/stderr
2400 test_done
"$testroot" "$ret"
2404 (cd $testroot/wt
&& got stage
-S > $testroot/stdout
)
2406 cat > $testroot/stdout.expected
<<EOF
2415 cmp -s $testroot/stdout.expected
$testroot/stdout
2417 if [ "$ret" != "0" ]; then
2418 diff -u $testroot/stdout.expected
$testroot/stdout
2419 test_done
"$testroot" "$ret"
2423 rm $testroot/wt
/alpha.link
2424 echo 'this is regular file alpha.link' > $testroot/wt
/alpha.link
2426 (cd $testroot/wt
&& got
diff -s > $testroot/stdout
)
2428 echo "diff $head_commit $testroot/wt (staged changes)" \
2429 > $testroot/stdout.expected
2430 echo -n 'blob - ' >> $testroot/stdout.expected
2431 got tree
-r $testroot/repo
-i |
grep 'alpha.link@ -> alpha$' | \
2432 cut
-d' ' -f 1 >> $testroot/stdout.expected
2433 echo -n 'blob + ' >> $testroot/stdout.expected
2434 (cd $testroot/wt
&& got stage
-l alpha.link
) | cut
-d' ' -f 1 \
2435 >> $testroot/stdout.expected
2436 echo '--- alpha.link' >> $testroot/stdout.expected
2437 echo '+++ alpha.link' >> $testroot/stdout.expected
2438 echo '@@ -1 +1 @@' >> $testroot/stdout.expected
2439 echo '-alpha' >> $testroot/stdout.expected
2440 echo '\ No newline at end of file' >> $testroot/stdout.expected
2441 echo '+beta' >> $testroot/stdout.expected
2442 echo '\ No newline at end of file' >> $testroot/stdout.expected
2443 echo 'blob - /dev/null' >> $testroot/stdout.expected
2444 echo -n 'blob + ' >> $testroot/stdout.expected
2445 (cd $testroot/wt
&& got stage
-l dotgotbar.link
) | cut
-d' ' -f 1 \
2446 >> $testroot/stdout.expected
2447 echo '--- /dev/null' >> $testroot/stdout.expected
2448 echo '+++ dotgotbar.link' >> $testroot/stdout.expected
2449 echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
2450 echo '+.got/bar' >> $testroot/stdout.expected
2451 echo '\ No newline at end of file' >> $testroot/stdout.expected
2452 echo 'blob - /dev/null' >> $testroot/stdout.expected
2453 echo -n 'blob + ' >> $testroot/stdout.expected
2454 (cd $testroot/wt
&& got stage
-l dotgotfoo.link
) | cut
-d' ' -f 1 \
2455 >> $testroot/stdout.expected
2456 echo '--- /dev/null' >> $testroot/stdout.expected
2457 echo '+++ dotgotfoo.link' >> $testroot/stdout.expected
2458 echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
2459 echo '+this is regular file foo' >> $testroot/stdout.expected
2460 echo -n 'blob - ' >> $testroot/stdout.expected
2461 got tree
-r $testroot/repo
-i epsilon |
grep 'beta.link@ -> ../beta$' | \
2462 cut
-d' ' -f 1 >> $testroot/stdout.expected
2463 echo -n 'blob + ' >> $testroot/stdout.expected
2464 (cd $testroot/wt
&& got stage
-l epsilon
/beta.link
) | cut
-d' ' -f 1 \
2465 >> $testroot/stdout.expected
2466 echo '--- epsilon/beta.link' >> $testroot/stdout.expected
2467 echo '+++ epsilon/beta.link' >> $testroot/stdout.expected
2468 echo '@@ -1 +1 @@' >> $testroot/stdout.expected
2469 echo '-../beta' >> $testroot/stdout.expected
2470 echo '\ No newline at end of file' >> $testroot/stdout.expected
2471 echo '+../gamma/delta' >> $testroot/stdout.expected
2472 echo '\ No newline at end of file' >> $testroot/stdout.expected
2473 echo -n 'blob - ' >> $testroot/stdout.expected
2474 got tree
-r $testroot/repo
-i |
grep 'epsilon.link@ -> epsilon$' | \
2475 cut
-d' ' -f 1 >> $testroot/stdout.expected
2476 echo -n 'blob + ' >> $testroot/stdout.expected
2477 (cd $testroot/wt
&& got stage
-l epsilon.link
) | cut
-d' ' -f 1 \
2478 >> $testroot/stdout.expected
2479 echo '--- epsilon.link' >> $testroot/stdout.expected
2480 echo '+++ epsilon.link' >> $testroot/stdout.expected
2481 echo '@@ -1 +1 @@' >> $testroot/stdout.expected
2482 echo '-epsilon' >> $testroot/stdout.expected
2483 echo '\ No newline at end of file' >> $testroot/stdout.expected
2484 echo '+gamma' >> $testroot/stdout.expected
2485 echo '\ No newline at end of file' >> $testroot/stdout.expected
2486 echo -n 'blob - ' >> $testroot/stdout.expected
2487 got tree
-r $testroot/repo
-i |
grep 'nonexistent.link@ -> nonexistent$' | \
2488 cut
-d' ' -f 1 >> $testroot/stdout.expected
2489 echo 'blob + /dev/null' >> $testroot/stdout.expected
2490 echo '--- nonexistent.link' >> $testroot/stdout.expected
2491 echo '+++ /dev/null' >> $testroot/stdout.expected
2492 echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
2493 echo '-nonexistent' >> $testroot/stdout.expected
2494 echo '\ No newline at end of file' >> $testroot/stdout.expected
2495 echo 'blob - /dev/null' >> $testroot/stdout.expected
2496 echo -n 'blob + ' >> $testroot/stdout.expected
2497 (cd $testroot/wt
&& got stage
-l zeta.link
) | cut
-d' ' -f 1 \
2498 >> $testroot/stdout.expected
2499 echo '--- /dev/null' >> $testroot/stdout.expected
2500 echo '+++ zeta.link' >> $testroot/stdout.expected
2501 echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
2502 echo '+gamma/delta' >> $testroot/stdout.expected
2503 echo '\ No newline at end of file' >> $testroot/stdout.expected
2505 cmp -s $testroot/stdout.expected
$testroot/stdout
2507 if [ "$ret" != "0" ]; then
2508 diff -u $testroot/stdout.expected
$testroot/stdout
2509 test_done
"$testroot" "$ret"
2513 (cd $testroot/wt
&& got commit
-m "staged symlink" \
2516 if [ "$ret" != "0" ]; then
2517 echo "got commit command failed unexpectedly" >&2
2518 test_done
"$testroot" "1"
2522 local commit_id
=`git_show_head $testroot/repo`
2523 echo "A dotgotbar.link" > $testroot/stdout.expected
2524 echo "A dotgotfoo.link" >> $testroot/stdout.expected
2525 echo "A zeta.link" >> $testroot/stdout.expected
2526 echo "M alpha.link" >> $testroot/stdout.expected
2527 echo "M epsilon/beta.link" >> $testroot/stdout.expected
2528 echo "M epsilon.link" >> $testroot/stdout.expected
2529 echo "D nonexistent.link" >> $testroot/stdout.expected
2530 echo "Created commit $commit_id" >> $testroot/stdout.expected
2531 cmp -s $testroot/stdout.expected
$testroot/stdout
2533 if [ "$ret" != "0" ]; then
2534 diff -u $testroot/stdout.expected
$testroot/stdout
2535 test_done
"$testroot" "$ret"
2539 got tree
-r $testroot/repo
-c $commit_id > $testroot/stdout
2541 if [ "$ret" != "0" ]; then
2542 echo "got tree command failed unexpectedly" >&2
2543 test_done
"$testroot" "1"
2547 cat > $testroot/stdout.expected
<<EOF
2551 dotgotbar.link@ -> .got/bar
2554 epsilon.link@ -> gamma
2556 passwd.link@ -> /etc/passwd
2557 zeta.link@ -> gamma/delta
2559 cmp -s $testroot/stdout.expected
$testroot/stdout
2561 if [ "$ret" != "0" ]; then
2562 diff -u $testroot/stdout.expected
$testroot/stdout
2566 if [ -h $testroot/wt
/alpha.link
]; then
2567 echo "alpha.link is a symlink"
2568 test_done
"$testroot" "1"
2572 echo 'this is regular file alpha.link' > $testroot/content.expected
2573 cp $testroot/wt
/alpha.link
$testroot/content
2574 cmp -s $testroot/content.expected
$testroot/content
2576 if [ "$ret" != "0" ]; then
2577 diff -u $testroot/content.expected
$testroot/content
2578 test_done
"$testroot" "$ret"
2582 if [ ! -h $testroot/wt
/dotgotbar.link
]; then
2583 echo "dotgotbar.link is not a symlink"
2584 test_done
"$testroot" "1"
2587 (cd $testroot/wt
&& got update
> /dev
/null
)
2588 if [ -h $testroot/wt
/dotgotbar.link
]; then
2589 echo "dotgotbar.link is a symlink"
2590 test_done
"$testroot" "1"
2593 echo -n ".got/bar" > $testroot/content.expected
2594 cp $testroot/wt
/dotgotbar.link
$testroot/content
2595 cmp -s $testroot/content.expected
$testroot/content
2597 if [ "$ret" != "0" ]; then
2598 diff -u $testroot/content.expected
$testroot/content
2599 test_done
"$testroot" "$ret"
2603 if [ -h $testroot/wt
/dotgotfoo.link
]; then
2604 echo "dotgotfoo.link is a symlink"
2605 test_done
"$testroot" "1"
2608 echo "this is regular file foo" > $testroot/content.expected
2609 cp $testroot/wt
/dotgotfoo.link
$testroot/content
2610 cmp -s $testroot/content.expected
$testroot/content
2612 if [ "$ret" != "0" ]; then
2613 diff -u $testroot/content.expected
$testroot/content
2614 test_done
"$testroot" "$ret"
2618 if ! [ -h $testroot/wt
/epsilon.link
]; then
2619 echo "epsilon.link is not a symlink"
2620 test_done
"$testroot" "1"
2624 readlink
$testroot/wt
/epsilon.link
> $testroot/stdout
2625 echo "gamma" > $testroot/stdout.expected
2626 cmp -s $testroot/stdout.expected
$testroot/stdout
2628 if [ "$ret" != "0" ]; then
2629 diff -u $testroot/stdout.expected
$testroot/stdout
2630 test_done
"$testroot" "$ret"
2634 if [ -h $testroot/wt
/passwd.link
]; then
2635 echo "passwd.link is a symlink"
2636 test_done
"$testroot" "1"
2639 echo -n "/etc/passwd" > $testroot/content.expected
2640 cp $testroot/wt
/passwd.link
$testroot/content
2641 cmp -s $testroot/content.expected
$testroot/content
2643 if [ "$ret" != "0" ]; then
2644 diff -u $testroot/content.expected
$testroot/content
2645 test_done
"$testroot" "$ret"
2649 if ! [ -h $testroot/wt
/zeta.link
]; then
2650 echo "zeta.link is not a symlink"
2651 test_done
"$testroot" "1"
2655 readlink
$testroot/wt
/zeta.link
> $testroot/stdout
2656 echo "gamma/delta" > $testroot/stdout.expected
2657 cmp -s $testroot/stdout.expected
$testroot/stdout
2659 if [ "$ret" != "0" ]; then
2660 diff -u $testroot/stdout.expected
$testroot/stdout
2661 test_done
"$testroot" "$ret"
2665 test_done
"$testroot" "0"
2668 test_stage_patch_symlink
() {
2669 local testroot
=`test_init stage_patch_symlink`
2671 (cd $testroot/repo
&& ln -s alpha alpha.link
)
2672 (cd $testroot/repo
&& ln -s epsilon epsilon.link
)
2673 (cd $testroot/repo
&& ln -s /etc
/passwd passwd.link
)
2674 (cd $testroot/repo
&& ln -s ..
/beta epsilon
/beta.link
)
2675 (cd $testroot/repo
&& ln -s nonexistent nonexistent.link
)
2676 (cd $testroot/repo
&& git add .
)
2677 git_commit
$testroot/repo
-m "add symlinks"
2678 local head_commit
=`git_show_head $testroot/repo`
2680 got checkout
$testroot/repo
$testroot/wt
> /dev
/null
2682 if [ "$ret" != "0" ]; then
2683 test_done
"$testroot" "$ret"
2687 (cd $testroot/wt
&& ln -sf beta alpha.link
)
2688 (cd $testroot/wt
&& ln -sfT gamma epsilon.link
)
2689 (cd $testroot/wt
&& ln -sf ..
/gamma
/delta epsilon
/beta.link
)
2690 echo 'this is regular file foo' > $testroot/wt
/dotgotfoo.link
2691 (cd $testroot/wt
&& got add dotgotfoo.link
> /dev
/null
)
2692 (cd $testroot/wt
&& ln -sf .got
/bar dotgotbar.link
)
2693 (cd $testroot/wt
&& got add dotgotbar.link
> /dev
/null
)
2694 (cd $testroot/wt
&& got
rm nonexistent.link
> /dev
/null
)
2695 (cd $testroot/wt
&& ln -sf gamma
/delta zeta.link
)
2696 (cd $testroot/wt
&& got add zeta.link
> /dev
/null
)
2698 printf "y\nn\ny\nn\ny\ny\ny" > $testroot/patchscript
2699 (cd $testroot/wt
&& got stage
-F $testroot/patchscript
-p \
2702 cat > $testroot/stdout.expected
<<EOF
2703 -----------------------------------------------
2706 \ No newline at end of file
2708 \ No newline at end of file
2709 -----------------------------------------------
2710 M alpha.link (change 1 of 1)
2711 stage this change? [y/n/q] y
2713 stage this addition? [y/n] n
2715 stage this addition? [y/n] y
2716 -----------------------------------------------
2719 \ No newline at end of file
2721 \ No newline at end of file
2722 -----------------------------------------------
2723 M epsilon/beta.link (change 1 of 1)
2724 stage this change? [y/n/q] n
2725 -----------------------------------------------
2728 \ No newline at end of file
2730 \ No newline at end of file
2731 -----------------------------------------------
2732 M epsilon.link (change 1 of 1)
2733 stage this change? [y/n/q] y
2735 stage this deletion? [y/n] y
2737 stage this addition? [y/n] y
2739 cmp -s $testroot/stdout.expected
$testroot/stdout
2741 if [ "$ret" != "0" ]; then
2742 diff -u $testroot/stdout.expected
$testroot/stdout
2743 test_done
"$testroot" "$ret"
2747 rm $testroot/wt
/alpha.link
2748 echo 'this is regular file alpha.link' > $testroot/wt
/alpha.link
2750 (cd $testroot/wt
&& got
diff -s > $testroot/stdout
)
2752 echo "diff $head_commit $testroot/wt (staged changes)" \
2753 > $testroot/stdout.expected
2754 echo -n 'blob - ' >> $testroot/stdout.expected
2755 got tree
-r $testroot/repo
-i |
grep 'alpha.link@ -> alpha$' | \
2756 cut
-d' ' -f 1 >> $testroot/stdout.expected
2757 echo -n 'blob + ' >> $testroot/stdout.expected
2758 (cd $testroot/wt
&& got stage
-l alpha.link
) | cut
-d' ' -f 1 \
2759 >> $testroot/stdout.expected
2760 echo '--- alpha.link' >> $testroot/stdout.expected
2761 echo '+++ alpha.link' >> $testroot/stdout.expected
2762 echo '@@ -1 +1 @@' >> $testroot/stdout.expected
2763 echo '-alpha' >> $testroot/stdout.expected
2764 echo '\ No newline at end of file' >> $testroot/stdout.expected
2765 echo '+beta' >> $testroot/stdout.expected
2766 echo '\ No newline at end of file' >> $testroot/stdout.expected
2767 echo 'blob - /dev/null' >> $testroot/stdout.expected
2768 echo -n 'blob + ' >> $testroot/stdout.expected
2769 (cd $testroot/wt
&& got stage
-l dotgotfoo.link
) | cut
-d' ' -f 1 \
2770 >> $testroot/stdout.expected
2771 echo '--- /dev/null' >> $testroot/stdout.expected
2772 echo '+++ dotgotfoo.link' >> $testroot/stdout.expected
2773 echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
2774 echo '+this is regular file foo' >> $testroot/stdout.expected
2775 echo -n 'blob - ' >> $testroot/stdout.expected
2776 got tree
-r $testroot/repo
-i |
grep 'epsilon.link@ -> epsilon$' | \
2777 cut
-d' ' -f 1 >> $testroot/stdout.expected
2778 echo -n 'blob + ' >> $testroot/stdout.expected
2779 (cd $testroot/wt
&& got stage
-l epsilon.link
) | cut
-d' ' -f 1 \
2780 >> $testroot/stdout.expected
2781 echo '--- epsilon.link' >> $testroot/stdout.expected
2782 echo '+++ epsilon.link' >> $testroot/stdout.expected
2783 echo '@@ -1 +1 @@' >> $testroot/stdout.expected
2784 echo '-epsilon' >> $testroot/stdout.expected
2785 echo '\ No newline at end of file' >> $testroot/stdout.expected
2786 echo '+gamma' >> $testroot/stdout.expected
2787 echo '\ No newline at end of file' >> $testroot/stdout.expected
2788 echo -n 'blob - ' >> $testroot/stdout.expected
2789 got tree
-r $testroot/repo
-i |
grep 'nonexistent.link@ -> nonexistent$' | \
2790 cut
-d' ' -f 1 >> $testroot/stdout.expected
2791 echo 'blob + /dev/null' >> $testroot/stdout.expected
2792 echo '--- nonexistent.link' >> $testroot/stdout.expected
2793 echo '+++ /dev/null' >> $testroot/stdout.expected
2794 echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
2795 echo '-nonexistent' >> $testroot/stdout.expected
2796 echo '\ No newline at end of file' >> $testroot/stdout.expected
2797 echo 'blob - /dev/null' >> $testroot/stdout.expected
2798 echo -n 'blob + ' >> $testroot/stdout.expected
2799 (cd $testroot/wt
&& got stage
-l zeta.link
) | cut
-d' ' -f 1 \
2800 >> $testroot/stdout.expected
2801 echo '--- /dev/null' >> $testroot/stdout.expected
2802 echo '+++ zeta.link' >> $testroot/stdout.expected
2803 echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
2804 echo '+gamma/delta' >> $testroot/stdout.expected
2805 echo '\ No newline at end of file' >> $testroot/stdout.expected
2807 cmp -s $testroot/stdout.expected
$testroot/stdout
2809 if [ "$ret" != "0" ]; then
2810 diff -u $testroot/stdout.expected
$testroot/stdout
2811 test_done
"$testroot" "$ret"
2815 (cd $testroot/wt
&& got commit
-m "staged symlink" \
2818 if [ "$ret" != "0" ]; then
2819 echo "got commit command failed unexpectedly" >&2
2820 test_done
"$testroot" "1"
2824 local commit_id
=`git_show_head $testroot/repo`
2825 echo "A dotgotfoo.link" > $testroot/stdout.expected
2826 echo "A zeta.link" >> $testroot/stdout.expected
2827 echo "M alpha.link" >> $testroot/stdout.expected
2828 echo "M epsilon.link" >> $testroot/stdout.expected
2829 echo "D nonexistent.link" >> $testroot/stdout.expected
2830 echo "Created commit $commit_id" >> $testroot/stdout.expected
2831 cmp -s $testroot/stdout.expected
$testroot/stdout
2833 if [ "$ret" != "0" ]; then
2834 diff -u $testroot/stdout.expected
$testroot/stdout
2835 test_done
"$testroot" "$ret"
2839 got tree
-r $testroot/repo
-c $commit_id > $testroot/stdout
2841 if [ "$ret" != "0" ]; then
2842 echo "got tree command failed unexpectedly" >&2
2843 test_done
"$testroot" "1"
2847 cat > $testroot/stdout.expected
<<EOF
2853 epsilon.link@ -> gamma
2855 passwd.link@ -> /etc/passwd
2856 zeta.link@ -> gamma/delta
2858 cmp -s $testroot/stdout.expected
$testroot/stdout
2860 if [ "$ret" != "0" ]; then
2861 diff -u $testroot/stdout.expected
$testroot/stdout
2865 if [ -h $testroot/wt
/alpha.link
]; then
2866 echo "alpha.link is a symlink"
2867 test_done
"$testroot" "1"
2871 echo 'this is regular file alpha.link' > $testroot/content.expected
2872 cp $testroot/wt
/alpha.link
$testroot/content
2873 cmp -s $testroot/content.expected
$testroot/content
2875 if [ "$ret" != "0" ]; then
2876 diff -u $testroot/content.expected
$testroot/content
2877 test_done
"$testroot" "$ret"
2881 if [ ! -h $testroot/wt
/dotgotbar.link
]; then
2882 echo "dotgotbar.link is not a symlink"
2883 test_done
"$testroot" "1"
2886 readlink
$testroot/wt
/dotgotbar.link
> $testroot/stdout
2887 echo ".got/bar" > $testroot/stdout.expected
2888 cmp -s $testroot/stdout.expected
$testroot/stdout
2890 if [ "$ret" != "0" ]; then
2891 diff -u $testroot/stdout.expected
$testroot/stdout
2892 test_done
"$testroot" "$ret"
2896 if [ -h $testroot/wt
/dotgotfoo.link
]; then
2897 echo "dotgotfoo.link is a symlink"
2898 test_done
"$testroot" "1"
2901 echo "this is regular file foo" > $testroot/content.expected
2902 cp $testroot/wt
/dotgotfoo.link
$testroot/content
2903 cmp -s $testroot/content.expected
$testroot/content
2905 if [ "$ret" != "0" ]; then
2906 diff -u $testroot/content.expected
$testroot/content
2907 test_done
"$testroot" "$ret"
2911 if ! [ -h $testroot/wt
/epsilon.link
]; then
2912 echo "epsilon.link is not a symlink"
2913 test_done
"$testroot" "1"
2917 readlink
$testroot/wt
/epsilon.link
> $testroot/stdout
2918 echo "gamma" > $testroot/stdout.expected
2919 cmp -s $testroot/stdout.expected
$testroot/stdout
2921 if [ "$ret" != "0" ]; then
2922 diff -u $testroot/stdout.expected
$testroot/stdout
2923 test_done
"$testroot" "$ret"
2927 if [ -h $testroot/wt
/passwd.link
]; then
2928 echo "passwd.link is a symlink"
2929 test_done
"$testroot" "1"
2932 echo -n "/etc/passwd" > $testroot/content.expected
2933 cp $testroot/wt
/passwd.link
$testroot/content
2934 cmp -s $testroot/content.expected
$testroot/content
2936 if [ "$ret" != "0" ]; then
2937 diff -u $testroot/content.expected
$testroot/content
2938 test_done
"$testroot" "$ret"
2942 if ! [ -h $testroot/wt
/zeta.link
]; then
2943 echo "zeta.link is not a symlink"
2944 test_done
"$testroot" "1"
2948 readlink
$testroot/wt
/zeta.link
> $testroot/stdout
2949 echo "gamma/delta" > $testroot/stdout.expected
2950 cmp -s $testroot/stdout.expected
$testroot/stdout
2952 if [ "$ret" != "0" ]; then
2953 diff -u $testroot/stdout.expected
$testroot/stdout
2954 test_done
"$testroot" "$ret"
2958 test_done
"$testroot" "0"
2962 run_test test_stage_basic
2963 run_test test_stage_no_changes
2964 run_test test_stage_unversioned
2965 run_test test_stage_nonexistent
2966 run_test test_stage_list
2967 run_test test_stage_conflict
2968 run_test test_stage_out_of_date
2969 run_test test_double_stage
2970 run_test test_stage_status
2971 run_test test_stage_add_already_staged_file
2972 run_test test_stage_rm_already_staged_file
2973 run_test test_stage_revert
2974 run_test test_stage_diff
2975 run_test test_stage_histedit
2976 run_test test_stage_rebase
2977 run_test test_stage_update
2978 run_test test_stage_commit_non_staged
2979 run_test test_stage_commit_out_of_date
2980 run_test test_stage_commit
2981 run_test test_stage_patch
2982 run_test test_stage_patch_twice
2983 run_test test_stage_patch_added
2984 run_test test_stage_patch_added_twice
2985 run_test test_stage_patch_removed
2986 run_test test_stage_patch_removed_twice
2987 run_test test_stage_patch_quit
2988 run_test test_stage_patch_incomplete_script
2989 run_test test_stage_symlink
2990 run_test test_stage_patch_symlink