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"
645 local base_commit=`git_show_head $testroot/repo`
647 got checkout $testroot/repo $testroot/wt > /dev/null
649 if [ "$ret" != "0" ]; then
650 test_done "$testroot" "$ret"
654 echo "modified alpha" > $testroot/repo/alpha
655 echo "modified beta" > $testroot/repo/beta
656 sed -i 's/2/22/' $testroot/repo/numbers
657 git_commit $testroot/repo -m "modified 3 files"
659 echo "modified alpha, too" > $testroot/wt/alpha
660 touch $testroot/wt/beta
661 sed -i 's/7/77/' $testroot/wt/numbers
663 echo "C alpha" > $testroot/stdout.expected
664 echo "U beta" >> $testroot/stdout.expected
665 echo "G numbers" >> $testroot/stdout.expected
666 echo -n "Updated to commit " >> $testroot/stdout.expected
667 git_show_head $testroot/repo >> $testroot/stdout.expected
668 echo >> $testroot/stdout.expected
669 echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
671 (cd $testroot/wt && got update > $testroot/stdout)
673 cmp -s $testroot/stdout.expected $testroot/stdout
675 if [ "$ret" != "0" ]; then
676 diff -u $testroot/stdout.expected $testroot/stdout
677 test_done "$testroot" "$ret"
681 echo -n "<<<<<<< merged change: commit " > $testroot/content.expected
682 git_show_head $testroot/repo >> $testroot/content.expected
683 echo >> $testroot/content.expected
684 echo "modified alpha" >> $testroot/content.expected
685 echo "||||||| 3-way merge base: commit $base_commit" \
686 >> $testroot/content.expected
687 echo "alpha" >> $testroot/content.expected
688 echo "=======" >> $testroot/content.expected
689 echo "modified alpha, too" >> $testroot/content.expected
690 echo '>>>>>>>' >> $testroot/content.expected
691 echo "modified beta" >> $testroot/content.expected
692 echo "1" >> $testroot/content.expected
693 echo "22" >> $testroot/content.expected
694 echo "3" >> $testroot/content.expected
695 echo "4" >> $testroot/content.expected
696 echo "5" >> $testroot/content.expected
697 echo "6" >> $testroot/content.expected
698 echo "77" >> $testroot/content.expected
699 echo "8" >> $testroot/content.expected
701 cat $testroot/wt/alpha > $testroot/content
702 cat $testroot/wt/beta >> $testroot/content
703 cat $testroot/wt/numbers >> $testroot/content
705 cmp -s $testroot/content.expected $testroot/content
707 if [ "$ret" != "0" ]; then
708 diff -u $testroot/content.expected $testroot/content
710 test_done "$testroot" "$ret"
713 function test_update_keeps_xbit {
714 local testroot=`test_init update_keeps_xbit 1`
716 touch $testroot/repo/xfile
717 chmod +x $testroot/repo/xfile
718 (cd $testroot/repo && git add .)
719 git_commit $testroot/repo -m "adding executable file"
721 got checkout $testroot/repo $testroot/wt > $testroot/stdout
723 if [ "$ret" != "0" ]; then
724 test_done "$testroot" "$ret"
728 echo foo > $testroot/repo/xfile
729 git_commit $testroot/repo -m "changed executable file"
731 echo "U xfile" > $testroot/stdout.expected
732 echo -n "Updated to commit " >> $testroot/stdout.expected
733 git_show_head $testroot/repo >> $testroot/stdout.expected
734 echo >> $testroot/stdout.expected
736 (cd $testroot/wt && got update > $testroot/stdout)
738 if [ "$ret" != "0" ]; then
739 test_done "$testroot" "$ret"
743 cmp -s $testroot/stdout.expected $testroot/stdout
745 if [ "$ret" != "0" ]; then
746 diff -u $testroot/stdout.expected $testroot/stdout
747 test_done "$testroot" "$ret"
751 ls -l $testroot/wt/xfile | grep -q '^-rwx'
753 if [ "$ret" != "0" ]; then
754 echo "file is not executable" >&2
755 ls -l $testroot/wt/xfile >&2
757 test_done "$testroot" "$ret"
760 function test_update_clears_xbit {
761 local testroot=`test_init update_clears_xbit 1`
763 touch $testroot/repo/xfile
764 chmod +x $testroot/repo/xfile
765 (cd $testroot/repo && git add .)
766 git_commit $testroot/repo -m "adding executable file"
768 got checkout $testroot/repo $testroot/wt > $testroot/stdout
770 if [ "$ret" != "0" ]; then
771 test_done "$testroot" "$ret"
775 ls -l $testroot/wt/xfile | grep -q '^-rwx'
777 if [ "$ret" != "0" ]; then
778 echo "file is not executable" >&2
779 ls -l $testroot/wt/xfile >&2
780 test_done "$testroot" "$ret"
784 # XXX git seems to require a file edit when flipping the x bit?
785 echo foo > $testroot/repo/xfile
786 chmod -x $testroot/repo/xfile
787 git_commit $testroot/repo -m "not an executable file anymore"
789 echo "U xfile" > $testroot/stdout.expected
790 echo -n "Updated to commit " >> $testroot/stdout.expected
791 git_show_head $testroot/repo >> $testroot/stdout.expected
792 echo >> $testroot/stdout.expected
794 (cd $testroot/wt && got update > $testroot/stdout)
796 if [ "$ret" != "0" ]; then
797 test_done "$testroot" "$ret"
801 cmp -s $testroot/stdout.expected $testroot/stdout
803 if [ "$ret" != "0" ]; then
804 diff -u $testroot/stdout.expected $testroot/stdout
805 test_done "$testroot" "$ret"
809 ls -l $testroot/wt/xfile | grep -q '^-rw-'
811 if [ "$ret" != "0" ]; then
812 echo "file is unexpectedly executable" >&2
813 ls -l $testroot/wt/xfile >&2
815 test_done "$testroot" "$ret"
818 function test_update_restores_missing_file {
819 local testroot=`test_init update_restores_missing_file`
821 got checkout $testroot/repo $testroot/wt > /dev/null
823 if [ "$ret" != "0" ]; then
824 test_done "$testroot" "$ret"
828 rm $testroot/wt/alpha
830 echo "! alpha" > $testroot/stdout.expected
831 echo -n "Updated to commit " >> $testroot/stdout.expected
832 git_show_head $testroot/repo >> $testroot/stdout.expected
833 echo >> $testroot/stdout.expected
834 (cd $testroot/wt && got update > $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 "alpha" > $testroot/content.expected
846 cat $testroot/wt/alpha > $testroot/content
848 cmp -s $testroot/content.expected $testroot/content
850 if [ "$ret" != "0" ]; then
851 diff -u $testroot/content.expected $testroot/content
853 test_done "$testroot" "$ret"
856 function test_update_conflict_wt_add_vs_repo_add {
857 local testroot=`test_init update_conflict_wt_add_vs_repo_add`
859 got checkout $testroot/repo $testroot/wt > /dev/null
861 if [ "$ret" != "0" ]; then
862 test_done "$testroot" "$ret"
866 echo "new" > $testroot/repo/gamma/new
867 (cd $testroot/repo && git add .)
868 git_commit $testroot/repo -m "adding a new file"
870 echo "also new" > $testroot/wt/gamma/new
871 (cd $testroot/wt && got add gamma/new >/dev/null)
873 (cd $testroot/wt && got update > $testroot/stdout)
875 echo "C gamma/new" > $testroot/stdout.expected
876 echo -n "Updated to commit " >> $testroot/stdout.expected
877 git_show_head $testroot/repo >> $testroot/stdout.expected
878 echo >> $testroot/stdout.expected
879 echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
881 cmp -s $testroot/stdout.expected $testroot/stdout
883 if [ "$ret" != "0" ]; then
884 diff -u $testroot/stdout.expected $testroot/stdout
885 test_done "$testroot" "$ret"
889 echo -n "<<<<<<< merged change: commit " > $testroot/content.expected
890 git_show_head $testroot/repo >> $testroot/content.expected
891 echo >> $testroot/content.expected
892 echo "new" >> $testroot/content.expected
893 echo "=======" >> $testroot/content.expected
894 echo "also new" >> $testroot/content.expected
895 echo '>>>>>>>' >> $testroot/content.expected
897 cat $testroot/wt/gamma/new > $testroot/content
899 cmp -s $testroot/content.expected $testroot/content
901 if [ "$ret" != "0" ]; then
902 diff -u $testroot/content.expected $testroot/content
903 test_done "$testroot" "$ret"
907 # resolve the conflict
908 echo "new and also new" > $testroot/wt/gamma/new
909 echo 'M gamma/new' > $testroot/stdout.expected
910 (cd $testroot/wt && got status > $testroot/stdout)
911 cmp -s $testroot/stdout.expected $testroot/stdout
913 if [ "$ret" != "0" ]; then
914 diff -u $testroot/stdout.expected $testroot/stdout
916 test_done "$testroot" "$ret"
919 function test_update_conflict_wt_edit_vs_repo_rm {
920 local testroot=`test_init update_conflict_wt_edit_vs_repo_rm`
922 got checkout $testroot/repo $testroot/wt > /dev/null
924 if [ "$ret" != "0" ]; then
925 test_done "$testroot" "$ret"
929 (cd $testroot/repo && git rm -q beta)
930 git_commit $testroot/repo -m "removing a file"
932 echo "modified beta" > $testroot/wt/beta
934 (cd $testroot/wt && got update > $testroot/stdout)
936 echo "G beta" > $testroot/stdout.expected
937 echo -n "Updated to commit " >> $testroot/stdout.expected
938 git_show_head $testroot/repo >> $testroot/stdout.expected
939 echo >> $testroot/stdout.expected
940 cmp -s $testroot/stdout.expected $testroot/stdout
942 if [ "$ret" != "0" ]; then
943 diff -u $testroot/stdout.expected $testroot/stdout
944 test_done "$testroot" "$ret"
948 echo "modified beta" > $testroot/content.expected
950 cat $testroot/wt/beta > $testroot/content
952 cmp -s $testroot/content.expected $testroot/content
954 if [ "$ret" != "0" ]; then
955 diff -u $testroot/content.expected $testroot/content
956 test_done "$testroot" "$ret"
960 # beta is now an added file... we don't flag tree conflicts yet
961 echo 'A beta' > $testroot/stdout.expected
962 (cd $testroot/wt && got status > $testroot/stdout)
963 cmp -s $testroot/stdout.expected $testroot/stdout
965 if [ "$ret" != "0" ]; then
966 diff -u $testroot/stdout.expected $testroot/stdout
968 test_done "$testroot" "$ret"
971 function test_update_conflict_wt_rm_vs_repo_edit {
972 local testroot=`test_init update_conflict_wt_rm_vs_repo_edit`
974 got checkout $testroot/repo $testroot/wt > /dev/null
976 if [ "$ret" != "0" ]; then
977 test_done "$testroot" "$ret"
981 echo "modified beta" > $testroot/repo/beta
982 git_commit $testroot/repo -m "modified a file"
984 (cd $testroot/wt && got rm beta > /dev/null)
986 (cd $testroot/wt && got update > $testroot/stdout)
988 echo "G beta" > $testroot/stdout.expected
989 echo -n "Updated to commit " >> $testroot/stdout.expected
990 git_show_head $testroot/repo >> $testroot/stdout.expected
991 echo >> $testroot/stdout.expected
992 cmp -s $testroot/stdout.expected $testroot/stdout
994 if [ "$ret" != "0" ]; then
995 diff -u $testroot/stdout.expected $testroot/stdout
996 test_done "$testroot" "$ret"
1000 # beta remains a deleted file... we don't flag tree conflicts yet
1001 echo 'D beta' > $testroot/stdout.expected
1002 (cd $testroot/wt && got status > $testroot/stdout)
1003 cmp -s $testroot/stdout.expected $testroot/stdout
1005 if [ "$ret" != "0" ]; then
1006 diff -u $testroot/stdout.expected $testroot/stdout
1007 test_done "$testroot" "$ret"
1011 # 'got diff' should show post-update contents of beta being deleted
1012 local head_rev=`git_show_head $testroot/repo`
1013 echo "diff $head_rev $testroot/wt" > $testroot/stdout.expected
1014 echo -n 'blob - ' >> $testroot/stdout.expected
1015 got tree -r $testroot/repo -i | grep 'beta$' | cut -d' ' -f 1 \
1016 >> $testroot/stdout.expected
1017 echo 'file + /dev/null' >> $testroot/stdout.expected
1018 echo '--- beta' >> $testroot/stdout.expected
1019 echo '+++ beta' >> $testroot/stdout.expected
1020 echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
1021 echo '-modified beta' >> $testroot/stdout.expected
1023 (cd $testroot/wt && got diff > $testroot/stdout)
1024 cmp -s $testroot/stdout.expected $testroot/stdout
1026 if [ "$ret" != "0" ]; then
1027 diff -u $testroot/stdout.expected $testroot/stdout
1029 test_done "$testroot" "$ret"
1032 function test_update_conflict_wt_rm_vs_repo_rm {
1033 local testroot=`test_init update_conflict_wt_rm_vs_repo_rm`
1035 got checkout $testroot/repo $testroot/wt > /dev/null
1037 if [ "$ret" != "0" ]; then
1038 test_done "$testroot" "$ret"
1042 (cd $testroot/repo && git rm -q beta)
1043 git_commit $testroot/repo -m "removing a file"
1045 (cd $testroot/wt && got rm beta > /dev/null)
1047 (cd $testroot/wt && got update > $testroot/stdout)
1049 echo "D beta" > $testroot/stdout.expected
1050 echo -n "Updated to commit " >> $testroot/stdout.expected
1051 git_show_head $testroot/repo >> $testroot/stdout.expected
1052 echo >> $testroot/stdout.expected
1053 cmp -s $testroot/stdout.expected $testroot/stdout
1055 if [ "$ret" != "0" ]; then
1056 diff -u $testroot/stdout.expected $testroot/stdout
1057 test_done "$testroot" "$ret"
1061 # beta is now gone... we don't flag tree conflicts yet
1062 echo "N beta" > $testroot/stdout.expected
1063 echo -n > $testroot/stderr.expected
1064 (cd $testroot/wt && got status beta > $testroot/stdout \
1065 2> $testroot/stderr)
1066 cmp -s $testroot/stdout.expected $testroot/stdout
1068 if [ "$ret" != "0" ]; then
1069 diff -u $testroot/stdout.expected $testroot/stdout
1070 test_done "$testroot" "$ret"
1073 cmp -s $testroot/stderr.expected $testroot/stderr
1075 if [ "$ret" != "0" ]; then
1076 diff -u $testroot/stderr.expected $testroot/stderr
1077 test_done "$testroot" "$ret"
1081 if [ -e $testroot/wt/beta ]; then
1082 echo "removed file beta still exists on disk" >&2
1083 test_done "$testroot" "1"
1087 test_done "$testroot" "0"
1090 function test_update_partial {
1091 local testroot=`test_init update_partial`
1093 got checkout $testroot/repo $testroot/wt > /dev/null
1095 if [ "$ret" != "0" ]; then
1096 test_done "$testroot" "$ret"
1100 echo "modified alpha" > $testroot/repo/alpha
1101 echo "modified beta" > $testroot/repo/beta
1102 echo "modified epsilon/zeta" > $testroot/repo/epsilon/zeta
1103 git_commit $testroot/repo -m "modified two files"
1105 echo "U alpha" > $testroot/stdout.expected
1106 echo "U beta" >> $testroot/stdout.expected
1107 echo -n "Updated to commit " >> $testroot/stdout.expected
1108 git_show_head $testroot/repo >> $testroot/stdout.expected
1109 echo >> $testroot/stdout.expected
1111 (cd $testroot/wt && got update alpha beta > $testroot/stdout)
1113 cmp -s $testroot/stdout.expected $testroot/stdout
1115 if [ "$ret" != "0" ]; then
1116 diff -u $testroot/stdout.expected $testroot/stdout
1117 test_done "$testroot" "$ret"
1121 echo "modified alpha" > $testroot/content.expected
1122 echo "modified beta" >> $testroot/content.expected
1124 cat $testroot/wt/alpha $testroot/wt/beta > $testroot/content
1125 cmp -s $testroot/content.expected $testroot/content
1127 if [ "$ret" != "0" ]; then
1128 diff -u $testroot/content.expected $testroot/content
1129 test_done "$testroot" "$ret"
1133 echo "U epsilon/zeta" > $testroot/stdout.expected
1134 echo -n "Updated to commit " >> $testroot/stdout.expected
1135 git_show_head $testroot/repo >> $testroot/stdout.expected
1136 echo >> $testroot/stdout.expected
1138 (cd $testroot/wt && got update epsilon > $testroot/stdout)
1140 cmp -s $testroot/stdout.expected $testroot/stdout
1142 if [ "$ret" != "0" ]; then
1143 diff -u $testroot/stdout.expected $testroot/stdout
1144 test_done "$testroot" "$ret"
1148 echo "modified epsilon/zeta" > $testroot/content.expected
1149 cat $testroot/wt/epsilon/zeta > $testroot/content
1151 cmp -s $testroot/content.expected $testroot/content
1153 if [ "$ret" != "0" ]; then
1154 diff -u $testroot/content.expected $testroot/content
1155 test_done "$testroot" "$ret"
1159 test_done "$testroot" "$ret"
1162 function test_update_partial_add {
1163 local testroot=`test_init update_partial_add`
1165 got checkout $testroot/repo $testroot/wt > /dev/null
1167 if [ "$ret" != "0" ]; then
1168 test_done "$testroot" "$ret"
1172 echo "new" > $testroot/repo/new
1173 echo "epsilon/new2" > $testroot/repo/epsilon/new2
1174 (cd $testroot/repo && git add .)
1175 git_commit $testroot/repo -m "added two files"
1177 echo "A new" > $testroot/stdout.expected
1178 echo "A epsilon/new2" >> $testroot/stdout.expected
1179 echo -n "Updated to commit " >> $testroot/stdout.expected
1180 git_show_head $testroot/repo >> $testroot/stdout.expected
1181 echo >> $testroot/stdout.expected
1183 (cd $testroot/wt && got update new epsilon/new2 > $testroot/stdout)
1185 cmp -s $testroot/stdout.expected $testroot/stdout
1187 if [ "$ret" != "0" ]; then
1188 diff -u $testroot/stdout.expected $testroot/stdout
1189 test_done "$testroot" "$ret"
1193 echo "new" > $testroot/content.expected
1194 echo "epsilon/new2" >> $testroot/content.expected
1196 cat $testroot/wt/new $testroot/wt/epsilon/new2 > $testroot/content
1198 cmp -s $testroot/content.expected $testroot/content
1200 if [ "$ret" != "0" ]; then
1201 diff -u $testroot/content.expected $testroot/content
1203 test_done "$testroot" "$ret"
1206 function test_update_partial_rm {
1207 local testroot=`test_init update_partial_rm`
1209 got checkout $testroot/repo $testroot/wt > /dev/null
1211 if [ "$ret" != "0" ]; then
1212 test_done "$testroot" "$ret"
1216 (cd $testroot/repo && git rm -q alpha epsilon/zeta)
1217 git_commit $testroot/repo -m "removed two files"
1219 echo "got: /alpha: no such entry found in tree" \
1220 > $testroot/stderr.expected
1222 (cd $testroot/wt && got update alpha epsilon/zeta 2> $testroot/stderr)
1224 if [ "$ret" == "0" ]; then
1225 echo "update succeeded unexpectedly" >&2
1226 test_done "$testroot" "1"
1230 cmp -s $testroot/stderr.expected $testroot/stderr
1232 if [ "$ret" != "0" ]; then
1233 diff -u $testroot/stderr.expected $testroot/stderr
1234 test_done "$testroot" "$ret"
1237 test_done "$testroot" "$ret"
1240 function test_update_partial_dir {
1241 local testroot=`test_init update_partial_dir`
1243 got checkout $testroot/repo $testroot/wt > /dev/null
1245 if [ "$ret" != "0" ]; then
1246 test_done "$testroot" "$ret"
1250 echo "modified alpha" > $testroot/repo/alpha
1251 echo "modified beta" > $testroot/repo/beta
1252 echo "modified epsilon/zeta" > $testroot/repo/epsilon/zeta
1253 git_commit $testroot/repo -m "modified two files"
1255 echo "U epsilon/zeta" > $testroot/stdout.expected
1256 echo -n "Updated to commit " >> $testroot/stdout.expected
1257 git_show_head $testroot/repo >> $testroot/stdout.expected
1258 echo >> $testroot/stdout.expected
1260 (cd $testroot/wt && got update epsilon > $testroot/stdout)
1262 cmp -s $testroot/stdout.expected $testroot/stdout
1264 if [ "$ret" != "0" ]; then
1265 diff -u $testroot/stdout.expected $testroot/stdout
1266 test_done "$testroot" "$ret"
1270 echo "modified epsilon/zeta" > $testroot/content.expected
1271 cat $testroot/wt/epsilon/zeta > $testroot/content
1273 cmp -s $testroot/content.expected $testroot/content
1275 if [ "$ret" != "0" ]; then
1276 diff -u $testroot/content.expected $testroot/content
1277 test_done "$testroot" "$ret"
1280 test_done "$testroot" "$ret"
1284 function test_update_moved_branch_ref {
1285 local testroot=`test_init update_moved_branch_ref`
1287 git clone -q --mirror $testroot/repo $testroot/repo2
1289 echo "modified alpha with git" > $testroot/repo/alpha
1290 git_commit $testroot/repo -m "modified alpha with git"
1292 got checkout $testroot/repo2 $testroot/wt > /dev/null
1294 if [ "$ret" != "0" ]; then
1295 test_done "$testroot" "$ret"
1299 echo "modified alpha with got" > $testroot/wt/alpha
1300 (cd $testroot/wt && got commit -m "modified alpha with got" > /dev/null)
1302 # + xxxxxxx...yyyyyyy master -> master (forced update)
1303 (cd $testroot/repo2 && git fetch -q --all)
1305 echo -n > $testroot/stdout.expected
1306 echo -n "got: work tree's head reference now points to a different " \
1307 > $testroot/stderr.expected
1308 echo "branch; new head reference and/or update -b required" \
1309 >> $testroot/stderr.expected
1311 (cd $testroot/wt && got update > $testroot/stdout 2> $testroot/stderr)
1313 cmp -s $testroot/stdout.expected $testroot/stdout
1315 if [ "$ret" != "0" ]; then
1316 diff -u $testroot/stdout.expected $testroot/stdout
1317 test_done "$testroot" "$ret"
1321 cmp -s $testroot/stderr.expected $testroot/stderr
1323 if [ "$ret" != "0" ]; then
1324 diff -u $testroot/stderr.expected $testroot/stderr
1326 test_done "$testroot" "$ret"
1329 function test_update_to_another_branch {
1330 local testroot=`test_init update_to_another_branch`
1331 local base_commit=`git_show_head $testroot/repo`
1333 got checkout $testroot/repo $testroot/wt > /dev/null
1335 if [ "$ret" != "0" ]; then
1336 test_done "$testroot" "$ret"
1340 echo 'refs/heads/master'> $testroot/head-ref.expected
1341 cmp -s $testroot/head-ref.expected $testroot/wt/.got/head-ref
1343 if [ "$ret" != "0" ]; then
1344 diff -u $testroot/head-ref.expected $testroot/wt/.got/head-ref
1345 test_done "$testroot" "$ret"
1349 (cd $testroot/repo && git checkout -q -b newbranch)
1350 echo "modified alpha on new branch" > $testroot/repo/alpha
1351 git_commit $testroot/repo -m "modified alpha on new branch"
1353 echo "modified alpha in work tree" > $testroot/wt/alpha
1355 echo "Switching work tree from refs/heads/master to refs/heads/newbranch" > $testroot/stdout.expected
1356 echo "C alpha" >> $testroot/stdout.expected
1357 echo -n "Updated to commit " >> $testroot/stdout.expected
1358 git_show_head $testroot/repo >> $testroot/stdout.expected
1359 echo >> $testroot/stdout.expected
1360 echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
1362 (cd $testroot/wt && got update -b newbranch > $testroot/stdout)
1364 cmp -s $testroot/stdout.expected $testroot/stdout
1366 if [ "$ret" != "0" ]; then
1367 diff -u $testroot/stdout.expected $testroot/stdout
1368 test_done "$testroot" "$ret"
1372 echo -n "<<<<<<< merged change: commit " > $testroot/content.expected
1373 git_show_head $testroot/repo >> $testroot/content.expected
1374 echo >> $testroot/content.expected
1375 echo "modified alpha on new branch" >> $testroot/content.expected
1376 echo "||||||| 3-way merge base: commit $base_commit" \
1377 >> $testroot/content.expected
1378 echo "alpha" >> $testroot/content.expected
1379 echo "=======" >> $testroot/content.expected
1380 echo "modified alpha in work tree" >> $testroot/content.expected
1381 echo '>>>>>>>' >> $testroot/content.expected
1383 cat $testroot/wt/alpha > $testroot/content
1385 cmp -s $testroot/content.expected $testroot/content
1387 if [ "$ret" != "0" ]; then
1388 diff -u $testroot/content.expected $testroot/content
1389 test_done "$testroot" "$ret"
1393 echo 'refs/heads/newbranch'> $testroot/head-ref.expected
1394 cmp -s $testroot/head-ref.expected $testroot/wt/.got/head-ref
1396 if [ "$ret" != "0" ]; then
1397 diff -u $testroot/head-ref.expected $testroot/wt/.got/head-ref
1398 test_done "$testroot" "$ret"
1402 test_done "$testroot" "$ret"
1405 function test_update_to_commit_on_wrong_branch {
1406 local testroot=`test_init update_to_commit_on_wrong_branch`
1408 got checkout $testroot/repo $testroot/wt > /dev/null
1410 if [ "$ret" != "0" ]; then
1411 test_done "$testroot" "$ret"
1415 (cd $testroot/repo && git checkout -q -b newbranch)
1416 echo "modified alpha on new branch" > $testroot/repo/alpha
1417 git_commit $testroot/repo -m "modified alpha on new branch"
1419 echo -n "" > $testroot/stdout.expected
1420 echo "got: target commit is on a different branch" \
1421 > $testroot/stderr.expected
1423 local head_rev=`git_show_head $testroot/repo`
1424 (cd $testroot/wt && got update -c $head_rev > $testroot/stdout \
1425 2> $testroot/stderr)
1427 cmp -s $testroot/stdout.expected $testroot/stdout
1429 if [ "$ret" != "0" ]; then
1430 diff -u $testroot/stdout.expected $testroot/stdout
1431 test_done "$testroot" "$ret"
1435 cmp -s $testroot/stderr.expected $testroot/stderr
1437 if [ "$ret" != "0" ]; then
1438 diff -u $testroot/stderr.expected $testroot/stderr
1439 test_done "$testroot" "$ret"
1443 test_done "$testroot" "$ret"
1446 function test_update_bumps_base_commit_id {
1447 local testroot=`test_init update_bumps_base_commit_id`
1449 echo "psi" > $testroot/repo/epsilon/psi
1450 (cd $testroot/repo && git add .)
1451 git_commit $testroot/repo -m "adding another file"
1453 got checkout $testroot/repo $testroot/wt > /dev/null
1455 if [ "$ret" != "0" ]; then
1456 test_done "$testroot" "$ret"
1460 echo "modified psi" > $testroot/wt/epsilon/psi
1461 (cd $testroot/wt && got commit -m "changed psi" > $testroot/stdout)
1463 local head_rev=`git_show_head $testroot/repo`
1464 echo "M epsilon/psi" > $testroot/stdout.expected
1465 echo "Created commit $head_rev" >> $testroot/stdout.expected
1466 cmp -s $testroot/stdout.expected $testroot/stdout
1468 if [ "$ret" != "0" ]; then
1469 diff -u $testroot/stdout.expected $testroot/stdout
1470 test_done "$testroot" "$ret"
1474 echo "changed zeta with git" > $testroot/repo/epsilon/zeta
1475 (cd $testroot/repo && git add .)
1476 git_commit $testroot/repo -m "changing zeta with git"
1478 echo "modified zeta" > $testroot/wt/epsilon/zeta
1479 (cd $testroot/wt && got commit -m "changed zeta" > $testroot/stdout \
1480 2> $testroot/stderr)
1482 echo -n "" > $testroot/stdout.expected
1483 echo "got: work tree must be updated before these changes can be committed" > $testroot/stderr.expected
1484 cmp -s $testroot/stderr.expected $testroot/stderr
1486 if [ "$ret" != "0" ]; then
1487 diff -u $testroot/stderr.expected $testroot/stderr
1488 test_done "$testroot" "$ret"
1492 (cd $testroot/wt && got update > $testroot/stdout)
1494 echo "U epsilon/psi" > $testroot/stdout.expected
1495 echo "C epsilon/zeta" >> $testroot/stdout.expected
1496 echo -n "Updated to commit " >> $testroot/stdout.expected
1497 git_show_head $testroot/repo >> $testroot/stdout.expected
1498 echo >> $testroot/stdout.expected
1499 echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
1501 cmp -s $testroot/stdout.expected $testroot/stdout
1503 if [ "$ret" != "0" ]; then
1504 diff -u $testroot/stdout.expected $testroot/stdout
1505 test_done "$testroot" "$ret"
1510 echo "modified zeta with got and git" > $testroot/wt/epsilon/zeta
1512 (cd $testroot/wt && got commit -m "changed zeta" > $testroot/stdout)
1514 local head_rev=`git_show_head $testroot/repo`
1515 echo "M epsilon/zeta" > $testroot/stdout.expected
1516 echo "Created commit $head_rev" >> $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"
1525 test_done "$testroot" "$ret"
1528 function test_update_tag {
1529 local testroot=`test_init update_tag`
1532 got checkout $testroot/repo $testroot/wt > /dev/null
1534 if [ "$ret" != "0" ]; then
1535 test_done "$testroot" "$ret"
1539 echo "modified alpha" > $testroot/repo/alpha
1540 git_commit $testroot/repo -m "modified alpha"
1541 (cd $testroot/repo && git tag -m "test" -a $tag)
1543 echo "U alpha" > $testroot/stdout.expected
1544 echo -n "Updated to commit " >> $testroot/stdout.expected
1545 git_show_head $testroot/repo >> $testroot/stdout.expected
1546 echo >> $testroot/stdout.expected
1548 (cd $testroot/wt && got update -c $tag > $testroot/stdout)
1550 cmp -s $testroot/stdout.expected $testroot/stdout
1552 if [ "$ret" != "0" ]; then
1553 diff -u $testroot/stdout.expected $testroot/stdout
1554 test_done "$testroot" "$ret"
1558 echo "modified alpha" > $testroot/content.expected
1559 cat $testroot/wt/alpha > $testroot/content
1561 cmp -s $testroot/content.expected $testroot/content
1563 if [ "$ret" != "0" ]; then
1564 diff -u $testroot/content.expected $testroot/content
1566 test_done "$testroot" "$ret"
1569 function test_update_toggles_xbit {
1570 local testroot=`test_init update_toggles_xbit 1`
1572 touch $testroot/repo/xfile
1573 chmod +x $testroot/repo/xfile
1574 (cd $testroot/repo && git add .)
1575 git_commit $testroot/repo -m "adding executable file"
1576 local commit_id1=`git_show_head $testroot/repo`
1578 got checkout $testroot/repo $testroot/wt > $testroot/stdout
1580 if [ "$ret" != "0" ]; then
1581 test_done "$testroot" "$ret"
1585 ls -l $testroot/wt/xfile | grep -q '^-rwx'
1587 if [ "$ret" != "0" ]; then
1588 echo "file is not executable" >&2
1589 ls -l $testroot/wt/xfile >&2
1590 test_done "$testroot" "$ret"
1594 chmod -x $testroot/wt/xfile
1595 (cd $testroot/wt && got commit -m "clear x bit" >/dev/null)
1596 local commit_id2=`git_show_head $testroot/repo`
1598 echo "U xfile" > $testroot/stdout.expected
1599 echo -n "Updated to commit " >> $testroot/stdout.expected
1600 git_show_head $testroot/repo >> $testroot/stdout.expected
1601 echo >> $testroot/stdout.expected
1603 (cd $testroot/wt && got update -c $commit_id1 > $testroot/stdout)
1605 if [ "$ret" != "0" ]; then
1606 test_done "$testroot" "$ret"
1610 echo "U xfile" > $testroot/stdout.expected
1611 echo "Updated to commit $commit_id1" >> $testroot/stdout.expected
1612 cmp -s $testroot/stdout.expected $testroot/stdout
1614 if [ "$ret" != "0" ]; then
1615 diff -u $testroot/stdout.expected $testroot/stdout
1616 test_done "$testroot" "$ret"
1621 ls -l $testroot/wt/xfile | grep -q '^-rwx'
1623 if [ "$ret" != "0" ]; then
1624 echo "file is not executable" >&2
1625 ls -l $testroot/wt/xfile >&2
1626 test_done "$testroot" "$ret"
1630 (cd $testroot/wt && got update > $testroot/stdout)
1632 if [ "$ret" != "0" ]; then
1633 test_done "$testroot" "$ret"
1637 echo "U xfile" > $testroot/stdout.expected
1638 echo "Updated to commit $commit_id2" >> $testroot/stdout.expected
1639 cmp -s $testroot/stdout.expected $testroot/stdout
1641 if [ "$ret" != "0" ]; then
1642 diff -u $testroot/stdout.expected $testroot/stdout
1643 test_done "$testroot" "$ret"
1647 ls -l $testroot/wt/xfile | grep -q '^-rw-'
1649 if [ "$ret" != "0" ]; then
1650 echo "file is unexpectedly executable" >&2
1651 ls -l $testroot/wt/xfile >&2
1653 test_done "$testroot" "$ret"
1656 function test_update_preserves_conflicted_file {
1657 local testroot=`test_init update_preserves_conflicted_file`
1658 local commit_id0=`git_show_head $testroot/repo`
1660 echo "modified alpha" > $testroot/repo/alpha
1661 git_commit $testroot/repo -m "modified alpha"
1662 local commit_id1=`git_show_head $testroot/repo`
1664 got checkout -c $commit_id0 $testroot/repo $testroot/wt > /dev/null
1666 if [ "$ret" != "0" ]; then
1667 test_done "$testroot" "$ret"
1671 # fake a merge conflict
1672 echo '<<<<<<<' > $testroot/wt/alpha
1673 echo 'alpha' >> $testroot/wt/alpha
1674 echo '=======' >> $testroot/wt/alpha
1675 echo 'alpha, too' >> $testroot/wt/alpha
1676 echo '>>>>>>>' >> $testroot/wt/alpha
1677 cp $testroot/wt/alpha $testroot/content.expected
1679 echo "C alpha" > $testroot/stdout.expected
1680 (cd $testroot/wt && got status > $testroot/stdout)
1681 cmp -s $testroot/stdout.expected $testroot/stdout
1683 if [ "$ret" != "0" ]; then
1684 diff -u $testroot/stdout.expected $testroot/stdout
1685 test_done "$testroot" "$ret"
1689 echo "# alpha" > $testroot/stdout.expected
1690 echo -n "Updated to commit " >> $testroot/stdout.expected
1691 git_show_head $testroot/repo >> $testroot/stdout.expected
1692 echo >> $testroot/stdout.expected
1693 echo "Files not updated because of existing merge conflicts: 1" \
1694 >> $testroot/stdout.expected
1695 (cd $testroot/wt && got update > $testroot/stdout)
1697 cmp -s $testroot/stdout.expected $testroot/stdout
1699 if [ "$ret" != "0" ]; then
1700 diff -u $testroot/stdout.expected $testroot/stdout
1701 test_done "$testroot" "$ret"
1705 cmp -s $testroot/content.expected $testroot/wt/alpha
1707 if [ "$ret" != "0" ]; then
1708 diff -u $testroot/content.expected $testroot/wt/alpha
1710 test_done "$testroot" "$ret"
1713 function test_update_modified_submodules {
1714 local testroot=`test_init update_modified_submodules`
1716 make_single_file_repo $testroot/repo2 foo
1718 (cd $testroot/repo && git submodule -q add ../repo2)
1719 (cd $testroot/repo && git commit -q -m 'adding submodule')
1721 got checkout $testroot/repo $testroot/wt > /dev/null
1723 echo "modified foo" > $testroot/repo2/foo
1724 (cd $testroot/repo2 && git commit -q -a -m 'modified a submodule')
1726 # Update the repo/repo2 submodule link
1727 (cd $testroot/repo && git -C repo2 pull -q)
1728 (cd $testroot/repo && git add repo2)
1729 git_commit $testroot/repo -m "modified submodule link"
1731 # This update only records the new base commit. Otherwise it is a
1732 # no-op change because Got's file index does not track submodules.
1733 echo -n "Updated to commit " > $testroot/stdout.expected
1734 git_show_head $testroot/repo >> $testroot/stdout.expected
1735 echo >> $testroot/stdout.expected
1737 (cd $testroot/wt && got update > $testroot/stdout)
1739 cmp -s $testroot/stdout.expected $testroot/stdout
1741 if [ "$ret" != "0" ]; then
1742 diff -u $testroot/stdout.expected $testroot/stdout
1744 test_done "$testroot" "$ret"
1747 function test_update_adds_submodule {
1748 local testroot=`test_init update_adds_submodule`
1750 got checkout $testroot/repo $testroot/wt > /dev/null
1752 make_single_file_repo $testroot/repo2 foo
1754 echo "modified foo" > $testroot/repo2/foo
1755 (cd $testroot/repo2 && git commit -q -a -m 'modified a submodule')
1757 (cd $testroot/repo && git submodule -q add ../repo2)
1758 (cd $testroot/repo && git commit -q -m 'adding submodule')
1760 echo "A .gitmodules" > $testroot/stdout.expected
1761 echo -n "Updated to commit " >> $testroot/stdout.expected
1762 git_show_head $testroot/repo >> $testroot/stdout.expected
1763 echo >> $testroot/stdout.expected
1765 (cd $testroot/wt && got update > $testroot/stdout)
1767 cmp -s $testroot/stdout.expected $testroot/stdout
1769 if [ "$ret" != "0" ]; then
1770 diff -u $testroot/stdout.expected $testroot/stdout
1772 test_done "$testroot" "$ret"
1775 function test_update_conflict_wt_file_vs_repo_submodule {
1776 local testroot=`test_init update_conflict_wt_file_vs_repo_submodule`
1778 got checkout $testroot/repo $testroot/wt > /dev/null
1780 make_single_file_repo $testroot/repo2 foo
1782 # Add a file which will clash with the submodule
1783 echo "This is a file called repo2" > $testroot/wt/repo2
1784 (cd $testroot/wt && got add repo2 > /dev/null)
1785 (cd $testroot/wt && got commit -m 'add file repo2' > /dev/null)
1787 if [ "$ret" != "0" ]; then
1788 echo "commit failed unexpectedly" >&2
1789 test_done "$testroot" "1"
1793 (cd $testroot/repo && git submodule -q add ../repo2)
1794 (cd $testroot/repo && git commit -q -m 'adding submodule')
1796 # Modify the clashing file such that any modifications brought
1797 # in by 'got update' would require a merge.
1798 echo "This file was changed" > $testroot/wt/repo2
1800 # No conflict occurs because 'got update' ignores the submodule
1801 # and leaves the clashing file as it was.
1802 echo "A .gitmodules" > $testroot/stdout.expected
1803 echo -n "Updated to commit " >> $testroot/stdout.expected
1804 git_show_head $testroot/repo >> $testroot/stdout.expected
1805 echo >> $testroot/stdout.expected
1807 (cd $testroot/wt && got update > $testroot/stdout)
1809 cmp -s $testroot/stdout.expected $testroot/stdout
1811 if [ "$ret" != "0" ]; then
1812 diff -u $testroot/stdout.expected $testroot/stdout
1813 test_done "$testroot" "$ret"
1817 (cd $testroot/wt && got status > $testroot/stdout)
1819 echo "M repo2" > $testroot/stdout.expected
1820 cmp -s $testroot/stdout.expected $testroot/stdout
1822 if [ "$ret" != "0" ]; then
1823 diff -u $testroot/stdout.expected $testroot/stdout
1825 test_done "$testroot" "$ret"
1828 function test_update_adds_symlink {
1829 local testroot=`test_init update_adds_symlink`
1831 got checkout $testroot/repo $testroot/wt > /dev/null
1833 if [ "$ret" != "0" ]; then
1834 echo "checkout failed unexpectedly" >&2
1835 test_done "$testroot" "$ret"
1839 (cd $testroot/repo && ln -s alpha alpha.link)
1840 (cd $testroot/repo && ln -s epsilon epsilon.link)
1841 (cd $testroot/repo && ln -s /etc/passwd passwd.link)
1842 (cd $testroot/repo && ln -s ../beta epsilon/beta.link)
1843 (cd $testroot/repo && ln -s nonexistent nonexistent.link)
1844 (cd $testroot/repo && git add .)
1845 git_commit $testroot/repo -m "add symlinks"
1847 echo "A alpha.link" > $testroot/stdout.expected
1848 echo "A epsilon/beta.link" >> $testroot/stdout.expected
1849 echo "A epsilon.link" >> $testroot/stdout.expected
1850 echo "A nonexistent.link" >> $testroot/stdout.expected
1851 echo "A passwd.link" >> $testroot/stdout.expected
1852 echo -n "Updated to commit " >> $testroot/stdout.expected
1853 git_show_head $testroot/repo >> $testroot/stdout.expected
1854 echo >> $testroot/stdout.expected
1856 (cd $testroot/wt && got update > $testroot/stdout)
1858 cmp -s $testroot/stdout.expected $testroot/stdout
1860 if [ "$ret" != "0" ]; then
1861 diff -u $testroot/stdout.expected $testroot/stdout
1862 test_done "$testroot" "$ret"
1866 if ! [ -h $testroot/wt/alpha.link ]; then
1867 echo "alpha.link is not a symlink"
1868 test_done "$testroot" "1"
1872 readlink $testroot/wt/alpha.link > $testroot/stdout
1873 echo "alpha" > $testroot/stdout.expected
1874 cmp -s $testroot/stdout.expected $testroot/stdout
1876 if [ "$ret" != "0" ]; then
1877 diff -u $testroot/stdout.expected $testroot/stdout
1878 test_done "$testroot" "$ret"
1882 if ! [ -h $testroot/wt/epsilon.link ]; then
1883 echo "epsilon.link is not a symlink"
1884 test_done "$testroot" "1"
1888 readlink $testroot/wt/epsilon.link > $testroot/stdout
1889 echo "epsilon" > $testroot/stdout.expected
1890 cmp -s $testroot/stdout.expected $testroot/stdout
1892 if [ "$ret" != "0" ]; then
1893 diff -u $testroot/stdout.expected $testroot/stdout
1894 test_done "$testroot" "$ret"
1898 if [ -h $testroot/wt/passwd.link ]; then
1899 echo -n "passwd.link symlink points outside of work tree: " >&2
1900 readlink $testroot/wt/passwd.link >&2
1901 test_done "$testroot" "1"
1905 echo -n "/etc/passwd" > $testroot/content.expected
1906 cp $testroot/wt/passwd.link $testroot/content
1908 cmp -s $testroot/content.expected $testroot/content
1910 if [ "$ret" != "0" ]; then
1911 diff -u $testroot/content.expected $testroot/content
1912 test_done "$testroot" "$ret"
1916 readlink $testroot/wt/epsilon/beta.link > $testroot/stdout
1917 echo "../beta" > $testroot/stdout.expected
1918 cmp -s $testroot/stdout.expected $testroot/stdout
1920 if [ "$ret" != "0" ]; then
1921 diff -u $testroot/stdout.expected $testroot/stdout
1922 test_done "$testroot" "$ret"
1926 readlink $testroot/wt/nonexistent.link > $testroot/stdout
1927 echo "nonexistent" > $testroot/stdout.expected
1928 cmp -s $testroot/stdout.expected $testroot/stdout
1930 if [ "$ret" != "0" ]; then
1931 diff -u $testroot/stdout.expected $testroot/stdout
1933 test_done "$testroot" "$ret"
1936 function test_update_deletes_symlink {
1937 local testroot=`test_init update_deletes_symlink`
1939 (cd $testroot/repo && ln -s alpha alpha.link)
1940 (cd $testroot/repo && git add .)
1941 git_commit $testroot/repo -m "add symlink"
1943 got checkout $testroot/repo $testroot/wt > /dev/null
1945 if [ "$ret" != "0" ]; then
1946 echo "checkout failed unexpectedly" >&2
1947 test_done "$testroot" "$ret"
1951 (cd $testroot/repo && git rm -q alpha.link)
1952 git_commit $testroot/repo -m "delete symlink"
1954 echo "D alpha.link" > $testroot/stdout.expected
1955 echo -n "Updated to commit " >> $testroot/stdout.expected
1956 git_show_head $testroot/repo >> $testroot/stdout.expected
1957 echo >> $testroot/stdout.expected
1959 (cd $testroot/wt && got update > $testroot/stdout)
1961 cmp -s $testroot/stdout.expected $testroot/stdout
1963 if [ "$ret" != "0" ]; then
1964 diff -u $testroot/stdout.expected $testroot/stdout
1965 test_done "$testroot" "$ret"
1969 if [ -e $testroot/wt/alpha.link ]; then
1970 echo "alpha.link still exists on disk"
1971 test_done "$testroot" "1"
1975 test_done "$testroot" "0"
1978 function test_update_symlink_conflicts {
1979 local testroot=`test_init update_symlink_conflicts`
1981 (cd $testroot/repo && ln -s alpha alpha.link)
1982 (cd $testroot/repo && ln -s epsilon epsilon.link)
1983 (cd $testroot/repo && ln -s /etc/passwd passwd.link)
1984 (cd $testroot/repo && ln -s ../beta epsilon/beta.link)
1985 (cd $testroot/repo && ln -s nonexistent nonexistent.link)
1986 (cd $testroot/repo && ln -sf epsilon/zeta zeta.link)
1987 (cd $testroot/repo && git add .)
1988 git_commit $testroot/repo -m "add symlinks"
1989 local commit_id1=`git_show_head $testroot/repo`
1991 got checkout $testroot/repo $testroot/wt > /dev/null
1993 if [ "$ret" != "0" ]; then
1994 echo "checkout failed unexpectedly" >&2
1995 test_done "$testroot" "$ret"
1999 (cd $testroot/repo && ln -sf beta alpha.link)
2000 (cd $testroot/repo && ln -sfh gamma epsilon.link)
2001 (cd $testroot/repo && ln -sf ../gamma/delta epsilon/beta.link)
2002 echo 'this is regular file foo' > $testroot/repo/dotgotfoo.link
2003 (cd $testroot/repo && ln -sf .got/bar dotgotbar.link)
2004 (cd $testroot/repo && git rm -q nonexistent.link)
2005 (cd $testroot/repo && ln -sf gamma/delta zeta.link)
2006 (cd $testroot/repo && ln -sf alpha new.link)
2007 (cd $testroot/repo && git add .)
2008 git_commit $testroot/repo -m "change symlinks"
2009 local commit_id2=`git_show_head $testroot/repo`
2011 # modified symlink to file A vs modified symlink to file B
2012 (cd $testroot/wt && ln -sf gamma/delta alpha.link)
2013 # modified symlink to dir A vs modified symlink to file B
2014 (cd $testroot/wt && ln -sfh beta epsilon.link)
2015 # modeified symlink to file A vs modified symlink to dir B
2016 (cd $testroot/wt && ln -sfh ../gamma epsilon/beta.link)
2017 # added regular file A vs added bad symlink to file A
2018 (cd $testroot/wt && ln -sf .got/bar dotgotfoo.link)
2019 (cd $testroot/wt && got add dotgotfoo.link > /dev/null)
2020 # added bad symlink to file A vs added regular file A
2021 echo 'this is regular file bar' > $testroot/wt/dotgotbar.link
2022 (cd $testroot/wt && got add dotgotbar.link > /dev/null)
2023 # removed symlink to non-existent file A vs modified symlink
2024 # to nonexistent file B
2025 (cd $testroot/wt && ln -sf nonexistent2 nonexistent.link)
2026 # modified symlink to file A vs removed symlink to file A
2027 (cd $testroot/wt && got rm zeta.link > /dev/null)
2028 # added symlink to file A vs added symlink to file B
2029 (cd $testroot/wt && ln -sf beta new.link)
2030 (cd $testroot/wt && got add new.link > /dev/null)
2032 (cd $testroot/wt && got update > $testroot/stdout)
2034 echo "C alpha.link" >> $testroot/stdout.expected
2035 echo "C dotgotbar.link" >> $testroot/stdout.expected
2036 echo "C dotgotfoo.link" >> $testroot/stdout.expected
2037 echo "C epsilon/beta.link" >> $testroot/stdout.expected
2038 echo "C epsilon.link" >> $testroot/stdout.expected
2039 echo "C new.link" >> $testroot/stdout.expected
2040 echo "C nonexistent.link" >> $testroot/stdout.expected
2041 echo "G zeta.link" >> $testroot/stdout.expected
2042 echo -n "Updated to commit " >> $testroot/stdout.expected
2043 git_show_head $testroot/repo >> $testroot/stdout.expected
2044 echo >> $testroot/stdout.expected
2045 echo "Files with new merge conflicts: 7" >> $testroot/stdout.expected
2047 cmp -s $testroot/stdout.expected $testroot/stdout
2049 if [ "$ret" != "0" ]; then
2050 diff -u $testroot/stdout.expected $testroot/stdout
2051 test_done "$testroot" "$ret"
2055 if [ -h $testroot/wt/alpha.link ]; then
2056 echo "alpha.link is a symlink"
2057 test_done "$testroot" "1"
2061 echo "<<<<<<< merged change: commit $commit_id2" \
2062 > $testroot/content.expected
2063 echo "beta" >> $testroot/content.expected
2064 echo "3-way merge base: commit $commit_id1" \
2065 >> $testroot/content.expected
2066 echo "alpha" >> $testroot/content.expected
2067 echo "=======" >> $testroot/content.expected
2068 echo "gamma/delta" >> $testroot/content.expected
2069 echo '>>>>>>>' >> $testroot/content.expected
2070 echo -n "" >> $testroot/content.expected
2072 cp $testroot/wt/alpha.link $testroot/content
2073 cmp -s $testroot/content.expected $testroot/content
2075 if [ "$ret" != "0" ]; then
2076 diff -u $testroot/content.expected $testroot/content
2077 test_done "$testroot" "$ret"
2081 if [ -h $testroot/wt/epsilon.link ]; then
2082 echo "epsilon.link is a symlink"
2083 test_done "$testroot" "1"
2087 echo "<<<<<<< merged change: commit $commit_id2" \
2088 > $testroot/content.expected
2089 echo "gamma" >> $testroot/content.expected
2090 echo "3-way merge base: commit $commit_id1" \
2091 >> $testroot/content.expected
2092 echo "epsilon" >> $testroot/content.expected
2093 echo "=======" >> $testroot/content.expected
2094 echo "beta" >> $testroot/content.expected
2095 echo '>>>>>>>' >> $testroot/content.expected
2096 echo -n "" >> $testroot/content.expected
2098 cp $testroot/wt/epsilon.link $testroot/content
2099 cmp -s $testroot/content.expected $testroot/content
2101 if [ "$ret" != "0" ]; then
2102 diff -u $testroot/content.expected $testroot/content
2103 test_done "$testroot" "$ret"
2107 if [ -h $testroot/wt/passwd.link ]; then
2108 echo -n "passwd.link symlink points outside of work tree: " >&2
2109 readlink $testroot/wt/passwd.link >&2
2110 test_done "$testroot" "1"
2114 echo -n "/etc/passwd" > $testroot/content.expected
2115 cp $testroot/wt/passwd.link $testroot/content
2117 cmp -s $testroot/content.expected $testroot/content
2119 if [ "$ret" != "0" ]; then
2120 diff -u $testroot/content.expected $testroot/content
2121 test_done "$testroot" "$ret"
2125 if [ -h $testroot/wt/epsilon/beta.link ]; then
2126 echo "epsilon/beta.link is a symlink"
2127 test_done "$testroot" "1"
2131 echo "<<<<<<< merged change: commit $commit_id2" \
2132 > $testroot/content.expected
2133 echo "../gamma/delta" >> $testroot/content.expected
2134 echo "3-way merge base: commit $commit_id1" \
2135 >> $testroot/content.expected
2136 echo "../beta" >> $testroot/content.expected
2137 echo "=======" >> $testroot/content.expected
2138 echo "../gamma" >> $testroot/content.expected
2139 echo '>>>>>>>' >> $testroot/content.expected
2140 echo -n "" >> $testroot/content.expected
2142 cp $testroot/wt/epsilon/beta.link $testroot/content
2143 cmp -s $testroot/content.expected $testroot/content
2145 if [ "$ret" != "0" ]; then
2146 diff -u $testroot/content.expected $testroot/content
2147 test_done "$testroot" "$ret"
2151 if [ -h $testroot/wt/nonexistent.link ]; then
2152 echo -n "nonexistent.link still exists on disk: " >&2
2153 readlink $testroot/wt/nonexistent.link >&2
2154 test_done "$testroot" "1"
2158 echo "<<<<<<< merged change: commit $commit_id2" \
2159 > $testroot/content.expected
2160 echo "(symlink was deleted)" >> $testroot/content.expected
2161 echo "=======" >> $testroot/content.expected
2162 echo "nonexistent2" >> $testroot/content.expected
2163 echo '>>>>>>>' >> $testroot/content.expected
2164 echo -n "" >> $testroot/content.expected
2166 cp $testroot/wt/nonexistent.link $testroot/content
2167 cmp -s $testroot/content.expected $testroot/content
2169 if [ "$ret" != "0" ]; then
2170 diff -u $testroot/content.expected $testroot/content
2171 test_done "$testroot" "$ret"
2175 if [ -h $testroot/wt/dotgotfoo.link ]; then
2176 echo "dotgotfoo.link is a symlink"
2177 test_done "$testroot" "1"
2181 echo "<<<<<<< merged change: commit $commit_id2" \
2182 > $testroot/content.expected
2183 echo "this is regular file foo" >> $testroot/content.expected
2184 echo "=======" >> $testroot/content.expected
2185 echo -n ".got/bar" >> $testroot/content.expected
2186 echo '>>>>>>>' >> $testroot/content.expected
2187 echo -n "" >> $testroot/content.expected
2189 cp $testroot/wt/dotgotfoo.link $testroot/content
2190 cmp -s $testroot/content.expected $testroot/content
2192 if [ "$ret" != "0" ]; then
2193 diff -u $testroot/content.expected $testroot/content
2194 test_done "$testroot" "$ret"
2198 if [ -h $testroot/wt/dotgotbar.link ]; then
2199 echo "dotgotbar.link is a symlink"
2200 test_done "$testroot" "1"
2203 echo "<<<<<<< merged change: commit $commit_id2" \
2204 > $testroot/content.expected
2205 echo -n ".got/bar" >> $testroot/content.expected
2206 echo "=======" >> $testroot/content.expected
2207 echo "this is regular file bar" >> $testroot/content.expected
2208 echo '>>>>>>>' >> $testroot/content.expected
2209 echo -n "" >> $testroot/content.expected
2211 cp $testroot/wt/dotgotbar.link $testroot/content
2212 cmp -s $testroot/content.expected $testroot/content
2214 if [ "$ret" != "0" ]; then
2215 diff -u $testroot/content.expected $testroot/content
2216 test_done "$testroot" "$ret"
2220 if [ -h $testroot/wt/new.link ]; then
2221 echo "new.link is a symlink"
2222 test_done "$testroot" "1"
2226 echo "<<<<<<< merged change: commit $commit_id2" \
2227 > $testroot/content.expected
2228 echo "alpha" >> $testroot/content.expected
2229 echo "=======" >> $testroot/content.expected
2230 echo "beta" >> $testroot/content.expected
2231 echo '>>>>>>>' >> $testroot/content.expected
2232 echo -n "" >> $testroot/content.expected
2234 cp $testroot/wt/new.link $testroot/content
2235 cmp -s $testroot/content.expected $testroot/content
2237 if [ "$ret" != "0" ]; then
2238 diff -u $testroot/content.expected $testroot/content
2239 test_done "$testroot" "$ret"
2243 echo "A dotgotfoo.link" > $testroot/stdout.expected
2244 echo "M new.link" >> $testroot/stdout.expected
2245 echo "D nonexistent.link" >> $testroot/stdout.expected
2246 (cd $testroot/wt && got status > $testroot/stdout)
2247 if [ "$ret" != "0" ]; then
2248 diff -u $testroot/stdout.expected $testroot/stdout
2249 test_done "$testroot" "$ret"
2253 test_done "$testroot" "0"
2257 run_test test_update_basic
2258 run_test test_update_adds_file
2259 run_test test_update_deletes_file
2260 run_test test_update_deletes_dir
2261 run_test test_update_deletes_dir_with_path_prefix
2262 run_test test_update_deletes_dir_recursively
2263 run_test test_update_sibling_dirs_with_common_prefix
2264 run_test test_update_dir_with_dot_sibling
2265 run_test test_update_moves_files_upwards
2266 run_test test_update_moves_files_to_new_dir
2267 run_test test_update_creates_missing_parent
2268 run_test test_update_creates_missing_parent_with_subdir
2269 run_test test_update_file_in_subsubdir
2270 run_test test_update_merges_file_edits
2271 run_test test_update_keeps_xbit
2272 run_test test_update_clears_xbit
2273 run_test test_update_restores_missing_file
2274 run_test test_update_conflict_wt_add_vs_repo_add
2275 run_test test_update_conflict_wt_edit_vs_repo_rm
2276 run_test test_update_conflict_wt_rm_vs_repo_edit
2277 run_test test_update_conflict_wt_rm_vs_repo_rm
2278 run_test test_update_partial
2279 run_test test_update_partial_add
2280 run_test test_update_partial_rm
2281 run_test test_update_partial_dir
2282 run_test test_update_moved_branch_ref
2283 run_test test_update_to_another_branch
2284 run_test test_update_to_commit_on_wrong_branch
2285 run_test test_update_bumps_base_commit_id
2286 run_test test_update_tag
2287 run_test test_update_toggles_xbit
2288 run_test test_update_preserves_conflicted_file
2289 run_test test_update_modified_submodules
2290 run_test test_update_adds_submodule
2291 run_test test_update_conflict_wt_file_vs_repo_submodule
2292 run_test test_update_adds_symlink
2293 run_test test_update_deletes_symlink
2294 run_test test_update_symlink_conflicts