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 function test_update_basic {
20 local testroot=`test_init update_basic`
22 got checkout $testroot/repo $testroot/wt > /dev/null
24 if [ "$ret" != "0" ]; then
25 test_done "$testroot" "$ret"
29 echo "modified alpha" > $testroot/repo/alpha
30 git_commit $testroot/repo -m "modified alpha"
32 echo "U alpha" > $testroot/stdout.expected
33 echo -n "Updated to commit " >> $testroot/stdout.expected
34 git_show_head $testroot/repo >> $testroot/stdout.expected
35 echo >> $testroot/stdout.expected
37 (cd $testroot/wt && got update > $testroot/stdout)
39 cmp -s $testroot/stdout.expected $testroot/stdout
41 if [ "$ret" != "0" ]; then
42 diff -u $testroot/stdout.expected $testroot/stdout
43 test_done "$testroot" "$ret"
47 echo "modified alpha" > $testroot/content.expected
48 cat $testroot/wt/alpha > $testroot/content
50 cmp -s $testroot/content.expected $testroot/content
52 if [ "$ret" != "0" ]; then
53 diff -u $testroot/content.expected $testroot/content
55 test_done "$testroot" "$ret"
58 function test_update_adds_file {
59 local testroot=`test_init update_adds_file`
61 got checkout $testroot/repo $testroot/wt > /dev/null
63 if [ "$ret" != "0" ]; then
64 test_done "$testroot" "$ret"
68 echo "new" > $testroot/repo/gamma/new
69 (cd $testroot/repo && git add .)
70 git_commit $testroot/repo -m "adding a new file"
72 echo "A gamma/new" > $testroot/stdout.expected
73 echo -n "Updated to commit " >> $testroot/stdout.expected
74 git_show_head $testroot/repo >> $testroot/stdout.expected
75 echo >> $testroot/stdout.expected
77 (cd $testroot/wt && got update > $testroot/stdout)
79 cmp -s $testroot/stdout.expected $testroot/stdout
81 if [ "$ret" != "0" ]; then
82 diff -u $testroot/stdout.expected $testroot/stdout
83 test_done "$testroot" "$ret"
87 echo "new" >> $testroot/content.expected
88 cat $testroot/wt/gamma/new > $testroot/content
90 cmp -s $testroot/content.expected $testroot/content
92 if [ "$ret" != "0" ]; then
93 diff -u $testroot/content.expected $testroot/content
95 test_done "$testroot" "$ret"
98 function test_update_deletes_file {
99 local testroot=`test_init update_deletes_file`
101 got checkout $testroot/repo $testroot/wt > /dev/null
103 if [ "$ret" != "0" ]; then
104 test_done "$testroot" "$ret"
108 (cd $testroot/repo && git_rm $testroot/repo beta)
109 git_commit $testroot/repo -m "deleting a file"
111 echo "D beta" > $testroot/stdout.expected
112 echo -n "Updated to commit " >> $testroot/stdout.expected
113 git_show_head $testroot/repo >> $testroot/stdout.expected
114 echo >> $testroot/stdout.expected
116 (cd $testroot/wt && got update > $testroot/stdout)
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 if [ -e $testroot/wt/beta ]; then
127 echo "removed file beta still exists on disk" >&2
128 test_done "$testroot" "1"
132 test_done "$testroot" "0"
135 function test_update_deletes_dir {
136 local testroot=`test_init update_deletes_dir`
138 got checkout $testroot/repo $testroot/wt > /dev/null
140 if [ "$ret" != "0" ]; then
141 test_done "$testroot" "$ret"
145 (cd $testroot/repo && git_rm $testroot/repo -r epsilon)
146 git_commit $testroot/repo -m "deleting a directory"
148 echo "D epsilon/zeta" > $testroot/stdout.expected
149 echo -n "Updated to commit " >> $testroot/stdout.expected
150 git_show_head $testroot/repo >> $testroot/stdout.expected
151 echo >> $testroot/stdout.expected
153 (cd $testroot/wt && got update > $testroot/stdout)
155 cmp -s $testroot/stdout.expected $testroot/stdout
157 if [ "$ret" != "0" ]; then
158 diff -u $testroot/stdout.expected $testroot/stdout
159 test_done "$testroot" "$ret"
163 if [ -e $testroot/wt/epsilon ]; then
164 echo "removed dir epsilon still exists on disk" >&2
165 test_done "$testroot" "1"
169 test_done "$testroot" "0"
172 function test_update_deletes_dir_with_path_prefix {
173 local testroot=`test_init update_deletes_dir_with_path_prefix`
174 local first_rev=`git_show_head $testroot/repo`
176 mkdir $testroot/repo/epsilon/psi
177 echo mu > $testroot/repo/epsilon/psi/mu
178 (cd $testroot/repo && git add .)
179 git_commit $testroot/repo -m "adding a sub-directory beneath epsilon"
181 # check out the epsilon/ sub-tree
182 got checkout -p epsilon $testroot/repo $testroot/wt > /dev/null
184 if [ "$ret" != "0" ]; then
185 test_done "$testroot" "$ret"
189 # update back to first commit and expect psi/mu to be deleted
190 echo "D psi/mu" > $testroot/stdout.expected
191 echo "Updated to commit $first_rev" >> $testroot/stdout.expected
193 (cd $testroot/wt && got update -c $first_rev > $testroot/stdout)
195 cmp -s $testroot/stdout.expected $testroot/stdout
197 if [ "$ret" != "0" ]; then
198 diff -u $testroot/stdout.expected $testroot/stdout
199 test_done "$testroot" "$ret"
203 if [ -e $testroot/wt/psi ]; then
204 echo "removed dir psi still exists on disk" >&2
205 test_done "$testroot" "1"
209 test_done "$testroot" "0"
212 function test_update_deletes_dir_recursively {
213 local testroot=`test_init update_deletes_dir_recursively`
214 local first_rev=`git_show_head $testroot/repo`
216 mkdir $testroot/repo/epsilon/psi
217 echo mu > $testroot/repo/epsilon/psi/mu
218 mkdir $testroot/repo/epsilon/psi/chi
219 echo tau > $testroot/repo/epsilon/psi/chi/tau
220 (cd $testroot/repo && git add .)
221 git_commit $testroot/repo -m "adding a sub-directory beneath epsilon"
223 # check out the epsilon/ sub-tree
224 got checkout -p epsilon $testroot/repo $testroot/wt > /dev/null
226 if [ "$ret" != "0" ]; then
227 test_done "$testroot" "$ret"
231 # update back to first commit and expect psi/mu to be deleted
232 echo "D psi/chi/tau" > $testroot/stdout.expected
233 echo "D psi/mu" >> $testroot/stdout.expected
234 echo "Updated to commit $first_rev" >> $testroot/stdout.expected
236 (cd $testroot/wt && got update -c $first_rev > $testroot/stdout)
238 cmp -s $testroot/stdout.expected $testroot/stdout
240 if [ "$?" != "0" ]; then
241 diff -u $testroot/stdout.expected $testroot/stdout
242 test_done "$testroot" "$ret"
246 if [ -e $testroot/wt/psi ]; then
247 echo "removed dir psi still exists on disk" >&2
248 test_done "$testroot" "1"
252 test_done "$testroot" "0"
255 function test_update_sibling_dirs_with_common_prefix {
256 local testroot=`test_init update_sibling_dirs_with_common_prefix`
258 got checkout $testroot/repo $testroot/wt > /dev/null
260 if [ "$ret" != "0" ]; then
261 test_done "$testroot" "$ret"
265 mkdir $testroot/repo/epsilon2
266 echo mu > $testroot/repo/epsilon2/mu
267 (cd $testroot/repo && git add epsilon2/mu)
268 git_commit $testroot/repo -m "adding sibling of epsilon"
269 echo change > $testroot/repo/epsilon/zeta
270 git_commit $testroot/repo -m "changing epsilon/zeta"
272 echo "U epsilon/zeta" > $testroot/stdout.expected
273 echo "A epsilon2/mu" >> $testroot/stdout.expected
274 echo -n "Updated to commit " >> $testroot/stdout.expected
275 git_show_head $testroot/repo >> $testroot/stdout.expected
276 echo >> $testroot/stdout.expected
278 (cd $testroot/wt && got update > $testroot/stdout)
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"
288 echo "another change" > $testroot/repo/epsilon/zeta
289 git_commit $testroot/repo -m "changing epsilon/zeta again"
291 echo "U epsilon/zeta" > $testroot/stdout.expected
292 echo -n "Updated to commit " >> $testroot/stdout.expected
293 git_show_head $testroot/repo >> $testroot/stdout.expected
294 echo >> $testroot/stdout.expected
296 # Bug: This update used to do delete/add epsilon2/mu again:
298 # D epsilon2/mu <--- not intended
299 # A epsilon2/mu <--- not intended
300 (cd $testroot/wt && got update > $testroot/stdout)
302 cmp -s $testroot/stdout.expected $testroot/stdout
304 if [ "$ret" != "0" ]; then
305 diff -u $testroot/stdout.expected $testroot/stdout
306 test_done "$testroot" "$ret"
310 cmp -s $testroot/stdout.expected $testroot/stdout
312 if [ "$ret" != "0" ]; then
313 diff -u $testroot/stdout.expected $testroot/stdout
315 test_done "$testroot" "$ret"
318 function test_update_dir_with_dot_sibling {
319 local testroot=`test_init update_dir_with_dot_sibling`
321 got checkout $testroot/repo $testroot/wt > /dev/null
323 if [ "$ret" != "0" ]; then
324 test_done "$testroot" "$ret"
328 echo text > $testroot/repo/epsilon.txt
329 (cd $testroot/repo && git add epsilon.txt)
330 git_commit $testroot/repo -m "adding sibling of epsilon"
331 echo change > $testroot/repo/epsilon/zeta
332 git_commit $testroot/repo -m "changing epsilon/zeta"
334 echo "U epsilon/zeta" > $testroot/stdout.expected
335 echo "A epsilon.txt" >> $testroot/stdout.expected
336 echo -n "Updated to commit " >> $testroot/stdout.expected
337 git_show_head $testroot/repo >> $testroot/stdout.expected
338 echo >> $testroot/stdout.expected
340 (cd $testroot/wt && got update > $testroot/stdout)
342 cmp -s $testroot/stdout.expected $testroot/stdout
344 if [ "$ret" != "0" ]; then
345 diff -u $testroot/stdout.expected $testroot/stdout
346 test_done "$testroot" "$ret"
350 echo "another change" > $testroot/repo/epsilon/zeta
351 git_commit $testroot/repo -m "changing epsilon/zeta again"
353 echo "U epsilon/zeta" > $testroot/stdout.expected
354 echo -n "Updated to commit " >> $testroot/stdout.expected
355 git_show_head $testroot/repo >> $testroot/stdout.expected
356 echo >> $testroot/stdout.expected
358 (cd $testroot/wt && got update > $testroot/stdout)
360 cmp -s $testroot/stdout.expected $testroot/stdout
362 if [ "$ret" != "0" ]; then
363 diff -u $testroot/stdout.expected $testroot/stdout
364 test_done "$testroot" "$ret"
368 cmp -s $testroot/stdout.expected $testroot/stdout
370 if [ "$ret" != "0" ]; then
371 diff -u $testroot/stdout.expected $testroot/stdout
373 test_done "$testroot" "$ret"
376 function test_update_moves_files_upwards {
377 local testroot=`test_init update_moves_files_upwards`
379 mkdir $testroot/repo/epsilon/psi
380 echo mu > $testroot/repo/epsilon/psi/mu
381 mkdir $testroot/repo/epsilon/psi/chi
382 echo tau > $testroot/repo/epsilon/psi/chi/tau
383 (cd $testroot/repo && git add .)
384 git_commit $testroot/repo -m "adding a sub-directory beneath epsilon"
386 got checkout $testroot/repo $testroot/wt > /dev/null
388 if [ "$ret" != "0" ]; then
389 test_done "$testroot" "$ret"
393 (cd $testroot/repo && git mv epsilon/psi/mu epsilon/mu)
394 (cd $testroot/repo && git mv epsilon/psi/chi/tau epsilon/psi/tau)
395 git_commit $testroot/repo -m "moving files upwards"
397 echo "A epsilon/mu" > $testroot/stdout.expected
398 echo "D epsilon/psi/chi/tau" >> $testroot/stdout.expected
399 echo "D epsilon/psi/mu" >> $testroot/stdout.expected
400 echo "A epsilon/psi/tau" >> $testroot/stdout.expected
401 echo -n "Updated to commit " >> $testroot/stdout.expected
402 git_show_head $testroot/repo >> $testroot/stdout.expected
403 echo >> $testroot/stdout.expected
405 (cd $testroot/wt && got update > $testroot/stdout)
407 cmp -s $testroot/stdout.expected $testroot/stdout
409 if [ "$ret" != "0" ]; then
410 diff -u $testroot/stdout.expected $testroot/stdout
411 test_done "$testroot" "$ret"
415 if [ -e $testroot/wt/epsilon/psi/chi ]; then
416 echo "removed dir epsilon/psi/chi still exists on disk" >&2
417 test_done "$testroot" "1"
421 if [ -e $testroot/wt/epsilon/psi/mu ]; then
422 echo "removed file epsilon/psi/mu still exists on disk" >&2
423 test_done "$testroot" "1"
427 test_done "$testroot" "0"
430 function test_update_moves_files_to_new_dir {
431 local testroot=`test_init update_moves_files_to_new_dir`
433 mkdir $testroot/repo/epsilon/psi
434 echo mu > $testroot/repo/epsilon/psi/mu
435 mkdir $testroot/repo/epsilon/psi/chi
436 echo tau > $testroot/repo/epsilon/psi/chi/tau
437 (cd $testroot/repo && git add .)
438 git_commit $testroot/repo -m "adding a sub-directory beneath epsilon"
440 got checkout $testroot/repo $testroot/wt > /dev/null
442 if [ "$ret" != "0" ]; then
443 test_done "$testroot" "$ret"
447 mkdir -p $testroot/repo/epsilon-new/psi
448 (cd $testroot/repo && git mv epsilon/psi/mu epsilon-new/mu)
449 (cd $testroot/repo && git mv epsilon/psi/chi/tau epsilon-new/psi/tau)
450 git_commit $testroot/repo -m "moving files upwards"
452 echo "D epsilon/psi/chi/tau" > $testroot/stdout.expected
453 echo "D epsilon/psi/mu" >> $testroot/stdout.expected
454 echo "A epsilon-new/mu" >> $testroot/stdout.expected
455 echo "A epsilon-new/psi/tau" >> $testroot/stdout.expected
456 echo -n "Updated to commit " >> $testroot/stdout.expected
457 git_show_head $testroot/repo >> $testroot/stdout.expected
458 echo >> $testroot/stdout.expected
460 (cd $testroot/wt && got update > $testroot/stdout)
462 cmp -s $testroot/stdout.expected $testroot/stdout
464 if [ "$ret" != "0" ]; then
465 diff -u $testroot/stdout.expected $testroot/stdout
466 test_done "$testroot" "$ret"
470 if [ -e $testroot/wt/epsilon/psi/chi ]; then
471 echo "removed dir epsilon/psi/chi still exists on disk" >&2
472 test_done "$testroot" "1"
476 if [ -e $testroot/wt/epsilon/psi/mu ]; then
477 echo "removed file epsilon/psi/mu still exists on disk" >&2
478 test_done "$testroot" "1"
482 test_done "$testroot" "0"
485 function test_update_creates_missing_parent {
486 local testroot=`test_init update_creates_missing_parent 1`
488 touch $testroot/repo/Makefile
489 touch $testroot/repo/snake.6
490 touch $testroot/repo/snake.c
491 (cd $testroot/repo && git add .)
492 git_commit $testroot/repo -m "adding initial snake tree"
494 got checkout $testroot/repo $testroot/wt > /dev/null
496 if [ "$ret" != "0" ]; then
497 test_done "$testroot" "$ret"
501 mkdir -p $testroot/repo/snake
502 (cd $testroot/repo && git mv Makefile snake.6 snake.c snake)
503 touch $testroot/repo/snake/move.c
504 touch $testroot/repo/snake/pathnames.h
505 touch $testroot/repo/snake/snake.h
506 mkdir -p $testroot/repo/snscore
507 touch $testroot/repo/snscore/Makefile
508 touch $testroot/repo/snscore/snscore.c
509 (cd $testroot/repo && git add .)
510 git_commit $testroot/repo -m "restructuring snake tree"
512 echo "D Makefile" > $testroot/stdout.expected
513 echo "A snake/Makefile" >> $testroot/stdout.expected
514 echo "A snake/move.c" >> $testroot/stdout.expected
515 echo "A snake/pathnames.h" >> $testroot/stdout.expected
516 echo "A snake/snake.6" >> $testroot/stdout.expected
517 echo "A snake/snake.c" >> $testroot/stdout.expected
518 echo "A snake/snake.h" >> $testroot/stdout.expected
519 echo "D snake.6" >> $testroot/stdout.expected
520 echo "D snake.c" >> $testroot/stdout.expected
521 echo "A snscore/Makefile" >> $testroot/stdout.expected
522 echo "A snscore/snscore.c" >> $testroot/stdout.expected
523 echo -n "Updated to commit " >> $testroot/stdout.expected
524 git_show_head $testroot/repo >> $testroot/stdout.expected
525 echo >> $testroot/stdout.expected
527 (cd $testroot/wt && got update > $testroot/stdout)
529 cmp -s $testroot/stdout.expected $testroot/stdout
531 if [ "$ret" != "0" ]; then
532 diff -u $testroot/stdout.expected $testroot/stdout
534 test_done "$testroot" "$ret"
537 function test_update_creates_missing_parent_with_subdir {
538 local testroot=`test_init update_creates_missing_parent_with_subdir 1`
540 touch $testroot/repo/Makefile
541 touch $testroot/repo/snake.6
542 touch $testroot/repo/snake.c
543 (cd $testroot/repo && git add .)
544 git_commit $testroot/repo -m "adding initial snake tree"
546 got checkout $testroot/repo $testroot/wt > /dev/null
548 if [ "$ret" != "0" ]; then
549 test_done "$testroot" "$ret"
553 mkdir -p $testroot/repo/sss/snake
554 (cd $testroot/repo && git mv Makefile snake.6 snake.c sss/snake)
555 touch $testroot/repo/sss/snake/move.c
556 touch $testroot/repo/sss/snake/pathnames.h
557 touch $testroot/repo/sss/snake/snake.h
558 mkdir -p $testroot/repo/snscore
559 touch $testroot/repo/snscore/Makefile
560 touch $testroot/repo/snscore/snscore.c
561 (cd $testroot/repo && git add .)
562 git_commit $testroot/repo -m "restructuring snake tree"
564 echo "D Makefile" > $testroot/stdout.expected
565 echo "D snake.6" >> $testroot/stdout.expected
566 echo "D snake.c" >> $testroot/stdout.expected
567 echo "A snscore/Makefile" >> $testroot/stdout.expected
568 echo "A snscore/snscore.c" >> $testroot/stdout.expected
569 echo "A sss/snake/Makefile" >> $testroot/stdout.expected
570 echo "A sss/snake/move.c" >> $testroot/stdout.expected
571 echo "A sss/snake/pathnames.h" >> $testroot/stdout.expected
572 echo "A sss/snake/snake.6" >> $testroot/stdout.expected
573 echo "A sss/snake/snake.c" >> $testroot/stdout.expected
574 echo "A sss/snake/snake.h" >> $testroot/stdout.expected
575 echo -n "Updated to commit " >> $testroot/stdout.expected
576 git_show_head $testroot/repo >> $testroot/stdout.expected
577 echo >> $testroot/stdout.expected
579 (cd $testroot/wt && got update > $testroot/stdout)
581 cmp -s $testroot/stdout.expected $testroot/stdout
583 if [ "$ret" != "0" ]; then
584 diff -u $testroot/stdout.expected $testroot/stdout
585 test_done "$testroot" "$ret"
589 test_done "$testroot" "0"
592 function test_update_file_in_subsubdir {
593 local testroot=`test_init update_fle_in_subsubdir 1`
595 touch $testroot/repo/Makefile
596 mkdir -p $testroot/repo/altq
597 touch $testroot/repo/altq/if_altq.h
598 mkdir -p $testroot/repo/arch/alpha
599 touch $testroot/repo/arch/alpha/Makefile
600 (cd $testroot/repo && git add .)
601 git_commit $testroot/repo -m "adding initial tree"
603 got checkout $testroot/repo $testroot/wt > /dev/null
605 if [ "$ret" != "0" ]; then
606 test_done "$testroot" "$ret"
610 echo change > $testroot/repo/arch/alpha/Makefile
611 (cd $testroot/repo && git add .)
612 git_commit $testroot/repo -m "changed a file"
614 echo "U arch/alpha/Makefile" > $testroot/stdout.expected
615 echo -n "Updated to commit " >> $testroot/stdout.expected
616 git_show_head $testroot/repo >> $testroot/stdout.expected
617 echo >> $testroot/stdout.expected
619 (cd $testroot/wt && got update > $testroot/stdout)
621 cmp -s $testroot/stdout.expected $testroot/stdout
623 if [ "$ret" != "0" ]; then
624 diff -u $testroot/stdout.expected $testroot/stdout
625 test_done "$testroot" "$ret"
629 test_done "$testroot" "0"
632 function test_update_merges_file_edits {
633 local testroot=`test_init update_merges_file_edits`
635 echo "1" > $testroot/repo/numbers
636 echo "2" >> $testroot/repo/numbers
637 echo "3" >> $testroot/repo/numbers
638 echo "4" >> $testroot/repo/numbers
639 echo "5" >> $testroot/repo/numbers
640 echo "6" >> $testroot/repo/numbers
641 echo "7" >> $testroot/repo/numbers
642 echo "8" >> $testroot/repo/numbers
643 (cd $testroot/repo && git add numbers)
644 git_commit $testroot/repo -m "added numbers file"
646 got checkout $testroot/repo $testroot/wt > /dev/null
648 if [ "$ret" != "0" ]; then
649 test_done "$testroot" "$ret"
653 echo "modified alpha" > $testroot/repo/alpha
654 echo "modified beta" > $testroot/repo/beta
655 sed -i 's/2/22/' $testroot/repo/numbers
656 git_commit $testroot/repo -m "modified 3 files"
658 echo "modified alpha, too" > $testroot/wt/alpha
659 touch $testroot/wt/beta
660 sed -i 's/7/77/' $testroot/wt/numbers
662 echo "C alpha" > $testroot/stdout.expected
663 echo "U beta" >> $testroot/stdout.expected
664 echo "G numbers" >> $testroot/stdout.expected
665 echo -n "Updated to commit " >> $testroot/stdout.expected
666 git_show_head $testroot/repo >> $testroot/stdout.expected
667 echo >> $testroot/stdout.expected
669 (cd $testroot/wt && got update > $testroot/stdout)
671 cmp -s $testroot/stdout.expected $testroot/stdout
673 if [ "$ret" != "0" ]; then
674 diff -u $testroot/stdout.expected $testroot/stdout
675 test_done "$testroot" "$ret"
679 echo -n "<<<<<<< commit " > $testroot/content.expected
680 git_show_head $testroot/repo >> $testroot/content.expected
681 echo >> $testroot/content.expected
682 echo "modified alpha" >> $testroot/content.expected
683 echo "=======" >> $testroot/content.expected
684 echo "modified alpha, too" >> $testroot/content.expected
685 echo '>>>>>>> alpha' >> $testroot/content.expected
686 echo "modified beta" >> $testroot/content.expected
687 echo "1" >> $testroot/content.expected
688 echo "22" >> $testroot/content.expected
689 echo "3" >> $testroot/content.expected
690 echo "4" >> $testroot/content.expected
691 echo "5" >> $testroot/content.expected
692 echo "6" >> $testroot/content.expected
693 echo "77" >> $testroot/content.expected
694 echo "8" >> $testroot/content.expected
696 cat $testroot/wt/alpha > $testroot/content
697 cat $testroot/wt/beta >> $testroot/content
698 cat $testroot/wt/numbers >> $testroot/content
700 cmp -s $testroot/content.expected $testroot/content
702 if [ "$ret" != "0" ]; then
703 diff -u $testroot/content.expected $testroot/content
705 test_done "$testroot" "$ret"
708 function test_update_keeps_xbit {
709 local testroot=`test_init update_keeps_xbit 1`
711 touch $testroot/repo/xfile
712 chmod +x $testroot/repo/xfile
713 (cd $testroot/repo && git add .)
714 git_commit $testroot/repo -m "adding executable file"
716 got checkout $testroot/repo $testroot/wt > $testroot/stdout
718 if [ "$ret" != "0" ]; then
719 test_done "$testroot" "$ret"
723 echo foo > $testroot/repo/xfile
724 git_commit $testroot/repo -m "changed executable file"
726 echo "U xfile" > $testroot/stdout.expected
727 echo -n "Updated to commit " >> $testroot/stdout.expected
728 git_show_head $testroot/repo >> $testroot/stdout.expected
729 echo >> $testroot/stdout.expected
731 (cd $testroot/wt && got update > $testroot/stdout)
733 if [ "$ret" != "0" ]; then
734 test_done "$testroot" "$ret"
738 cmp -s $testroot/stdout.expected $testroot/stdout
740 if [ "$ret" != "0" ]; then
741 diff -u $testroot/stdout.expected $testroot/stdout
742 test_done "$testroot" "$ret"
746 ls -l $testroot/wt/xfile | grep -q '^-rwx'
748 if [ "$ret" != "0" ]; then
749 echo "file is not executable" >&2
750 ls -l $testroot/wt/xfile >&2
752 test_done "$testroot" "$ret"
755 function test_update_clears_xbit {
756 local testroot=`test_init update_clears_xbit 1`
758 touch $testroot/repo/xfile
759 chmod +x $testroot/repo/xfile
760 (cd $testroot/repo && git add .)
761 git_commit $testroot/repo -m "adding executable file"
763 got checkout $testroot/repo $testroot/wt > $testroot/stdout
765 if [ "$ret" != "0" ]; then
766 test_done "$testroot" "$ret"
770 ls -l $testroot/wt/xfile | grep -q '^-rwx'
772 if [ "$ret" != "0" ]; then
773 echo "file is not executable" >&2
774 ls -l $testroot/wt/xfile >&2
775 test_done "$testroot" "$ret"
779 # XXX git seems to require a file edit when flipping the x bit?
780 echo foo > $testroot/repo/xfile
781 chmod -x $testroot/repo/xfile
782 git_commit $testroot/repo -m "not an executable file anymore"
784 echo "U xfile" > $testroot/stdout.expected
785 echo -n "Updated to commit " >> $testroot/stdout.expected
786 git_show_head $testroot/repo >> $testroot/stdout.expected
787 echo >> $testroot/stdout.expected
789 (cd $testroot/wt && got update > $testroot/stdout)
791 if [ "$ret" != "0" ]; then
792 test_done "$testroot" "$ret"
796 cmp -s $testroot/stdout.expected $testroot/stdout
798 if [ "$ret" != "0" ]; then
799 diff -u $testroot/stdout.expected $testroot/stdout
800 test_done "$testroot" "$ret"
804 ls -l $testroot/wt/xfile | grep -q '^-rw-'
806 if [ "$ret" != "0" ]; then
807 echo "file is unexpectedly executable" >&2
808 ls -l $testroot/wt/xfile >&2
810 test_done "$testroot" "$ret"
813 function test_update_restores_missing_file {
814 local testroot=`test_init update_restores_missing_file`
816 got checkout $testroot/repo $testroot/wt > /dev/null
818 if [ "$ret" != "0" ]; then
819 test_done "$testroot" "$ret"
823 rm $testroot/wt/alpha
825 echo "! alpha" > $testroot/stdout.expected
826 echo -n "Updated to commit " >> $testroot/stdout.expected
827 git_show_head $testroot/repo >> $testroot/stdout.expected
828 echo >> $testroot/stdout.expected
829 (cd $testroot/wt && got update > $testroot/stdout)
831 cmp -s $testroot/stdout.expected $testroot/stdout
833 if [ "$ret" != "0" ]; then
834 diff -u $testroot/stdout.expected $testroot/stdout
835 test_done "$testroot" "$ret"
839 echo "alpha" > $testroot/content.expected
841 cat $testroot/wt/alpha > $testroot/content
843 cmp -s $testroot/content.expected $testroot/content
845 if [ "$ret" != "0" ]; then
846 diff -u $testroot/content.expected $testroot/content
848 test_done "$testroot" "$ret"
851 function test_update_conflict_wt_add_vs_repo_add {
852 local testroot=`test_init update_conflict_wt_add_vs_repo_add`
854 got checkout $testroot/repo $testroot/wt > /dev/null
856 if [ "$ret" != "0" ]; then
857 test_done "$testroot" "$ret"
861 echo "new" > $testroot/repo/gamma/new
862 (cd $testroot/repo && git add .)
863 git_commit $testroot/repo -m "adding a new file"
865 echo "also new" > $testroot/wt/gamma/new
866 (cd $testroot/wt && got add gamma/new >/dev/null)
868 (cd $testroot/wt && got update > $testroot/stdout)
870 echo "C gamma/new" > $testroot/stdout.expected
871 echo -n "Updated to commit " >> $testroot/stdout.expected
872 git_show_head $testroot/repo >> $testroot/stdout.expected
873 echo >> $testroot/stdout.expected
874 cmp -s $testroot/stdout.expected $testroot/stdout
876 if [ "$ret" != "0" ]; then
877 diff -u $testroot/stdout.expected $testroot/stdout
878 test_done "$testroot" "$ret"
882 echo -n "<<<<<<< commit " > $testroot/content.expected
883 git_show_head $testroot/repo >> $testroot/content.expected
884 echo >> $testroot/content.expected
885 echo "new" >> $testroot/content.expected
886 echo "=======" >> $testroot/content.expected
887 echo "also new" >> $testroot/content.expected
888 echo '>>>>>>> gamma/new' >> $testroot/content.expected
890 cat $testroot/wt/gamma/new > $testroot/content
892 cmp -s $testroot/content.expected $testroot/content
894 if [ "$ret" != "0" ]; then
895 diff -u $testroot/content.expected $testroot/content
896 test_done "$testroot" "$ret"
900 # resolve the conflict
901 echo "new and also new" > $testroot/wt/gamma/new
902 echo 'M gamma/new' > $testroot/stdout.expected
903 (cd $testroot/wt && got status > $testroot/stdout)
904 cmp -s $testroot/stdout.expected $testroot/stdout
906 if [ "$ret" != "0" ]; then
907 diff -u $testroot/stdout.expected $testroot/stdout
909 test_done "$testroot" "$ret"
912 function test_update_conflict_wt_edit_vs_repo_rm {
913 local testroot=`test_init update_conflict_wt_edit_vs_repo_rm`
915 got checkout $testroot/repo $testroot/wt > /dev/null
917 if [ "$ret" != "0" ]; then
918 test_done "$testroot" "$ret"
922 (cd $testroot/repo && git rm -q beta)
923 git_commit $testroot/repo -m "removing a file"
925 echo "modified beta" > $testroot/wt/beta
927 (cd $testroot/wt && got update > $testroot/stdout)
929 echo "G beta" > $testroot/stdout.expected
930 echo -n "Updated to commit " >> $testroot/stdout.expected
931 git_show_head $testroot/repo >> $testroot/stdout.expected
932 echo >> $testroot/stdout.expected
933 cmp -s $testroot/stdout.expected $testroot/stdout
935 if [ "$ret" != "0" ]; then
936 diff -u $testroot/stdout.expected $testroot/stdout
937 test_done "$testroot" "$ret"
941 echo "modified beta" > $testroot/content.expected
943 cat $testroot/wt/beta > $testroot/content
945 cmp -s $testroot/content.expected $testroot/content
947 if [ "$ret" != "0" ]; then
948 diff -u $testroot/content.expected $testroot/content
949 test_done "$testroot" "$ret"
953 # beta is now an added file... we don't flag tree conflicts yet
954 echo 'A beta' > $testroot/stdout.expected
955 (cd $testroot/wt && got status > $testroot/stdout)
956 cmp -s $testroot/stdout.expected $testroot/stdout
958 if [ "$ret" != "0" ]; then
959 diff -u $testroot/stdout.expected $testroot/stdout
961 test_done "$testroot" "$ret"
964 function test_update_conflict_wt_rm_vs_repo_edit {
965 local testroot=`test_init update_conflict_wt_rm_vs_repo_edit`
967 got checkout $testroot/repo $testroot/wt > /dev/null
969 if [ "$ret" != "0" ]; then
970 test_done "$testroot" "$ret"
974 echo "modified beta" > $testroot/repo/beta
975 git_commit $testroot/repo -m "modified a file"
977 (cd $testroot/wt && got rm beta > /dev/null)
979 (cd $testroot/wt && got update > $testroot/stdout)
981 echo "G beta" > $testroot/stdout.expected
982 echo -n "Updated to commit " >> $testroot/stdout.expected
983 git_show_head $testroot/repo >> $testroot/stdout.expected
984 echo >> $testroot/stdout.expected
985 cmp -s $testroot/stdout.expected $testroot/stdout
987 if [ "$ret" != "0" ]; then
988 diff -u $testroot/stdout.expected $testroot/stdout
989 test_done "$testroot" "$ret"
993 # beta remains a deleted file... we don't flag tree conflicts yet
994 echo 'D beta' > $testroot/stdout.expected
995 (cd $testroot/wt && got status > $testroot/stdout)
996 cmp -s $testroot/stdout.expected $testroot/stdout
998 if [ "$ret" != "0" ]; then
999 diff -u $testroot/stdout.expected $testroot/stdout
1000 test_done "$testroot" "$ret"
1004 # 'got diff' should show post-update contents of beta being deleted
1005 local head_rev=`git_show_head $testroot/repo`
1006 echo "diff $head_rev $testroot/wt" > $testroot/stdout.expected
1007 echo -n 'blob - ' >> $testroot/stdout.expected
1008 got tree -r $testroot/repo -i | grep 'beta$' | cut -d' ' -f 1 \
1009 >> $testroot/stdout.expected
1010 echo 'file + /dev/null' >> $testroot/stdout.expected
1011 echo '--- beta' >> $testroot/stdout.expected
1012 echo '+++ beta' >> $testroot/stdout.expected
1013 echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
1014 echo '-modified beta' >> $testroot/stdout.expected
1016 (cd $testroot/wt && got diff > $testroot/stdout)
1017 cmp -s $testroot/stdout.expected $testroot/stdout
1019 if [ "$ret" != "0" ]; then
1020 diff -u $testroot/stdout.expected $testroot/stdout
1022 test_done "$testroot" "$ret"
1025 function test_update_conflict_wt_rm_vs_repo_rm {
1026 local testroot=`test_init update_conflict_wt_rm_vs_repo_rm`
1028 got checkout $testroot/repo $testroot/wt > /dev/null
1030 if [ "$ret" != "0" ]; then
1031 test_done "$testroot" "$ret"
1035 (cd $testroot/repo && git rm -q beta)
1036 git_commit $testroot/repo -m "removing a file"
1038 (cd $testroot/wt && got rm beta > /dev/null)
1040 (cd $testroot/wt && got update > $testroot/stdout)
1042 echo "D beta" > $testroot/stdout.expected
1043 echo -n "Updated to commit " >> $testroot/stdout.expected
1044 git_show_head $testroot/repo >> $testroot/stdout.expected
1045 echo >> $testroot/stdout.expected
1046 cmp -s $testroot/stdout.expected $testroot/stdout
1048 if [ "$ret" != "0" ]; then
1049 diff -u $testroot/stdout.expected $testroot/stdout
1050 test_done "$testroot" "$ret"
1054 # beta is now gone... we don't flag tree conflicts yet
1055 echo 'got: bad path' > $testroot/stderr.expected
1056 (cd $testroot/wt && got status beta 2> $testroot/stderr)
1057 cmp -s $testroot/stderr.expected $testroot/stderr
1059 if [ "$ret" != "0" ]; then
1060 diff -u $testroot/stderr.expected $testroot/stderr
1061 test_done "$testroot" "$ret"
1065 if [ -e $testroot/wt/beta ]; then
1066 echo "removed file beta still exists on disk" >&2
1067 test_done "$testroot" "1"
1071 test_done "$testroot" "0"
1074 function test_update_partial {
1075 local testroot=`test_init update_partial`
1077 got checkout $testroot/repo $testroot/wt > /dev/null
1079 if [ "$ret" != "0" ]; then
1080 test_done "$testroot" "$ret"
1084 echo "modified alpha" > $testroot/repo/alpha
1085 echo "modified beta" > $testroot/repo/beta
1086 echo "modified epsilon/zeta" > $testroot/repo/epsilon/zeta
1087 git_commit $testroot/repo -m "modified two files"
1089 for f in alpha beta; do
1090 echo "U $f" > $testroot/stdout.expected
1091 echo -n "Updated to commit " >> $testroot/stdout.expected
1092 git_show_head $testroot/repo >> $testroot/stdout.expected
1093 echo >> $testroot/stdout.expected
1095 (cd $testroot/wt && got update $f > $testroot/stdout)
1097 cmp -s $testroot/stdout.expected $testroot/stdout
1099 if [ "$ret" != "0" ]; then
1100 diff -u $testroot/stdout.expected $testroot/stdout
1101 test_done "$testroot" "$ret"
1105 echo "modified $f" > $testroot/content.expected
1106 cat $testroot/wt/$f > $testroot/content
1108 cmp -s $testroot/content.expected $testroot/content
1110 if [ "$ret" != "0" ]; then
1111 diff -u $testroot/content.expected $testroot/content
1112 test_done "$testroot" "$ret"
1117 echo "U epsilon/zeta" > $testroot/stdout.expected
1118 echo -n "Updated to commit " >> $testroot/stdout.expected
1119 git_show_head $testroot/repo >> $testroot/stdout.expected
1120 echo >> $testroot/stdout.expected
1122 (cd $testroot/wt && got update epsilon > $testroot/stdout)
1124 cmp -s $testroot/stdout.expected $testroot/stdout
1126 if [ "$ret" != "0" ]; then
1127 diff -u $testroot/stdout.expected $testroot/stdout
1128 test_done "$testroot" "$ret"
1132 echo "modified epsilon/zeta" > $testroot/content.expected
1133 cat $testroot/wt/epsilon/zeta > $testroot/content
1135 cmp -s $testroot/content.expected $testroot/content
1137 if [ "$ret" != "0" ]; then
1138 diff -u $testroot/content.expected $testroot/content
1139 test_done "$testroot" "$ret"
1143 test_done "$testroot" "$ret"
1146 function test_update_partial_add {
1147 local testroot=`test_init update_partial_add`
1149 got checkout $testroot/repo $testroot/wt > /dev/null
1151 if [ "$ret" != "0" ]; then
1152 test_done "$testroot" "$ret"
1156 echo "new" > $testroot/repo/new
1157 echo "epsilon/new2" > $testroot/repo/epsilon/new2
1158 (cd $testroot/repo && git add .)
1159 git_commit $testroot/repo -m "added two files"
1161 for f in new epsilon/new2; do
1162 echo "A $f" > $testroot/stdout.expected
1163 echo -n "Updated to commit " >> $testroot/stdout.expected
1164 git_show_head $testroot/repo >> $testroot/stdout.expected
1165 echo >> $testroot/stdout.expected
1167 (cd $testroot/wt && got update $f > $testroot/stdout)
1169 cmp -s $testroot/stdout.expected $testroot/stdout
1171 if [ "$ret" != "0" ]; then
1172 diff -u $testroot/stdout.expected $testroot/stdout
1173 test_done "$testroot" "$ret"
1177 echo "$f" > $testroot/content.expected
1178 cat $testroot/wt/$f > $testroot/content
1180 cmp -s $testroot/content.expected $testroot/content
1182 if [ "$ret" != "0" ]; then
1183 diff -u $testroot/content.expected $testroot/content
1184 test_done "$testroot" "$ret"
1188 test_done "$testroot" "$ret"
1191 function test_update_partial_rm {
1192 local testroot=`test_init update_partial_rm`
1194 got checkout $testroot/repo $testroot/wt > /dev/null
1196 if [ "$ret" != "0" ]; then
1197 test_done "$testroot" "$ret"
1201 (cd $testroot/repo && git rm -q alpha)
1202 (cd $testroot/repo && git rm -q epsilon/zeta)
1203 git_commit $testroot/repo -m "removed two files"
1205 for f in alpha epsilon/zeta; do
1206 echo "got: no such entry found in tree" \
1207 > $testroot/stderr.expected
1209 (cd $testroot/wt && got update $f 2> $testroot/stderr)
1211 if [ "$ret" == "0" ]; then
1212 echo "update succeeded unexpectedly" >&2
1213 test_done "$testroot" "1"
1217 cmp -s $testroot/stderr.expected $testroot/stderr
1219 if [ "$ret" != "0" ]; then
1220 diff -u $testroot/stderr.expected $testroot/stderr
1221 test_done "$testroot" "$ret"
1225 test_done "$testroot" "$ret"
1228 function test_update_partial_dir {
1229 local testroot=`test_init update_partial_dir`
1231 got checkout $testroot/repo $testroot/wt > /dev/null
1233 if [ "$ret" != "0" ]; then
1234 test_done "$testroot" "$ret"
1238 echo "modified alpha" > $testroot/repo/alpha
1239 echo "modified beta" > $testroot/repo/beta
1240 echo "modified epsilon/zeta" > $testroot/repo/epsilon/zeta
1241 git_commit $testroot/repo -m "modified two files"
1243 echo "U epsilon/zeta" > $testroot/stdout.expected
1244 echo -n "Updated to commit " >> $testroot/stdout.expected
1245 git_show_head $testroot/repo >> $testroot/stdout.expected
1246 echo >> $testroot/stdout.expected
1248 (cd $testroot/wt && got update epsilon > $testroot/stdout)
1250 cmp -s $testroot/stdout.expected $testroot/stdout
1252 if [ "$ret" != "0" ]; then
1253 diff -u $testroot/stdout.expected $testroot/stdout
1254 test_done "$testroot" "$ret"
1258 echo "modified epsilon/zeta" > $testroot/content.expected
1259 cat $testroot/wt/epsilon/zeta > $testroot/content
1261 cmp -s $testroot/content.expected $testroot/content
1263 if [ "$ret" != "0" ]; then
1264 diff -u $testroot/content.expected $testroot/content
1265 test_done "$testroot" "$ret"
1268 test_done "$testroot" "$ret"
1272 function test_update_moved_branch_ref {
1273 local testroot=`test_init update_moved_branch_ref`
1275 git clone -q --mirror $testroot/repo $testroot/repo2
1277 echo "modified alpha with git" > $testroot/repo/alpha
1278 git_commit $testroot/repo -m "modified alpha with git"
1280 got checkout $testroot/repo2 $testroot/wt > /dev/null
1282 if [ "$ret" != "0" ]; then
1283 test_done "$testroot" "$ret"
1287 echo "modified alpha with got" > $testroot/wt/alpha
1288 (cd $testroot/wt && got commit -m "modified alpha with got" > /dev/null)
1290 # + xxxxxxx...yyyyyyy master -> master (forced update)
1291 (cd $testroot/repo2 && git fetch -q --all)
1293 echo -n > $testroot/stdout.expected
1294 echo -n "got: work tree's head reference now points to a different " \
1295 > $testroot/stderr.expected
1296 echo "branch; new head reference and/or update -b required" \
1297 >> $testroot/stderr.expected
1299 (cd $testroot/wt && got update > $testroot/stdout 2> $testroot/stderr)
1301 cmp -s $testroot/stdout.expected $testroot/stdout
1303 if [ "$ret" != "0" ]; then
1304 diff -u $testroot/stdout.expected $testroot/stdout
1305 test_done "$testroot" "$ret"
1309 cmp -s $testroot/stderr.expected $testroot/stderr
1311 if [ "$ret" != "0" ]; then
1312 diff -u $testroot/stderr.expected $testroot/stderr
1314 test_done "$testroot" "$ret"
1317 function test_update_to_another_branch {
1318 local testroot=`test_init update_to_another_branch`
1320 got checkout $testroot/repo $testroot/wt > /dev/null
1322 if [ "$ret" != "0" ]; then
1323 test_done "$testroot" "$ret"
1327 echo 'refs/heads/master'> $testroot/head-ref.expected
1328 cmp -s $testroot/head-ref.expected $testroot/wt/.got/head-ref
1330 if [ "$ret" != "0" ]; then
1331 diff -u $testroot/head-ref.expected $testroot/wt/.got/head-ref
1332 test_done "$testroot" "$ret"
1336 (cd $testroot/repo && git checkout -q -b newbranch)
1337 echo "modified alpha on new branch" > $testroot/repo/alpha
1338 git_commit $testroot/repo -m "modified alpha on new branch"
1340 echo "modified alpha in work tree" > $testroot/wt/alpha
1342 echo "Switching work tree from refs/heads/master to refs/heads/newbranch" > $testroot/stdout.expected
1343 echo "C alpha" >> $testroot/stdout.expected
1344 echo -n "Updated to commit " >> $testroot/stdout.expected
1345 git_show_head $testroot/repo >> $testroot/stdout.expected
1346 echo >> $testroot/stdout.expected
1348 (cd $testroot/wt && got update -b newbranch > $testroot/stdout)
1350 cmp -s $testroot/stdout.expected $testroot/stdout
1352 if [ "$ret" != "0" ]; then
1353 diff -u $testroot/stdout.expected $testroot/stdout
1354 test_done "$testroot" "$ret"
1358 echo -n "<<<<<<< commit " > $testroot/content.expected
1359 git_show_head $testroot/repo >> $testroot/content.expected
1360 echo >> $testroot/content.expected
1361 echo "modified alpha on new branch" >> $testroot/content.expected
1362 echo "=======" >> $testroot/content.expected
1363 echo "modified alpha in work tree" >> $testroot/content.expected
1364 echo '>>>>>>> alpha' >> $testroot/content.expected
1366 cat $testroot/wt/alpha > $testroot/content
1368 cmp -s $testroot/content.expected $testroot/content
1370 if [ "$ret" != "0" ]; then
1371 diff -u $testroot/content.expected $testroot/content
1372 test_done "$testroot" "$ret"
1376 echo 'refs/heads/newbranch'> $testroot/head-ref.expected
1377 cmp -s $testroot/head-ref.expected $testroot/wt/.got/head-ref
1379 if [ "$ret" != "0" ]; then
1380 diff -u $testroot/head-ref.expected $testroot/wt/.got/head-ref
1381 test_done "$testroot" "$ret"
1385 test_done "$testroot" "$ret"
1388 function test_update_to_commit_on_wrong_branch {
1389 local testroot=`test_init update_to_commit_on_wrong_branch`
1391 got checkout $testroot/repo $testroot/wt > /dev/null
1393 if [ "$ret" != "0" ]; then
1394 test_done "$testroot" "$ret"
1398 (cd $testroot/repo && git checkout -q -b newbranch)
1399 echo "modified alpha on new branch" > $testroot/repo/alpha
1400 git_commit $testroot/repo -m "modified alpha on new branch"
1402 echo -n "" > $testroot/stdout.expected
1403 echo "got: target commit is on a different branch" \
1404 > $testroot/stderr.expected
1406 local head_rev=`git_show_head $testroot/repo`
1407 (cd $testroot/wt && got update -c $head_rev > $testroot/stdout \
1408 2> $testroot/stderr)
1410 cmp -s $testroot/stdout.expected $testroot/stdout
1412 if [ "$ret" != "0" ]; then
1413 diff -u $testroot/stdout.expected $testroot/stdout
1414 test_done "$testroot" "$ret"
1418 cmp -s $testroot/stderr.expected $testroot/stderr
1420 if [ "$ret" != "0" ]; then
1421 diff -u $testroot/stderr.expected $testroot/stderr
1422 test_done "$testroot" "$ret"
1426 test_done "$testroot" "$ret"
1429 function test_update_bumps_base_commit_id {
1430 local testroot=`test_init update_bumps_base_commit_id`
1432 echo "psi" > $testroot/repo/epsilon/psi
1433 (cd $testroot/repo && git add .)
1434 git_commit $testroot/repo -m "adding another file"
1436 got checkout $testroot/repo $testroot/wt > /dev/null
1438 if [ "$ret" != "0" ]; then
1439 test_done "$testroot" "$ret"
1443 echo "modified psi" > $testroot/wt/epsilon/psi
1444 (cd $testroot/wt && got commit -m "changed psi" > $testroot/stdout)
1446 local head_rev=`git_show_head $testroot/repo`
1447 echo "M epsilon/psi" > $testroot/stdout.expected
1448 echo "Created commit $head_rev" >> $testroot/stdout.expected
1449 cmp -s $testroot/stdout.expected $testroot/stdout
1451 if [ "$ret" != "0" ]; then
1452 diff -u $testroot/stdout.expected $testroot/stdout
1453 test_done "$testroot" "$ret"
1457 echo "modified zeta" > $testroot/wt/epsilon/zeta
1458 (cd $testroot/wt && got commit -m "changed zeta" > $testroot/stdout \
1459 2> $testroot/stderr)
1461 echo -n "" > $testroot/stdout.expected
1462 echo "got: work tree must be updated before these changes can be committed" > $testroot/stderr.expected
1463 cmp -s $testroot/stderr.expected $testroot/stderr
1465 if [ "$ret" != "0" ]; then
1466 diff -u $testroot/stderr.expected $testroot/stderr
1467 test_done "$testroot" "$ret"
1471 (cd $testroot/wt && got update > $testroot/stdout)
1473 echo -n "Updated to commit " >> $testroot/stdout.expected
1474 git_show_head $testroot/repo >> $testroot/stdout.expected
1475 echo >> $testroot/stdout.expected
1476 cmp -s $testroot/stdout.expected $testroot/stdout
1478 if [ "$ret" != "0" ]; then
1479 diff -u $testroot/stdout.expected $testroot/stdout
1480 test_done "$testroot" "$ret"
1484 (cd $testroot/wt && got commit -m "changed zeta" > $testroot/stdout)
1486 local head_rev=`git_show_head $testroot/repo`
1487 echo "M epsilon/zeta" > $testroot/stdout.expected
1488 echo "Created commit $head_rev" >> $testroot/stdout.expected
1489 cmp -s $testroot/stdout.expected $testroot/stdout
1491 if [ "$ret" != "0" ]; then
1492 diff -u $testroot/stdout.expected $testroot/stdout
1493 test_done "$testroot" "$ret"
1497 test_done "$testroot" "$ret"
1500 run_test test_update_basic
1501 run_test test_update_adds_file
1502 run_test test_update_deletes_file
1503 run_test test_update_deletes_dir
1504 run_test test_update_deletes_dir_with_path_prefix
1505 run_test test_update_deletes_dir_recursively
1506 run_test test_update_sibling_dirs_with_common_prefix
1507 run_test test_update_dir_with_dot_sibling
1508 run_test test_update_moves_files_upwards
1509 run_test test_update_moves_files_to_new_dir
1510 run_test test_update_creates_missing_parent
1511 run_test test_update_creates_missing_parent_with_subdir
1512 run_test test_update_file_in_subsubdir
1513 run_test test_update_merges_file_edits
1514 run_test test_update_keeps_xbit
1515 run_test test_update_clears_xbit
1516 run_test test_update_restores_missing_file
1517 run_test test_update_conflict_wt_add_vs_repo_add
1518 run_test test_update_conflict_wt_edit_vs_repo_rm
1519 run_test test_update_conflict_wt_rm_vs_repo_edit
1520 run_test test_update_conflict_wt_rm_vs_repo_rm
1521 run_test test_update_partial
1522 run_test test_update_partial_add
1523 run_test test_update_partial_rm
1524 run_test test_update_partial_dir
1525 run_test test_update_moved_branch_ref
1526 run_test test_update_to_another_branch
1527 run_test test_update_to_commit_on_wrong_branch
1528 run_test test_update_bumps_base_commit_id