Blob


1 #!/bin/sh
2 #
3 # Copyright (c) 2019 Stefan Sperling <stsp@openbsd.org>
4 #
5 # Permission to use, copy, modify, and distribute this software for any
6 # purpose with or without fee is hereby granted, provided that the above
7 # copyright notice and this permission notice appear in all copies.
8 #
9 # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 . ./common.sh
19 test_update_basic() {
20 local testroot=`test_init update_basic`
22 got checkout $testroot/repo $testroot/wt > /dev/null
23 ret=$?
24 if [ $ret -ne 0 ]; then
25 test_done "$testroot" "$ret"
26 return 1
27 fi
29 echo "modified alpha" > $testroot/repo/alpha
30 git_commit $testroot/repo -m "modified alpha"
32 echo "U alpha" > $testroot/stdout.expected
33 echo -n "Updated to refs/heads/master: " >> $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
40 ret=$?
41 if [ $ret -ne 0 ]; then
42 diff -u $testroot/stdout.expected $testroot/stdout
43 test_done "$testroot" "$ret"
44 return 1
45 fi
47 echo "modified alpha" > $testroot/content.expected
48 cat $testroot/wt/alpha > $testroot/content
50 cmp -s $testroot/content.expected $testroot/content
51 ret=$?
52 if [ $ret -ne 0 ]; then
53 diff -u $testroot/content.expected $testroot/content
54 fi
55 test_done "$testroot" "$ret"
56 }
58 test_update_adds_file() {
59 local testroot=`test_init update_adds_file`
61 got checkout $testroot/repo $testroot/wt > /dev/null
62 ret=$?
63 if [ $ret -ne 0 ]; then
64 test_done "$testroot" "$ret"
65 return 1
66 fi
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 refs/heads/master: " >> $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
80 ret=$?
81 if [ $ret -ne 0 ]; then
82 diff -u $testroot/stdout.expected $testroot/stdout
83 test_done "$testroot" "$ret"
84 return 1
85 fi
87 echo "new" >> $testroot/content.expected
88 cat $testroot/wt/gamma/new > $testroot/content
90 cmp -s $testroot/content.expected $testroot/content
91 ret=$?
92 if [ $ret -ne 0 ]; then
93 diff -u $testroot/content.expected $testroot/content
94 fi
95 test_done "$testroot" "$ret"
96 }
98 test_update_deletes_file() {
99 local testroot=`test_init update_deletes_file`
101 mkdir $testroot/wtparent
102 got checkout $testroot/repo $testroot/wtparent/wt > /dev/null
103 ret=$?
104 if [ $ret -ne 0 ]; then
105 test_done "$testroot" "$ret"
106 return 1
107 fi
109 git_rm $testroot/repo beta
110 git_commit $testroot/repo -m "deleting a file"
112 echo "D beta" > $testroot/stdout.expected
113 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
114 git_show_head $testroot/repo >> $testroot/stdout.expected
115 echo >> $testroot/stdout.expected
117 # verify that no error occurs if the work tree's parent
118 # directory is not writable
119 chmod u-w $testroot/wtparent
120 (cd $testroot/wtparent/wt && got update > $testroot/stdout)
121 chmod u+w $testroot/wtparent
123 cmp -s $testroot/stdout.expected $testroot/stdout
124 ret=$?
125 if [ $ret -ne 0 ]; then
126 diff -u $testroot/stdout.expected $testroot/stdout
127 test_done "$testroot" "$ret"
128 return 1
129 fi
131 if [ -e $testroot/wtparent/wt/beta ]; then
132 echo "removed file beta still exists on disk" >&2
133 test_done "$testroot" "1"
134 return 1
135 fi
137 test_done "$testroot" "0"
140 test_update_deletes_dir() {
141 local testroot=`test_init update_deletes_dir`
143 got checkout $testroot/repo $testroot/wt > /dev/null
144 ret=$?
145 if [ $ret -ne 0 ]; then
146 test_done "$testroot" "$ret"
147 return 1
148 fi
150 git_rm $testroot/repo -r epsilon
151 git_commit $testroot/repo -m "deleting a directory"
153 echo "D epsilon/zeta" > $testroot/stdout.expected
154 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
155 git_show_head $testroot/repo >> $testroot/stdout.expected
156 echo >> $testroot/stdout.expected
158 (cd $testroot/wt && got update > $testroot/stdout)
160 cmp -s $testroot/stdout.expected $testroot/stdout
161 ret=$?
162 if [ $ret -ne 0 ]; then
163 diff -u $testroot/stdout.expected $testroot/stdout
164 test_done "$testroot" "$ret"
165 return 1
166 fi
168 if [ -e $testroot/wt/epsilon ]; then
169 echo "removed dir epsilon still exists on disk" >&2
170 test_done "$testroot" "1"
171 return 1
172 fi
174 test_done "$testroot" "0"
177 test_update_deletes_dir_with_path_prefix() {
178 local testroot=`test_init update_deletes_dir_with_path_prefix`
179 local first_rev=`git_show_head $testroot/repo`
181 mkdir $testroot/repo/epsilon/psi
182 echo mu > $testroot/repo/epsilon/psi/mu
183 (cd $testroot/repo && git add .)
184 git_commit $testroot/repo -m "adding a sub-directory beneath epsilon"
186 # check out the epsilon/ sub-tree
187 got checkout -p epsilon $testroot/repo $testroot/wt > /dev/null
188 ret=$?
189 if [ $ret -ne 0 ]; then
190 test_done "$testroot" "$ret"
191 return 1
192 fi
194 # update back to first commit and expect psi/mu to be deleted
195 echo "D psi/mu" > $testroot/stdout.expected
196 echo "Updated to refs/heads/master: $first_rev" \
197 >> $testroot/stdout.expected
199 (cd $testroot/wt && got update -c $first_rev > $testroot/stdout)
201 cmp -s $testroot/stdout.expected $testroot/stdout
202 ret=$?
203 if [ $ret -ne 0 ]; then
204 diff -u $testroot/stdout.expected $testroot/stdout
205 test_done "$testroot" "$ret"
206 return 1
207 fi
209 if [ -e $testroot/wt/psi ]; then
210 echo "removed dir psi still exists on disk" >&2
211 test_done "$testroot" "1"
212 return 1
213 fi
215 test_done "$testroot" "0"
218 test_update_deletes_dir_recursively() {
219 local testroot=`test_init update_deletes_dir_recursively`
220 local first_rev=`git_show_head $testroot/repo`
222 mkdir $testroot/repo/epsilon/psi
223 echo mu > $testroot/repo/epsilon/psi/mu
224 mkdir $testroot/repo/epsilon/psi/chi
225 echo tau > $testroot/repo/epsilon/psi/chi/tau
226 (cd $testroot/repo && git add .)
227 git_commit $testroot/repo -m "adding a sub-directory beneath epsilon"
229 # check out the epsilon/ sub-tree
230 got checkout -p epsilon $testroot/repo $testroot/wt > /dev/null
231 ret=$?
232 if [ $ret -ne 0 ]; then
233 test_done "$testroot" "$ret"
234 return 1
235 fi
237 # update back to first commit and expect psi/mu to be deleted
238 echo "D psi/chi/tau" > $testroot/stdout.expected
239 echo "D psi/mu" >> $testroot/stdout.expected
240 echo "Updated to refs/heads/master: $first_rev" \
241 >> $testroot/stdout.expected
243 (cd $testroot/wt && got update -c $first_rev > $testroot/stdout)
245 cmp -s $testroot/stdout.expected $testroot/stdout
246 ret=$?
247 if [ "$?" != "0" ]; then
248 diff -u $testroot/stdout.expected $testroot/stdout
249 test_done "$testroot" "$ret"
250 return 1
251 fi
253 if [ -e $testroot/wt/psi ]; then
254 echo "removed dir psi still exists on disk" >&2
255 test_done "$testroot" "1"
256 return 1
257 fi
259 test_done "$testroot" "0"
262 test_update_sibling_dirs_with_common_prefix() {
263 local testroot=`test_init update_sibling_dirs_with_common_prefix`
265 got checkout $testroot/repo $testroot/wt > /dev/null
266 ret=$?
267 if [ $ret -ne 0 ]; then
268 test_done "$testroot" "$ret"
269 return 1
270 fi
272 mkdir $testroot/repo/epsilon2
273 echo mu > $testroot/repo/epsilon2/mu
274 (cd $testroot/repo && git add epsilon2/mu)
275 git_commit $testroot/repo -m "adding sibling of epsilon"
276 echo change > $testroot/repo/epsilon/zeta
277 git_commit $testroot/repo -m "changing epsilon/zeta"
279 echo "U epsilon/zeta" > $testroot/stdout.expected
280 echo "A epsilon2/mu" >> $testroot/stdout.expected
281 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
282 git_show_head $testroot/repo >> $testroot/stdout.expected
283 echo >> $testroot/stdout.expected
285 (cd $testroot/wt && got update > $testroot/stdout)
287 cmp -s $testroot/stdout.expected $testroot/stdout
288 ret=$?
289 if [ $ret -ne 0 ]; then
290 diff -u $testroot/stdout.expected $testroot/stdout
291 test_done "$testroot" "$ret"
292 return 1
293 fi
295 echo "another change" > $testroot/repo/epsilon/zeta
296 git_commit $testroot/repo -m "changing epsilon/zeta again"
298 echo "U epsilon/zeta" > $testroot/stdout.expected
299 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
300 git_show_head $testroot/repo >> $testroot/stdout.expected
301 echo >> $testroot/stdout.expected
303 # Bug: This update used to do delete/add epsilon2/mu again:
304 # U epsilon/zeta
305 # D epsilon2/mu <--- not intended
306 # A epsilon2/mu <--- not intended
307 (cd $testroot/wt && got update > $testroot/stdout)
309 cmp -s $testroot/stdout.expected $testroot/stdout
310 ret=$?
311 if [ $ret -ne 0 ]; then
312 diff -u $testroot/stdout.expected $testroot/stdout
313 test_done "$testroot" "$ret"
314 return 1
315 fi
317 cmp -s $testroot/stdout.expected $testroot/stdout
318 ret=$?
319 if [ $ret -ne 0 ]; then
320 diff -u $testroot/stdout.expected $testroot/stdout
321 fi
322 test_done "$testroot" "$ret"
325 test_update_dir_with_dot_sibling() {
326 local testroot=`test_init update_dir_with_dot_sibling`
328 got checkout $testroot/repo $testroot/wt > /dev/null
329 ret=$?
330 if [ $ret -ne 0 ]; then
331 test_done "$testroot" "$ret"
332 return 1
333 fi
335 echo text > $testroot/repo/epsilon.txt
336 (cd $testroot/repo && git add epsilon.txt)
337 git_commit $testroot/repo -m "adding sibling of epsilon"
338 echo change > $testroot/repo/epsilon/zeta
339 git_commit $testroot/repo -m "changing epsilon/zeta"
341 echo "U epsilon/zeta" > $testroot/stdout.expected
342 echo "A epsilon.txt" >> $testroot/stdout.expected
343 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
344 git_show_head $testroot/repo >> $testroot/stdout.expected
345 echo >> $testroot/stdout.expected
347 (cd $testroot/wt && got update > $testroot/stdout)
349 cmp -s $testroot/stdout.expected $testroot/stdout
350 ret=$?
351 if [ $ret -ne 0 ]; then
352 diff -u $testroot/stdout.expected $testroot/stdout
353 test_done "$testroot" "$ret"
354 return 1
355 fi
357 echo "another change" > $testroot/repo/epsilon/zeta
358 git_commit $testroot/repo -m "changing epsilon/zeta again"
360 echo "U epsilon/zeta" > $testroot/stdout.expected
361 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
362 git_show_head $testroot/repo >> $testroot/stdout.expected
363 echo >> $testroot/stdout.expected
365 (cd $testroot/wt && got update > $testroot/stdout)
367 cmp -s $testroot/stdout.expected $testroot/stdout
368 ret=$?
369 if [ $ret -ne 0 ]; then
370 diff -u $testroot/stdout.expected $testroot/stdout
371 test_done "$testroot" "$ret"
372 return 1
373 fi
375 cmp -s $testroot/stdout.expected $testroot/stdout
376 ret=$?
377 if [ $ret -ne 0 ]; then
378 diff -u $testroot/stdout.expected $testroot/stdout
379 fi
380 test_done "$testroot" "$ret"
383 test_update_moves_files_upwards() {
384 local testroot=`test_init update_moves_files_upwards`
386 mkdir $testroot/repo/epsilon/psi
387 echo mu > $testroot/repo/epsilon/psi/mu
388 mkdir $testroot/repo/epsilon/psi/chi
389 echo tau > $testroot/repo/epsilon/psi/chi/tau
390 (cd $testroot/repo && git add .)
391 git_commit $testroot/repo -m "adding a sub-directory beneath epsilon"
393 got checkout $testroot/repo $testroot/wt > /dev/null
394 ret=$?
395 if [ $ret -ne 0 ]; then
396 test_done "$testroot" "$ret"
397 return 1
398 fi
400 (cd $testroot/repo && git mv epsilon/psi/mu epsilon/mu)
401 (cd $testroot/repo && git mv epsilon/psi/chi/tau epsilon/psi/tau)
402 git_commit $testroot/repo -m "moving files upwards"
404 echo "A epsilon/mu" > $testroot/stdout.expected
405 echo "D epsilon/psi/chi/tau" >> $testroot/stdout.expected
406 echo "D epsilon/psi/mu" >> $testroot/stdout.expected
407 echo "A epsilon/psi/tau" >> $testroot/stdout.expected
408 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
409 git_show_head $testroot/repo >> $testroot/stdout.expected
410 echo >> $testroot/stdout.expected
412 (cd $testroot/wt && got update > $testroot/stdout)
414 cmp -s $testroot/stdout.expected $testroot/stdout
415 ret=$?
416 if [ $ret -ne 0 ]; then
417 diff -u $testroot/stdout.expected $testroot/stdout
418 test_done "$testroot" "$ret"
419 return 1
420 fi
422 if [ -e $testroot/wt/epsilon/psi/chi ]; then
423 echo "removed dir epsilon/psi/chi still exists on disk" >&2
424 test_done "$testroot" "1"
425 return 1
426 fi
428 if [ -e $testroot/wt/epsilon/psi/mu ]; then
429 echo "removed file epsilon/psi/mu still exists on disk" >&2
430 test_done "$testroot" "1"
431 return 1
432 fi
434 test_done "$testroot" "0"
437 test_update_moves_files_to_new_dir() {
438 local testroot=`test_init update_moves_files_to_new_dir`
440 mkdir $testroot/repo/epsilon/psi
441 echo mu > $testroot/repo/epsilon/psi/mu
442 mkdir $testroot/repo/epsilon/psi/chi
443 echo tau > $testroot/repo/epsilon/psi/chi/tau
444 (cd $testroot/repo && git add .)
445 git_commit $testroot/repo -m "adding a sub-directory beneath epsilon"
447 got checkout $testroot/repo $testroot/wt > /dev/null
448 ret=$?
449 if [ $ret -ne 0 ]; then
450 test_done "$testroot" "$ret"
451 return 1
452 fi
454 mkdir -p $testroot/repo/epsilon-new/psi
455 (cd $testroot/repo && git mv epsilon/psi/mu epsilon-new/mu)
456 (cd $testroot/repo && git mv epsilon/psi/chi/tau epsilon-new/psi/tau)
457 git_commit $testroot/repo -m "moving files upwards"
459 echo "D epsilon/psi/chi/tau" > $testroot/stdout.expected
460 echo "D epsilon/psi/mu" >> $testroot/stdout.expected
461 echo "A epsilon-new/mu" >> $testroot/stdout.expected
462 echo "A epsilon-new/psi/tau" >> $testroot/stdout.expected
463 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
464 git_show_head $testroot/repo >> $testroot/stdout.expected
465 echo >> $testroot/stdout.expected
467 (cd $testroot/wt && got update > $testroot/stdout)
469 cmp -s $testroot/stdout.expected $testroot/stdout
470 ret=$?
471 if [ $ret -ne 0 ]; then
472 diff -u $testroot/stdout.expected $testroot/stdout
473 test_done "$testroot" "$ret"
474 return 1
475 fi
477 if [ -e $testroot/wt/epsilon/psi/chi ]; then
478 echo "removed dir epsilon/psi/chi still exists on disk" >&2
479 test_done "$testroot" "1"
480 return 1
481 fi
483 if [ -e $testroot/wt/epsilon/psi/mu ]; then
484 echo "removed file epsilon/psi/mu still exists on disk" >&2
485 test_done "$testroot" "1"
486 return 1
487 fi
489 test_done "$testroot" "0"
492 test_update_creates_missing_parent() {
493 local testroot=`test_init update_creates_missing_parent 1`
495 touch $testroot/repo/Makefile
496 touch $testroot/repo/snake.6
497 touch $testroot/repo/snake.c
498 (cd $testroot/repo && git add .)
499 git_commit $testroot/repo -m "adding initial snake tree"
501 got checkout $testroot/repo $testroot/wt > /dev/null
502 ret=$?
503 if [ $ret -ne 0 ]; then
504 test_done "$testroot" "$ret"
505 return 1
506 fi
508 mkdir -p $testroot/repo/snake
509 (cd $testroot/repo && git mv Makefile snake.6 snake.c snake)
510 touch $testroot/repo/snake/move.c
511 touch $testroot/repo/snake/pathnames.h
512 touch $testroot/repo/snake/snake.h
513 mkdir -p $testroot/repo/snscore
514 touch $testroot/repo/snscore/Makefile
515 touch $testroot/repo/snscore/snscore.c
516 (cd $testroot/repo && git add .)
517 git_commit $testroot/repo -m "restructuring snake tree"
519 echo "D Makefile" > $testroot/stdout.expected
520 echo "A snake/Makefile" >> $testroot/stdout.expected
521 echo "A snake/move.c" >> $testroot/stdout.expected
522 echo "A snake/pathnames.h" >> $testroot/stdout.expected
523 echo "A snake/snake.6" >> $testroot/stdout.expected
524 echo "A snake/snake.c" >> $testroot/stdout.expected
525 echo "A snake/snake.h" >> $testroot/stdout.expected
526 echo "D snake.6" >> $testroot/stdout.expected
527 echo "D snake.c" >> $testroot/stdout.expected
528 echo "A snscore/Makefile" >> $testroot/stdout.expected
529 echo "A snscore/snscore.c" >> $testroot/stdout.expected
530 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
531 git_show_head $testroot/repo >> $testroot/stdout.expected
532 echo >> $testroot/stdout.expected
534 (cd $testroot/wt && got update > $testroot/stdout)
536 cmp -s $testroot/stdout.expected $testroot/stdout
537 ret=$?
538 if [ $ret -ne 0 ]; then
539 diff -u $testroot/stdout.expected $testroot/stdout
540 fi
541 test_done "$testroot" "$ret"
544 test_update_creates_missing_parent_with_subdir() {
545 local testroot=`test_init update_creates_missing_parent_with_subdir 1`
547 touch $testroot/repo/Makefile
548 touch $testroot/repo/snake.6
549 touch $testroot/repo/snake.c
550 (cd $testroot/repo && git add .)
551 git_commit $testroot/repo -m "adding initial snake tree"
553 got checkout $testroot/repo $testroot/wt > /dev/null
554 ret=$?
555 if [ $ret -ne 0 ]; then
556 test_done "$testroot" "$ret"
557 return 1
558 fi
560 mkdir -p $testroot/repo/sss/snake
561 (cd $testroot/repo && git mv Makefile snake.6 snake.c sss/snake)
562 touch $testroot/repo/sss/snake/move.c
563 touch $testroot/repo/sss/snake/pathnames.h
564 touch $testroot/repo/sss/snake/snake.h
565 mkdir -p $testroot/repo/snscore
566 touch $testroot/repo/snscore/Makefile
567 touch $testroot/repo/snscore/snscore.c
568 (cd $testroot/repo && git add .)
569 git_commit $testroot/repo -m "restructuring snake tree"
571 echo "D Makefile" > $testroot/stdout.expected
572 echo "D snake.6" >> $testroot/stdout.expected
573 echo "D snake.c" >> $testroot/stdout.expected
574 echo "A snscore/Makefile" >> $testroot/stdout.expected
575 echo "A snscore/snscore.c" >> $testroot/stdout.expected
576 echo "A sss/snake/Makefile" >> $testroot/stdout.expected
577 echo "A sss/snake/move.c" >> $testroot/stdout.expected
578 echo "A sss/snake/pathnames.h" >> $testroot/stdout.expected
579 echo "A sss/snake/snake.6" >> $testroot/stdout.expected
580 echo "A sss/snake/snake.c" >> $testroot/stdout.expected
581 echo "A sss/snake/snake.h" >> $testroot/stdout.expected
582 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
583 git_show_head $testroot/repo >> $testroot/stdout.expected
584 echo >> $testroot/stdout.expected
586 (cd $testroot/wt && got update > $testroot/stdout)
588 cmp -s $testroot/stdout.expected $testroot/stdout
589 ret=$?
590 if [ $ret -ne 0 ]; then
591 diff -u $testroot/stdout.expected $testroot/stdout
592 test_done "$testroot" "$ret"
593 return 1
594 fi
596 test_done "$testroot" "0"
599 test_update_file_in_subsubdir() {
600 local testroot=`test_init update_fle_in_subsubdir 1`
602 touch $testroot/repo/Makefile
603 mkdir -p $testroot/repo/altq
604 touch $testroot/repo/altq/if_altq.h
605 mkdir -p $testroot/repo/arch/alpha
606 touch $testroot/repo/arch/alpha/Makefile
607 (cd $testroot/repo && git add .)
608 git_commit $testroot/repo -m "adding initial tree"
610 got checkout $testroot/repo $testroot/wt > /dev/null
611 ret=$?
612 if [ $ret -ne 0 ]; then
613 test_done "$testroot" "$ret"
614 return 1
615 fi
617 echo change > $testroot/repo/arch/alpha/Makefile
618 (cd $testroot/repo && git add .)
619 git_commit $testroot/repo -m "changed a file"
621 echo "U arch/alpha/Makefile" > $testroot/stdout.expected
622 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
623 git_show_head $testroot/repo >> $testroot/stdout.expected
624 echo >> $testroot/stdout.expected
626 (cd $testroot/wt && got update > $testroot/stdout)
628 cmp -s $testroot/stdout.expected $testroot/stdout
629 ret=$?
630 if [ $ret -ne 0 ]; then
631 diff -u $testroot/stdout.expected $testroot/stdout
632 test_done "$testroot" "$ret"
633 return 1
634 fi
636 test_done "$testroot" "0"
639 test_update_changes_file_to_dir() {
640 local testroot=`test_init update_changes_file_to_dir`
642 got checkout $testroot/repo $testroot/wt > /dev/null
643 ret=$?
644 if [ $ret -ne 0 ]; then
645 test_done "$testroot" "$ret"
646 return 1
647 fi
649 git_rm $testroot/repo alpha
650 mkdir $testroot/repo/alpha
651 echo eta > $testroot/repo/alpha/eta
652 (cd $testroot/repo && git add alpha/eta)
653 git_commit $testroot/repo -m "changed alpha into directory"
655 (cd $testroot/wt && got update > $testroot/stdout 2> $testroot/stderr)
656 ret=$?
657 if [ $ret -ne 0 ]; then
658 echo "update failed unexpectedly" >&2
659 test_done "$testroot" "1"
660 return 1
661 fi
663 echo "D alpha" > $testroot/stdout.expected
664 echo "A alpha/eta" >> $testroot/stdout.expected
665 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
666 git_show_head $testroot/repo >> $testroot/stdout.expected
667 echo >> $testroot/stdout.expected
669 cmp -s $testroot/stdout.expected $testroot/stdout
670 ret=$?
671 if [ $ret -ne 0 ]; then
672 diff -u $testroot/stdout.expected $testroot/stdout
673 fi
674 test_done "$testroot" "$ret"
677 test_update_changes_modified_file_to_dir() {
678 local testroot=`test_init update_changes_modified_file_to_dir`
680 got checkout $testroot/repo $testroot/wt > /dev/null
681 ret=$?
682 if [ $ret -ne 0 ]; then
683 test_done "$testroot" "$ret"
684 return 1
685 fi
687 git_rm $testroot/repo alpha
688 mkdir $testroot/repo/alpha
689 echo eta > $testroot/repo/alpha/eta
690 (cd $testroot/repo && git add alpha/eta)
691 git_commit $testroot/repo -m "changed alpha into directory"
693 echo "modified alpha" >> $testroot/wt/alpha
694 cp $testroot/wt/alpha $testroot/wt/content.expected
695 (cd $testroot/wt && got update > $testroot/stdout 2> $testroot/stderr)
696 ret=$?
697 if [ $ret -eq 0 ]; then
698 echo "update succeeded unexpectedly" >&2
699 test_done "$testroot" "1"
700 return 1
701 fi
703 echo "d alpha" > $testroot/stdout.expected
704 cmp -s $testroot/stdout.expected $testroot/stdout
705 ret=$?
706 if [ $ret -ne 0 ]; then
707 diff -u $testroot/stdout.expected $testroot/stdout
708 test_done "$testroot" "$ret"
709 return 1
710 fi
712 echo "got: alpha/eta: file is obstructed" > $testroot/stderr.expected
713 cmp -s $testroot/stderr.expected $testroot/stderr
714 ret=$?
715 if [ $ret -ne 0 ]; then
716 diff -u $testroot/stderr.expected $testroot/stderr
717 fi
718 test_done "$testroot" "$ret"
721 test_update_merges_file_edits() {
722 local testroot=`test_init update_merges_file_edits`
724 echo "1" > $testroot/repo/numbers
725 echo "2" >> $testroot/repo/numbers
726 echo "3" >> $testroot/repo/numbers
727 echo "4" >> $testroot/repo/numbers
728 echo "5" >> $testroot/repo/numbers
729 echo "6" >> $testroot/repo/numbers
730 echo "7" >> $testroot/repo/numbers
731 echo "8" >> $testroot/repo/numbers
732 (cd $testroot/repo && git add numbers)
733 git_commit $testroot/repo -m "added numbers file"
734 local base_commit=`git_show_head $testroot/repo`
736 got checkout $testroot/repo $testroot/wt > /dev/null
737 ret=$?
738 if [ $ret -ne 0 ]; then
739 test_done "$testroot" "$ret"
740 return 1
741 fi
743 echo "modified alpha" > $testroot/repo/alpha
744 echo "modified beta" > $testroot/repo/beta
745 ed -s $testroot/repo/numbers <<-\EOF
746 ,s/2/22/
748 EOF
749 git_commit $testroot/repo -m "modified 3 files"
751 echo "modified alpha, too" > $testroot/wt/alpha
752 touch $testroot/wt/beta
753 ed -s $testroot/wt/numbers <<-\EOF
754 ,s/7/77/
756 EOF
758 echo "C alpha" > $testroot/stdout.expected
759 echo "U beta" >> $testroot/stdout.expected
760 echo "G numbers" >> $testroot/stdout.expected
761 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
762 git_show_head $testroot/repo >> $testroot/stdout.expected
763 echo >> $testroot/stdout.expected
764 echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
766 (cd $testroot/wt && got update > $testroot/stdout)
768 cmp -s $testroot/stdout.expected $testroot/stdout
769 ret=$?
770 if [ $ret -ne 0 ]; then
771 diff -u $testroot/stdout.expected $testroot/stdout
772 test_done "$testroot" "$ret"
773 return 1
774 fi
776 echo -n "<<<<<<< merged change: commit " > $testroot/content.expected
777 git_show_head $testroot/repo >> $testroot/content.expected
778 echo >> $testroot/content.expected
779 echo "modified alpha" >> $testroot/content.expected
780 echo "||||||| 3-way merge base: commit $base_commit" \
781 >> $testroot/content.expected
782 echo "alpha" >> $testroot/content.expected
783 echo "=======" >> $testroot/content.expected
784 echo "modified alpha, too" >> $testroot/content.expected
785 echo '>>>>>>>' >> $testroot/content.expected
786 echo "modified beta" >> $testroot/content.expected
787 echo "1" >> $testroot/content.expected
788 echo "22" >> $testroot/content.expected
789 echo "3" >> $testroot/content.expected
790 echo "4" >> $testroot/content.expected
791 echo "5" >> $testroot/content.expected
792 echo "6" >> $testroot/content.expected
793 echo "77" >> $testroot/content.expected
794 echo "8" >> $testroot/content.expected
796 cat $testroot/wt/alpha > $testroot/content
797 cat $testroot/wt/beta >> $testroot/content
798 cat $testroot/wt/numbers >> $testroot/content
800 cmp -s $testroot/content.expected $testroot/content
801 ret=$?
802 if [ $ret -ne 0 ]; then
803 diff -u $testroot/content.expected $testroot/content
804 fi
805 test_done "$testroot" "$ret"
808 test_update_keeps_xbit() {
809 local testroot=`test_init update_keeps_xbit 1`
811 touch $testroot/repo/xfile
812 chmod +x $testroot/repo/xfile
813 (cd $testroot/repo && git add .)
814 git_commit $testroot/repo -m "adding executable file"
816 got checkout $testroot/repo $testroot/wt > $testroot/stdout
817 ret=$?
818 if [ $ret -ne 0 ]; then
819 test_done "$testroot" "$ret"
820 return 1
821 fi
823 echo foo > $testroot/repo/xfile
824 git_commit $testroot/repo -m "changed executable file"
826 echo "U xfile" > $testroot/stdout.expected
827 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
828 git_show_head $testroot/repo >> $testroot/stdout.expected
829 echo >> $testroot/stdout.expected
831 (cd $testroot/wt && got update > $testroot/stdout)
832 ret=$?
833 if [ $ret -ne 0 ]; then
834 test_done "$testroot" "$ret"
835 return 1
836 fi
838 cmp -s $testroot/stdout.expected $testroot/stdout
839 ret=$?
840 if [ $ret -ne 0 ]; then
841 diff -u $testroot/stdout.expected $testroot/stdout
842 test_done "$testroot" "$ret"
843 return 1
844 fi
846 ls -l $testroot/wt/xfile | grep -q '^-rwx'
847 ret=$?
848 if [ $ret -ne 0 ]; then
849 echo "file is not executable" >&2
850 ls -l $testroot/wt/xfile >&2
851 fi
852 test_done "$testroot" "$ret"
855 test_update_clears_xbit() {
856 local testroot=`test_init update_clears_xbit 1`
858 touch $testroot/repo/xfile
859 chmod +x $testroot/repo/xfile
860 (cd $testroot/repo && git add .)
861 git_commit $testroot/repo -m "adding executable file"
863 got checkout $testroot/repo $testroot/wt > $testroot/stdout
864 ret=$?
865 if [ $ret -ne 0 ]; then
866 test_done "$testroot" "$ret"
867 return 1
868 fi
870 ls -l $testroot/wt/xfile | grep -q '^-rwx'
871 ret=$?
872 if [ $ret -ne 0 ]; then
873 echo "file is not executable" >&2
874 ls -l $testroot/wt/xfile >&2
875 test_done "$testroot" "$ret"
876 return 1
877 fi
879 # XXX git seems to require a file edit when flipping the x bit?
880 echo foo > $testroot/repo/xfile
881 chmod -x $testroot/repo/xfile
882 git_commit $testroot/repo -m "not an executable file anymore"
884 echo "U xfile" > $testroot/stdout.expected
885 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
886 git_show_head $testroot/repo >> $testroot/stdout.expected
887 echo >> $testroot/stdout.expected
889 (cd $testroot/wt && got update > $testroot/stdout)
890 ret=$?
891 if [ $ret -ne 0 ]; then
892 test_done "$testroot" "$ret"
893 return 1
894 fi
896 cmp -s $testroot/stdout.expected $testroot/stdout
897 ret=$?
898 if [ $ret -ne 0 ]; then
899 diff -u $testroot/stdout.expected $testroot/stdout
900 test_done "$testroot" "$ret"
901 return 1
902 fi
904 ls -l $testroot/wt/xfile | grep -q '^-rw-'
905 ret=$?
906 if [ $ret -ne 0 ]; then
907 echo "file is unexpectedly executable" >&2
908 ls -l $testroot/wt/xfile >&2
909 fi
910 test_done "$testroot" "$ret"
913 test_update_restores_missing_file() {
914 local testroot=`test_init update_restores_missing_file`
916 got checkout $testroot/repo $testroot/wt > /dev/null
917 ret=$?
918 if [ $ret -ne 0 ]; then
919 test_done "$testroot" "$ret"
920 return 1
921 fi
923 rm $testroot/wt/alpha
925 echo "! alpha" > $testroot/stdout.expected
926 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
927 git_show_head $testroot/repo >> $testroot/stdout.expected
928 echo >> $testroot/stdout.expected
929 (cd $testroot/wt && got update > $testroot/stdout)
931 cmp -s $testroot/stdout.expected $testroot/stdout
932 ret=$?
933 if [ $ret -ne 0 ]; then
934 diff -u $testroot/stdout.expected $testroot/stdout
935 test_done "$testroot" "$ret"
936 return 1
937 fi
939 echo "alpha" > $testroot/content.expected
941 cat $testroot/wt/alpha > $testroot/content
943 cmp -s $testroot/content.expected $testroot/content
944 ret=$?
945 if [ $ret -ne 0 ]; then
946 diff -u $testroot/content.expected $testroot/content
947 fi
948 test_done "$testroot" "$ret"
951 test_update_conflict_wt_add_vs_repo_add() {
952 local testroot=`test_init update_conflict_wt_add_vs_repo_add`
954 got checkout $testroot/repo $testroot/wt > /dev/null
955 ret=$?
956 if [ $ret -ne 0 ]; then
957 test_done "$testroot" "$ret"
958 return 1
959 fi
961 echo "new" > $testroot/repo/gamma/new
962 (cd $testroot/repo && git add .)
963 git_commit $testroot/repo -m "adding a new file"
965 echo "also new" > $testroot/wt/gamma/new
966 (cd $testroot/wt && got add gamma/new >/dev/null)
968 (cd $testroot/wt && got update > $testroot/stdout)
970 echo "C gamma/new" > $testroot/stdout.expected
971 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
972 git_show_head $testroot/repo >> $testroot/stdout.expected
973 echo >> $testroot/stdout.expected
974 echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
976 cmp -s $testroot/stdout.expected $testroot/stdout
977 ret=$?
978 if [ $ret -ne 0 ]; then
979 diff -u $testroot/stdout.expected $testroot/stdout
980 test_done "$testroot" "$ret"
981 return 1
982 fi
984 echo -n "<<<<<<< merged change: commit " > $testroot/content.expected
985 git_show_head $testroot/repo >> $testroot/content.expected
986 echo >> $testroot/content.expected
987 echo "new" >> $testroot/content.expected
988 echo "=======" >> $testroot/content.expected
989 echo "also new" >> $testroot/content.expected
990 echo '>>>>>>>' >> $testroot/content.expected
992 cat $testroot/wt/gamma/new > $testroot/content
994 cmp -s $testroot/content.expected $testroot/content
995 ret=$?
996 if [ $ret -ne 0 ]; then
997 diff -u $testroot/content.expected $testroot/content
998 test_done "$testroot" "$ret"
999 return 1
1002 # resolve the conflict
1003 echo "new and also new" > $testroot/wt/gamma/new
1004 echo 'M gamma/new' > $testroot/stdout.expected
1005 (cd $testroot/wt && got status > $testroot/stdout)
1006 cmp -s $testroot/stdout.expected $testroot/stdout
1007 ret=$?
1008 if [ $ret -ne 0 ]; then
1009 diff -u $testroot/stdout.expected $testroot/stdout
1011 test_done "$testroot" "$ret"
1014 test_update_conflict_wt_edit_vs_repo_rm() {
1015 local testroot=`test_init update_conflict_wt_edit_vs_repo_rm`
1017 got checkout $testroot/repo $testroot/wt > /dev/null
1018 ret=$?
1019 if [ $ret -ne 0 ]; then
1020 test_done "$testroot" "$ret"
1021 return 1
1024 (cd $testroot/repo && git rm -q beta)
1025 git_commit $testroot/repo -m "removing a file"
1027 echo "modified beta" > $testroot/wt/beta
1029 (cd $testroot/wt && got update > $testroot/stdout)
1031 echo "G beta" > $testroot/stdout.expected
1032 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
1033 git_show_head $testroot/repo >> $testroot/stdout.expected
1034 echo >> $testroot/stdout.expected
1035 cmp -s $testroot/stdout.expected $testroot/stdout
1036 ret=$?
1037 if [ $ret -ne 0 ]; then
1038 diff -u $testroot/stdout.expected $testroot/stdout
1039 test_done "$testroot" "$ret"
1040 return 1
1043 echo "modified beta" > $testroot/content.expected
1045 cat $testroot/wt/beta > $testroot/content
1047 cmp -s $testroot/content.expected $testroot/content
1048 ret=$?
1049 if [ $ret -ne 0 ]; then
1050 diff -u $testroot/content.expected $testroot/content
1051 test_done "$testroot" "$ret"
1052 return 1
1055 # beta is now an added file... we don't flag tree conflicts yet
1056 echo 'A beta' > $testroot/stdout.expected
1057 (cd $testroot/wt && got status > $testroot/stdout)
1058 cmp -s $testroot/stdout.expected $testroot/stdout
1059 ret=$?
1060 if [ $ret -ne 0 ]; then
1061 diff -u $testroot/stdout.expected $testroot/stdout
1063 test_done "$testroot" "$ret"
1066 test_update_conflict_wt_rm_vs_repo_edit() {
1067 local testroot=`test_init update_conflict_wt_rm_vs_repo_edit`
1069 got checkout $testroot/repo $testroot/wt > /dev/null
1070 ret=$?
1071 if [ $ret -ne 0 ]; then
1072 test_done "$testroot" "$ret"
1073 return 1
1076 echo "modified beta" > $testroot/repo/beta
1077 git_commit $testroot/repo -m "modified a file"
1079 (cd $testroot/wt && got rm beta > /dev/null)
1081 (cd $testroot/wt && got update > $testroot/stdout)
1083 echo "G beta" > $testroot/stdout.expected
1084 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
1085 git_show_head $testroot/repo >> $testroot/stdout.expected
1086 echo >> $testroot/stdout.expected
1087 cmp -s $testroot/stdout.expected $testroot/stdout
1088 ret=$?
1089 if [ $ret -ne 0 ]; then
1090 diff -u $testroot/stdout.expected $testroot/stdout
1091 test_done "$testroot" "$ret"
1092 return 1
1095 # beta remains a deleted file... we don't flag tree conflicts yet
1096 echo 'D beta' > $testroot/stdout.expected
1097 (cd $testroot/wt && got status > $testroot/stdout)
1098 cmp -s $testroot/stdout.expected $testroot/stdout
1099 ret=$?
1100 if [ $ret -ne 0 ]; then
1101 diff -u $testroot/stdout.expected $testroot/stdout
1102 test_done "$testroot" "$ret"
1103 return 1
1106 # 'got diff' should show post-update contents of beta being deleted
1107 local head_rev=`git_show_head $testroot/repo`
1108 echo "diff $testroot/wt" > $testroot/stdout.expected
1109 echo "commit - $head_rev" >> $testroot/stdout.expected
1110 echo "path + $testroot/wt" >> $testroot/stdout.expected
1111 echo -n 'blob - ' >> $testroot/stdout.expected
1112 got tree -r $testroot/repo -i | grep 'beta$' | cut -d' ' -f 1 \
1113 >> $testroot/stdout.expected
1114 echo 'file + /dev/null' >> $testroot/stdout.expected
1115 echo '--- beta' >> $testroot/stdout.expected
1116 echo '+++ /dev/null' >> $testroot/stdout.expected
1117 echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
1118 echo '-modified beta' >> $testroot/stdout.expected
1120 (cd $testroot/wt && got diff > $testroot/stdout)
1121 cmp -s $testroot/stdout.expected $testroot/stdout
1122 ret=$?
1123 if [ $ret -ne 0 ]; then
1124 diff -u $testroot/stdout.expected $testroot/stdout
1126 test_done "$testroot" "$ret"
1129 test_update_conflict_wt_rm_vs_repo_rm() {
1130 local testroot=`test_init update_conflict_wt_rm_vs_repo_rm`
1132 got checkout $testroot/repo $testroot/wt > /dev/null
1133 ret=$?
1134 if [ $ret -ne 0 ]; then
1135 test_done "$testroot" "$ret"
1136 return 1
1139 (cd $testroot/repo && git rm -q beta)
1140 git_commit $testroot/repo -m "removing a file"
1142 (cd $testroot/wt && got rm beta > /dev/null)
1144 (cd $testroot/wt && got update > $testroot/stdout)
1146 echo "D beta" > $testroot/stdout.expected
1147 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
1148 git_show_head $testroot/repo >> $testroot/stdout.expected
1149 echo >> $testroot/stdout.expected
1150 cmp -s $testroot/stdout.expected $testroot/stdout
1151 ret=$?
1152 if [ $ret -ne 0 ]; then
1153 diff -u $testroot/stdout.expected $testroot/stdout
1154 test_done "$testroot" "$ret"
1155 return 1
1158 # beta is now gone... we don't flag tree conflicts yet
1159 echo "N beta" > $testroot/stdout.expected
1160 echo -n > $testroot/stderr.expected
1161 (cd $testroot/wt && got status beta > $testroot/stdout \
1162 2> $testroot/stderr)
1163 cmp -s $testroot/stdout.expected $testroot/stdout
1164 ret=$?
1165 if [ $ret -ne 0 ]; then
1166 diff -u $testroot/stdout.expected $testroot/stdout
1167 test_done "$testroot" "$ret"
1168 return 1
1170 cmp -s $testroot/stderr.expected $testroot/stderr
1171 ret=$?
1172 if [ $ret -ne 0 ]; then
1173 diff -u $testroot/stderr.expected $testroot/stderr
1174 test_done "$testroot" "$ret"
1175 return 1
1178 if [ -e $testroot/wt/beta ]; then
1179 echo "removed file beta still exists on disk" >&2
1180 test_done "$testroot" "1"
1181 return 1
1184 test_done "$testroot" "0"
1187 test_update_partial() {
1188 local testroot=`test_init update_partial`
1190 got checkout $testroot/repo $testroot/wt > /dev/null
1191 ret=$?
1192 if [ $ret -ne 0 ]; then
1193 test_done "$testroot" "$ret"
1194 return 1
1197 echo "modified alpha" > $testroot/repo/alpha
1198 echo "modified beta" > $testroot/repo/beta
1199 echo "modified epsilon/zeta" > $testroot/repo/epsilon/zeta
1200 git_commit $testroot/repo -m "modified two files"
1202 echo "U alpha" > $testroot/stdout.expected
1203 echo "U beta" >> $testroot/stdout.expected
1204 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
1205 git_show_head $testroot/repo >> $testroot/stdout.expected
1206 echo >> $testroot/stdout.expected
1208 (cd $testroot/wt && got update alpha beta > $testroot/stdout)
1210 cmp -s $testroot/stdout.expected $testroot/stdout
1211 ret=$?
1212 if [ $ret -ne 0 ]; then
1213 diff -u $testroot/stdout.expected $testroot/stdout
1214 test_done "$testroot" "$ret"
1215 return 1
1218 echo "modified alpha" > $testroot/content.expected
1219 echo "modified beta" >> $testroot/content.expected
1221 cat $testroot/wt/alpha $testroot/wt/beta > $testroot/content
1222 cmp -s $testroot/content.expected $testroot/content
1223 ret=$?
1224 if [ $ret -ne 0 ]; then
1225 diff -u $testroot/content.expected $testroot/content
1226 test_done "$testroot" "$ret"
1227 return 1
1230 echo "U epsilon/zeta" > $testroot/stdout.expected
1231 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
1232 git_show_head $testroot/repo >> $testroot/stdout.expected
1233 echo >> $testroot/stdout.expected
1235 (cd $testroot/wt && got update epsilon > $testroot/stdout)
1237 cmp -s $testroot/stdout.expected $testroot/stdout
1238 ret=$?
1239 if [ $ret -ne 0 ]; then
1240 diff -u $testroot/stdout.expected $testroot/stdout
1241 test_done "$testroot" "$ret"
1242 return 1
1245 echo "modified epsilon/zeta" > $testroot/content.expected
1246 cat $testroot/wt/epsilon/zeta > $testroot/content
1248 cmp -s $testroot/content.expected $testroot/content
1249 ret=$?
1250 if [ $ret -ne 0 ]; then
1251 diff -u $testroot/content.expected $testroot/content
1252 test_done "$testroot" "$ret"
1253 return 1
1256 test_done "$testroot" "$ret"
1259 test_update_partial_add() {
1260 local testroot=`test_init update_partial_add`
1262 got checkout $testroot/repo $testroot/wt > /dev/null
1263 ret=$?
1264 if [ $ret -ne 0 ]; then
1265 test_done "$testroot" "$ret"
1266 return 1
1269 echo "new" > $testroot/repo/new
1270 echo "epsilon/new2" > $testroot/repo/epsilon/new2
1271 (cd $testroot/repo && git add .)
1272 git_commit $testroot/repo -m "added two files"
1274 echo "A epsilon/new2" > $testroot/stdout.expected
1275 echo "A new" >> $testroot/stdout.expected
1276 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
1277 git_show_head $testroot/repo >> $testroot/stdout.expected
1278 echo >> $testroot/stdout.expected
1280 (cd $testroot/wt && got update new epsilon/new2 > $testroot/stdout)
1282 cmp -s $testroot/stdout.expected $testroot/stdout
1283 ret=$?
1284 if [ $ret -ne 0 ]; then
1285 diff -u $testroot/stdout.expected $testroot/stdout
1286 test_done "$testroot" "$ret"
1287 return 1
1290 echo "new" > $testroot/content.expected
1291 echo "epsilon/new2" >> $testroot/content.expected
1293 cat $testroot/wt/new $testroot/wt/epsilon/new2 > $testroot/content
1295 cmp -s $testroot/content.expected $testroot/content
1296 ret=$?
1297 if [ $ret -ne 0 ]; then
1298 diff -u $testroot/content.expected $testroot/content
1300 test_done "$testroot" "$ret"
1303 test_update_partial_rm() {
1304 local testroot=`test_init update_partial_rm`
1306 got checkout $testroot/repo $testroot/wt > /dev/null
1307 ret=$?
1308 if [ $ret -ne 0 ]; then
1309 test_done "$testroot" "$ret"
1310 return 1
1313 (cd $testroot/repo && git rm -q alpha epsilon/zeta)
1314 git_commit $testroot/repo -m "removed two files"
1316 echo "got: /alpha: no such entry found in tree" \
1317 > $testroot/stderr.expected
1319 (cd $testroot/wt && got update alpha epsilon/zeta 2> $testroot/stderr)
1320 ret=$?
1321 if [ $ret -eq 0 ]; then
1322 echo "update succeeded unexpectedly" >&2
1323 test_done "$testroot" "1"
1324 return 1
1327 cmp -s $testroot/stderr.expected $testroot/stderr
1328 ret=$?
1329 if [ $ret -ne 0 ]; then
1330 diff -u $testroot/stderr.expected $testroot/stderr
1331 test_done "$testroot" "$ret"
1332 return 1
1334 test_done "$testroot" "$ret"
1337 test_update_partial_dir() {
1338 local testroot=`test_init update_partial_dir`
1340 got checkout $testroot/repo $testroot/wt > /dev/null
1341 ret=$?
1342 if [ $ret -ne 0 ]; then
1343 test_done "$testroot" "$ret"
1344 return 1
1347 echo "modified alpha" > $testroot/repo/alpha
1348 echo "modified beta" > $testroot/repo/beta
1349 echo "modified epsilon/zeta" > $testroot/repo/epsilon/zeta
1350 git_commit $testroot/repo -m "modified two files"
1352 echo "U epsilon/zeta" > $testroot/stdout.expected
1353 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
1354 git_show_head $testroot/repo >> $testroot/stdout.expected
1355 echo >> $testroot/stdout.expected
1357 (cd $testroot/wt && got update epsilon > $testroot/stdout)
1359 cmp -s $testroot/stdout.expected $testroot/stdout
1360 ret=$?
1361 if [ $ret -ne 0 ]; then
1362 diff -u $testroot/stdout.expected $testroot/stdout
1363 test_done "$testroot" "$ret"
1364 return 1
1367 echo "modified epsilon/zeta" > $testroot/content.expected
1368 cat $testroot/wt/epsilon/zeta > $testroot/content
1370 cmp -s $testroot/content.expected $testroot/content
1371 ret=$?
1372 if [ $ret -ne 0 ]; then
1373 diff -u $testroot/content.expected $testroot/content
1374 test_done "$testroot" "$ret"
1375 return 1
1377 test_done "$testroot" "$ret"
1381 test_update_moved_branch_ref() {
1382 local testroot=`test_init update_moved_branch_ref`
1384 git clone -q --mirror $testroot/repo $testroot/repo2
1386 echo "modified alpha with git" > $testroot/repo/alpha
1387 git_commit $testroot/repo -m "modified alpha with git"
1389 got checkout $testroot/repo2 $testroot/wt > /dev/null
1390 ret=$?
1391 if [ $ret -ne 0 ]; then
1392 test_done "$testroot" "$ret"
1393 return 1
1396 echo "modified alpha with got" > $testroot/wt/alpha
1397 (cd $testroot/wt && got commit -m "modified alpha with got" > /dev/null)
1399 # + xxxxxxx...yyyyyyy master -> master (forced update)
1400 (cd $testroot/repo2 && git fetch -q --all)
1402 echo -n > $testroot/stdout.expected
1403 echo -n "got: work tree's head reference now points to a different " \
1404 > $testroot/stderr.expected
1405 echo "branch; new head reference and/or update -b required" \
1406 >> $testroot/stderr.expected
1408 (cd $testroot/wt && got update > $testroot/stdout 2> $testroot/stderr)
1410 cmp -s $testroot/stdout.expected $testroot/stdout
1411 ret=$?
1412 if [ $ret -ne 0 ]; then
1413 diff -u $testroot/stdout.expected $testroot/stdout
1414 test_done "$testroot" "$ret"
1415 return 1
1418 cmp -s $testroot/stderr.expected $testroot/stderr
1419 ret=$?
1420 if [ $ret -ne 0 ]; then
1421 diff -u $testroot/stderr.expected $testroot/stderr
1423 test_done "$testroot" "$ret"
1426 test_update_to_another_branch() {
1427 local testroot=`test_init update_to_another_branch`
1428 local base_commit=`git_show_head $testroot/repo`
1430 got checkout $testroot/repo $testroot/wt > /dev/null
1431 ret=$?
1432 if [ $ret -ne 0 ]; then
1433 test_done "$testroot" "$ret"
1434 return 1
1437 echo 'refs/heads/master'> $testroot/head-ref.expected
1438 cmp -s $testroot/head-ref.expected $testroot/wt/.got/head-ref
1439 ret=$?
1440 if [ $ret -ne 0 ]; then
1441 diff -u $testroot/head-ref.expected $testroot/wt/.got/head-ref
1442 test_done "$testroot" "$ret"
1443 return 1
1446 (cd $testroot/repo && git checkout -q -b newbranch)
1447 echo "modified alpha on new branch" > $testroot/repo/alpha
1448 git_commit $testroot/repo -m "modified alpha on new branch"
1450 echo "modified alpha in work tree" > $testroot/wt/alpha
1452 echo "Switching work tree from refs/heads/master to refs/heads/newbranch" > $testroot/stdout.expected
1453 echo "C alpha" >> $testroot/stdout.expected
1454 echo -n "Updated to refs/heads/newbranch: " >> $testroot/stdout.expected
1455 git_show_head $testroot/repo >> $testroot/stdout.expected
1456 echo >> $testroot/stdout.expected
1457 echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
1459 (cd $testroot/wt && got update -b newbranch > $testroot/stdout)
1461 cmp -s $testroot/stdout.expected $testroot/stdout
1462 ret=$?
1463 if [ $ret -ne 0 ]; then
1464 diff -u $testroot/stdout.expected $testroot/stdout
1465 test_done "$testroot" "$ret"
1466 return 1
1469 echo -n "<<<<<<< merged change: commit " > $testroot/content.expected
1470 git_show_head $testroot/repo >> $testroot/content.expected
1471 echo >> $testroot/content.expected
1472 echo "modified alpha on new branch" >> $testroot/content.expected
1473 echo "||||||| 3-way merge base: commit $base_commit" \
1474 >> $testroot/content.expected
1475 echo "alpha" >> $testroot/content.expected
1476 echo "=======" >> $testroot/content.expected
1477 echo "modified alpha in work tree" >> $testroot/content.expected
1478 echo '>>>>>>>' >> $testroot/content.expected
1480 cat $testroot/wt/alpha > $testroot/content
1482 cmp -s $testroot/content.expected $testroot/content
1483 ret=$?
1484 if [ $ret -ne 0 ]; then
1485 diff -u $testroot/content.expected $testroot/content
1486 test_done "$testroot" "$ret"
1487 return 1
1490 echo 'refs/heads/newbranch'> $testroot/head-ref.expected
1491 cmp -s $testroot/head-ref.expected $testroot/wt/.got/head-ref
1492 ret=$?
1493 if [ $ret -ne 0 ]; then
1494 diff -u $testroot/head-ref.expected $testroot/wt/.got/head-ref
1495 test_done "$testroot" "$ret"
1496 return 1
1499 test_done "$testroot" "$ret"
1502 test_update_to_commit_on_wrong_branch() {
1503 local testroot=`test_init update_to_commit_on_wrong_branch`
1505 got checkout $testroot/repo $testroot/wt > /dev/null
1506 ret=$?
1507 if [ $ret -ne 0 ]; then
1508 test_done "$testroot" "$ret"
1509 return 1
1512 (cd $testroot/repo && git checkout -q -b newbranch)
1513 echo "modified alpha on new branch" > $testroot/repo/alpha
1514 git_commit $testroot/repo -m "modified alpha on new branch"
1516 echo -n "" > $testroot/stdout.expected
1517 echo "got: target commit is on a different branch" \
1518 > $testroot/stderr.expected
1520 local head_rev=`git_show_head $testroot/repo`
1521 (cd $testroot/wt && got update -c $head_rev > $testroot/stdout \
1522 2> $testroot/stderr)
1524 cmp -s $testroot/stdout.expected $testroot/stdout
1525 ret=$?
1526 if [ $ret -ne 0 ]; then
1527 diff -u $testroot/stdout.expected $testroot/stdout
1528 test_done "$testroot" "$ret"
1529 return 1
1532 cmp -s $testroot/stderr.expected $testroot/stderr
1533 ret=$?
1534 if [ $ret -ne 0 ]; then
1535 diff -u $testroot/stderr.expected $testroot/stderr
1536 test_done "$testroot" "$ret"
1537 return 1
1540 test_done "$testroot" "$ret"
1543 test_update_bumps_base_commit_id() {
1544 local testroot=`test_init update_bumps_base_commit_id`
1546 echo "psi" > $testroot/repo/epsilon/psi
1547 (cd $testroot/repo && git add .)
1548 git_commit $testroot/repo -m "adding another file"
1550 got checkout $testroot/repo $testroot/wt > /dev/null
1551 ret=$?
1552 if [ $ret -ne 0 ]; then
1553 test_done "$testroot" "$ret"
1554 return 1
1557 echo "modified psi" > $testroot/wt/epsilon/psi
1558 (cd $testroot/wt && got commit -m "changed psi" > $testroot/stdout)
1560 local head_rev=`git_show_head $testroot/repo`
1561 echo "M epsilon/psi" > $testroot/stdout.expected
1562 echo "Created commit $head_rev" >> $testroot/stdout.expected
1563 cmp -s $testroot/stdout.expected $testroot/stdout
1564 ret=$?
1565 if [ $ret -ne 0 ]; then
1566 diff -u $testroot/stdout.expected $testroot/stdout
1567 test_done "$testroot" "$ret"
1568 return 1
1571 echo "changed zeta with git" > $testroot/repo/epsilon/zeta
1572 (cd $testroot/repo && git add .)
1573 git_commit $testroot/repo -m "changing zeta with git"
1575 echo "modified zeta" > $testroot/wt/epsilon/zeta
1576 (cd $testroot/wt && got commit -m "changed zeta" > $testroot/stdout \
1577 2> $testroot/stderr)
1579 echo -n "" > $testroot/stdout.expected
1580 echo "got: work tree must be updated before these changes can be committed" > $testroot/stderr.expected
1581 cmp -s $testroot/stderr.expected $testroot/stderr
1582 ret=$?
1583 if [ $ret -ne 0 ]; then
1584 diff -u $testroot/stderr.expected $testroot/stderr
1585 test_done "$testroot" "$ret"
1586 return 1
1589 (cd $testroot/wt && got update > $testroot/stdout)
1591 echo "U epsilon/psi" > $testroot/stdout.expected
1592 echo "C epsilon/zeta" >> $testroot/stdout.expected
1593 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
1594 git_show_head $testroot/repo >> $testroot/stdout.expected
1595 echo >> $testroot/stdout.expected
1596 echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
1598 cmp -s $testroot/stdout.expected $testroot/stdout
1599 ret=$?
1600 if [ $ret -ne 0 ]; then
1601 diff -u $testroot/stdout.expected $testroot/stdout
1602 test_done "$testroot" "$ret"
1603 return 1
1606 # resolve conflict
1607 echo "modified zeta with got and git" > $testroot/wt/epsilon/zeta
1609 (cd $testroot/wt && got commit -m "changed zeta" > $testroot/stdout)
1611 local head_rev=`git_show_head $testroot/repo`
1612 echo "M epsilon/zeta" > $testroot/stdout.expected
1613 echo "Created commit $head_rev" >> $testroot/stdout.expected
1614 cmp -s $testroot/stdout.expected $testroot/stdout
1615 ret=$?
1616 if [ $ret -ne 0 ]; then
1617 diff -u $testroot/stdout.expected $testroot/stdout
1618 test_done "$testroot" "$ret"
1619 return 1
1622 test_done "$testroot" "$ret"
1625 test_update_tag() {
1626 local testroot=`test_init update_tag`
1627 local tag="1.0.0"
1629 got checkout $testroot/repo $testroot/wt > /dev/null
1630 ret=$?
1631 if [ $ret -ne 0 ]; then
1632 test_done "$testroot" "$ret"
1633 return 1
1636 echo "modified alpha" > $testroot/repo/alpha
1637 git_commit $testroot/repo -m "modified alpha"
1638 (cd $testroot/repo && git tag -m "test" -a $tag)
1640 echo "U alpha" > $testroot/stdout.expected
1641 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
1642 git_show_head $testroot/repo >> $testroot/stdout.expected
1643 echo >> $testroot/stdout.expected
1645 (cd $testroot/wt && got update -c $tag > $testroot/stdout)
1647 cmp -s $testroot/stdout.expected $testroot/stdout
1648 ret=$?
1649 if [ $ret -ne 0 ]; then
1650 diff -u $testroot/stdout.expected $testroot/stdout
1651 test_done "$testroot" "$ret"
1652 return 1
1655 echo "modified alpha" > $testroot/content.expected
1656 cat $testroot/wt/alpha > $testroot/content
1658 cmp -s $testroot/content.expected $testroot/content
1659 ret=$?
1660 if [ $ret -ne 0 ]; then
1661 diff -u $testroot/content.expected $testroot/content
1663 test_done "$testroot" "$ret"
1666 test_update_toggles_xbit() {
1667 local testroot=`test_init update_toggles_xbit 1`
1669 touch $testroot/repo/xfile
1670 chmod +x $testroot/repo/xfile
1671 (cd $testroot/repo && git add .)
1672 git_commit $testroot/repo -m "adding executable file"
1673 local commit_id1=`git_show_head $testroot/repo`
1675 got checkout $testroot/repo $testroot/wt > $testroot/stdout
1676 ret=$?
1677 if [ $ret -ne 0 ]; then
1678 test_done "$testroot" "$ret"
1679 return 1
1682 ls -l $testroot/wt/xfile | grep -q '^-rwx'
1683 ret=$?
1684 if [ $ret -ne 0 ]; then
1685 echo "file is not executable" >&2
1686 ls -l $testroot/wt/xfile >&2
1687 test_done "$testroot" "$ret"
1688 return 1
1691 chmod -x $testroot/wt/xfile
1692 (cd $testroot/wt && got commit -m "clear x bit" >/dev/null)
1693 local commit_id2=`git_show_head $testroot/repo`
1695 echo "U xfile" > $testroot/stdout.expected
1696 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
1697 git_show_head $testroot/repo >> $testroot/stdout.expected
1698 echo >> $testroot/stdout.expected
1700 (cd $testroot/wt && got update -c $commit_id1 > $testroot/stdout)
1701 ret=$?
1702 if [ $ret -ne 0 ]; then
1703 test_done "$testroot" "$ret"
1704 return 1
1707 echo "U xfile" > $testroot/stdout.expected
1708 echo "Updated to refs/heads/master: $commit_id1" >> $testroot/stdout.expected
1709 cmp -s $testroot/stdout.expected $testroot/stdout
1710 ret=$?
1711 if [ $ret -ne 0 ]; then
1712 diff -u $testroot/stdout.expected $testroot/stdout
1713 test_done "$testroot" "$ret"
1714 return 1
1718 ls -l $testroot/wt/xfile | grep -q '^-rwx'
1719 ret=$?
1720 if [ $ret -ne 0 ]; then
1721 echo "file is not executable" >&2
1722 ls -l $testroot/wt/xfile >&2
1723 test_done "$testroot" "$ret"
1724 return 1
1727 (cd $testroot/wt && got update > $testroot/stdout)
1728 ret=$?
1729 if [ $ret -ne 0 ]; then
1730 test_done "$testroot" "$ret"
1731 return 1
1734 echo "U xfile" > $testroot/stdout.expected
1735 echo "Updated to refs/heads/master: $commit_id2" \
1736 >> $testroot/stdout.expected
1737 cmp -s $testroot/stdout.expected $testroot/stdout
1738 ret=$?
1739 if [ $ret -ne 0 ]; then
1740 diff -u $testroot/stdout.expected $testroot/stdout
1741 test_done "$testroot" "$ret"
1742 return 1
1745 ls -l $testroot/wt/xfile | grep -q '^-rw-'
1746 ret=$?
1747 if [ $ret -ne 0 ]; then
1748 echo "file is unexpectedly executable" >&2
1749 ls -l $testroot/wt/xfile >&2
1751 test_done "$testroot" "$ret"
1754 test_update_preserves_conflicted_file() {
1755 local testroot=`test_init update_preserves_conflicted_file`
1756 local commit_id0=`git_show_head $testroot/repo`
1758 echo "modified alpha" > $testroot/repo/alpha
1759 git_commit $testroot/repo -m "modified alpha"
1760 local commit_id1=`git_show_head $testroot/repo`
1762 got checkout -c $commit_id0 $testroot/repo $testroot/wt > /dev/null
1763 ret=$?
1764 if [ $ret -ne 0 ]; then
1765 test_done "$testroot" "$ret"
1766 return 1
1769 # fake a merge conflict
1770 echo '<<<<<<<' > $testroot/wt/alpha
1771 echo 'alpha' >> $testroot/wt/alpha
1772 echo '=======' >> $testroot/wt/alpha
1773 echo 'alpha, too' >> $testroot/wt/alpha
1774 echo '>>>>>>>' >> $testroot/wt/alpha
1775 cp $testroot/wt/alpha $testroot/content.expected
1777 echo "C alpha" > $testroot/stdout.expected
1778 (cd $testroot/wt && got status > $testroot/stdout)
1779 cmp -s $testroot/stdout.expected $testroot/stdout
1780 ret=$?
1781 if [ $ret -ne 0 ]; then
1782 diff -u $testroot/stdout.expected $testroot/stdout
1783 test_done "$testroot" "$ret"
1784 return 1
1787 echo "# alpha" > $testroot/stdout.expected
1788 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
1789 git_show_head $testroot/repo >> $testroot/stdout.expected
1790 echo >> $testroot/stdout.expected
1791 echo "Files not updated because of existing merge conflicts: 1" \
1792 >> $testroot/stdout.expected
1793 (cd $testroot/wt && got update > $testroot/stdout)
1795 cmp -s $testroot/stdout.expected $testroot/stdout
1796 ret=$?
1797 if [ $ret -ne 0 ]; then
1798 diff -u $testroot/stdout.expected $testroot/stdout
1799 test_done "$testroot" "$ret"
1800 return 1
1803 cmp -s $testroot/content.expected $testroot/wt/alpha
1804 ret=$?
1805 if [ $ret -ne 0 ]; then
1806 diff -u $testroot/content.expected $testroot/wt/alpha
1808 test_done "$testroot" "$ret"
1811 test_update_modified_submodules() {
1812 local testroot=`test_init update_modified_submodules`
1814 make_single_file_repo $testroot/repo2 foo
1816 (cd $testroot/repo && git -c protocol.file.allow=always \
1817 submodule -q add ../repo2)
1818 (cd $testroot/repo && git commit -q -m 'adding submodule')
1820 got checkout $testroot/repo $testroot/wt > /dev/null
1822 echo "modified foo" > $testroot/repo2/foo
1823 (cd $testroot/repo2 && git commit -q -a -m 'modified a submodule')
1825 # Update the repo/repo2 submodule link
1826 (cd $testroot/repo && git -C repo2 pull -q)
1827 (cd $testroot/repo && git add repo2)
1828 git_commit $testroot/repo -m "modified submodule link"
1830 # This update only records the new base commit. Otherwise it is a
1831 # no-op change because Got's file index does not track submodules.
1832 echo -n "Updated to refs/heads/master: " > $testroot/stdout.expected
1833 git_show_head $testroot/repo >> $testroot/stdout.expected
1834 echo >> $testroot/stdout.expected
1836 (cd $testroot/wt && got update > $testroot/stdout)
1838 cmp -s $testroot/stdout.expected $testroot/stdout
1839 ret=$?
1840 if [ $ret -ne 0 ]; then
1841 diff -u $testroot/stdout.expected $testroot/stdout
1843 test_done "$testroot" "$ret"
1846 test_update_adds_submodule() {
1847 local testroot=`test_init update_adds_submodule`
1849 got checkout $testroot/repo $testroot/wt > /dev/null
1851 make_single_file_repo $testroot/repo2 foo
1853 echo "modified foo" > $testroot/repo2/foo
1854 (cd $testroot/repo2 && git commit -q -a -m 'modified a submodule')
1856 (cd $testroot/repo && git -c protocol.file.allow=always \
1857 submodule -q add ../repo2)
1858 (cd $testroot/repo && git commit -q -m 'adding submodule')
1860 echo "A .gitmodules" > $testroot/stdout.expected
1861 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
1862 git_show_head $testroot/repo >> $testroot/stdout.expected
1863 echo >> $testroot/stdout.expected
1865 (cd $testroot/wt && got update > $testroot/stdout)
1867 cmp -s $testroot/stdout.expected $testroot/stdout
1868 ret=$?
1869 if [ $ret -ne 0 ]; then
1870 diff -u $testroot/stdout.expected $testroot/stdout
1872 test_done "$testroot" "$ret"
1875 test_update_conflict_wt_file_vs_repo_submodule() {
1876 local testroot=`test_init update_conflict_wt_file_vs_repo_submodule`
1878 got checkout $testroot/repo $testroot/wt > /dev/null
1880 make_single_file_repo $testroot/repo2 foo
1882 # Add a file which will clash with the submodule
1883 echo "This is a file called repo2" > $testroot/wt/repo2
1884 (cd $testroot/wt && got add repo2 > /dev/null)
1885 (cd $testroot/wt && got commit -m 'add file repo2' > /dev/null)
1886 ret=$?
1887 if [ $ret -ne 0 ]; then
1888 echo "commit failed unexpectedly" >&2
1889 test_done "$testroot" "1"
1890 return 1
1893 (cd $testroot/repo && git -c protocol.file.allow=always \
1894 submodule -q add ../repo2)
1895 (cd $testroot/repo && git commit -q -m 'adding submodule')
1897 # Modify the clashing file such that any modifications brought
1898 # in by 'got update' would require a merge.
1899 echo "This file was changed" > $testroot/wt/repo2
1901 # No conflict occurs because 'got update' ignores the submodule
1902 # and leaves the clashing file as it was.
1903 echo "A .gitmodules" > $testroot/stdout.expected
1904 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
1905 git_show_head $testroot/repo >> $testroot/stdout.expected
1906 echo >> $testroot/stdout.expected
1908 (cd $testroot/wt && got update > $testroot/stdout)
1910 cmp -s $testroot/stdout.expected $testroot/stdout
1911 ret=$?
1912 if [ $ret -ne 0 ]; then
1913 diff -u $testroot/stdout.expected $testroot/stdout
1914 test_done "$testroot" "$ret"
1915 return 1
1918 (cd $testroot/wt && got status > $testroot/stdout)
1920 echo "M repo2" > $testroot/stdout.expected
1921 cmp -s $testroot/stdout.expected $testroot/stdout
1922 ret=$?
1923 if [ $ret -ne 0 ]; then
1924 diff -u $testroot/stdout.expected $testroot/stdout
1926 test_done "$testroot" "$ret"
1929 test_update_adds_symlink() {
1930 local testroot=`test_init update_adds_symlink`
1932 got checkout $testroot/repo $testroot/wt > /dev/null
1933 ret=$?
1934 if [ $ret -ne 0 ]; then
1935 echo "checkout failed unexpectedly" >&2
1936 test_done "$testroot" "$ret"
1937 return 1
1940 (cd $testroot/repo && ln -s alpha alpha.link)
1941 (cd $testroot/repo && ln -s epsilon epsilon.link)
1942 (cd $testroot/repo && ln -s /etc/passwd passwd.link)
1943 (cd $testroot/repo && ln -s ../beta epsilon/beta.link)
1944 (cd $testroot/repo && ln -s nonexistent nonexistent.link)
1945 (cd $testroot/repo && git add .)
1946 git_commit $testroot/repo -m "add symlinks"
1948 echo "A alpha.link" > $testroot/stdout.expected
1949 echo "A epsilon/beta.link" >> $testroot/stdout.expected
1950 echo "A epsilon.link" >> $testroot/stdout.expected
1951 echo "A nonexistent.link" >> $testroot/stdout.expected
1952 echo "A passwd.link" >> $testroot/stdout.expected
1953 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
1954 git_show_head $testroot/repo >> $testroot/stdout.expected
1955 echo >> $testroot/stdout.expected
1957 (cd $testroot/wt && got update > $testroot/stdout)
1959 cmp -s $testroot/stdout.expected $testroot/stdout
1960 ret=$?
1961 if [ $ret -ne 0 ]; then
1962 diff -u $testroot/stdout.expected $testroot/stdout
1963 test_done "$testroot" "$ret"
1964 return 1
1967 if ! [ -h $testroot/wt/alpha.link ]; then
1968 echo "alpha.link is not a symlink"
1969 test_done "$testroot" "1"
1970 return 1
1973 readlink $testroot/wt/alpha.link > $testroot/stdout
1974 echo "alpha" > $testroot/stdout.expected
1975 cmp -s $testroot/stdout.expected $testroot/stdout
1976 ret=$?
1977 if [ $ret -ne 0 ]; then
1978 diff -u $testroot/stdout.expected $testroot/stdout
1979 test_done "$testroot" "$ret"
1980 return 1
1983 if ! [ -h $testroot/wt/epsilon.link ]; then
1984 echo "epsilon.link is not a symlink"
1985 test_done "$testroot" "1"
1986 return 1
1989 readlink $testroot/wt/epsilon.link > $testroot/stdout
1990 echo "epsilon" > $testroot/stdout.expected
1991 cmp -s $testroot/stdout.expected $testroot/stdout
1992 ret=$?
1993 if [ $ret -ne 0 ]; then
1994 diff -u $testroot/stdout.expected $testroot/stdout
1995 test_done "$testroot" "$ret"
1996 return 1
1999 if [ -h $testroot/wt/passwd.link ]; then
2000 echo -n "passwd.link symlink points outside of work tree: " >&2
2001 readlink $testroot/wt/passwd.link >&2
2002 test_done "$testroot" "1"
2003 return 1
2006 echo -n "/etc/passwd" > $testroot/content.expected
2007 cp $testroot/wt/passwd.link $testroot/content
2009 cmp -s $testroot/content.expected $testroot/content
2010 ret=$?
2011 if [ $ret -ne 0 ]; then
2012 diff -u $testroot/content.expected $testroot/content
2013 test_done "$testroot" "$ret"
2014 return 1
2017 readlink $testroot/wt/epsilon/beta.link > $testroot/stdout
2018 echo "../beta" > $testroot/stdout.expected
2019 cmp -s $testroot/stdout.expected $testroot/stdout
2020 ret=$?
2021 if [ $ret -ne 0 ]; then
2022 diff -u $testroot/stdout.expected $testroot/stdout
2023 test_done "$testroot" "$ret"
2024 return 1
2027 readlink $testroot/wt/nonexistent.link > $testroot/stdout
2028 echo "nonexistent" > $testroot/stdout.expected
2029 cmp -s $testroot/stdout.expected $testroot/stdout
2030 ret=$?
2031 if [ $ret -ne 0 ]; then
2032 diff -u $testroot/stdout.expected $testroot/stdout
2033 test_done "$testroot" "$ret"
2034 return 1
2037 # Updating an up-to-date symlink should be a no-op.
2038 echo 'Already up-to-date' > $testroot/stdout.expected
2039 (cd $testroot/wt && got update > $testroot/stdout)
2040 cmp -s $testroot/stdout.expected $testroot/stdout
2041 ret=$?
2042 if [ $ret -ne 0 ]; then
2043 diff -u $testroot/stdout.expected $testroot/stdout
2045 test_done "$testroot" "$ret"
2048 test_update_deletes_symlink() {
2049 local testroot=`test_init update_deletes_symlink`
2051 (cd $testroot/repo && ln -s alpha alpha.link)
2052 (cd $testroot/repo && git add .)
2053 git_commit $testroot/repo -m "add symlink"
2055 got checkout $testroot/repo $testroot/wt > /dev/null
2056 ret=$?
2057 if [ $ret -ne 0 ]; then
2058 echo "checkout failed unexpectedly" >&2
2059 test_done "$testroot" "$ret"
2060 return 1
2063 (cd $testroot/repo && git rm -q alpha.link)
2064 git_commit $testroot/repo -m "delete symlink"
2066 echo "D alpha.link" > $testroot/stdout.expected
2067 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
2068 git_show_head $testroot/repo >> $testroot/stdout.expected
2069 echo >> $testroot/stdout.expected
2071 (cd $testroot/wt && got update > $testroot/stdout)
2073 cmp -s $testroot/stdout.expected $testroot/stdout
2074 ret=$?
2075 if [ $ret -ne 0 ]; then
2076 diff -u $testroot/stdout.expected $testroot/stdout
2077 test_done "$testroot" "$ret"
2078 return 1
2081 if [ -e $testroot/wt/alpha.link ]; then
2082 echo "alpha.link still exists on disk"
2083 test_done "$testroot" "1"
2084 return 1
2087 test_done "$testroot" "0"
2090 test_update_symlink_conflicts() {
2091 local testroot=`test_init update_symlink_conflicts`
2093 (cd $testroot/repo && ln -s alpha alpha.link)
2094 (cd $testroot/repo && ln -s epsilon epsilon.link)
2095 (cd $testroot/repo && ln -s /etc/passwd passwd.link)
2096 (cd $testroot/repo && ln -s ../beta epsilon/beta.link)
2097 (cd $testroot/repo && ln -s nonexistent nonexistent.link)
2098 (cd $testroot/repo && ln -sf epsilon/zeta zeta.link)
2099 (cd $testroot/repo && git add .)
2100 git_commit $testroot/repo -m "add symlinks"
2101 local commit_id1=`git_show_head $testroot/repo`
2103 got checkout $testroot/repo $testroot/wt > /dev/null
2104 ret=$?
2105 if [ $ret -ne 0 ]; then
2106 echo "checkout failed unexpectedly" >&2
2107 test_done "$testroot" "$ret"
2108 return 1
2111 (cd $testroot/repo && ln -sf beta alpha.link)
2112 (cd $testroot/repo && rm epsilon.link && ln -s gamma epsilon.link)
2113 (cd $testroot/repo && ln -sf ../gamma/delta epsilon/beta.link)
2114 echo 'this is regular file foo' > $testroot/repo/dotgotfoo.link
2115 (cd $testroot/repo && ln -sf .got/bar dotgotbar.link)
2116 (cd $testroot/repo && git rm -q nonexistent.link)
2117 (cd $testroot/repo && ln -sf gamma/delta zeta.link)
2118 (cd $testroot/repo && ln -sf alpha new.link)
2119 (cd $testroot/repo && git add .)
2120 git_commit $testroot/repo -m "change symlinks"
2121 local commit_id2=`git_show_head $testroot/repo`
2123 # modified symlink to file A vs modified symlink to file B
2124 (cd $testroot/wt && ln -sf gamma/delta alpha.link)
2125 # modified symlink to dir A vs modified symlink to file B
2126 (cd $testroot/wt && rm epsilon.link && ln -s beta epsilon.link)
2127 # modeified symlink to file A vs modified symlink to dir B
2128 (cd $testroot/wt && rm epsilon/beta.link && ln -s ../gamma \
2129 epsilon/beta.link)
2130 # added regular file A vs added bad symlink to file A
2131 (cd $testroot/wt && ln -sf .got/bar dotgotfoo.link)
2132 (cd $testroot/wt && got add dotgotfoo.link > /dev/null)
2133 # added bad symlink to file A vs added regular file A
2134 echo 'this is regular file bar' > $testroot/wt/dotgotbar.link
2135 (cd $testroot/wt && got add dotgotbar.link > /dev/null)
2136 # removed symlink to non-existent file A vs modified symlink
2137 # to nonexistent file B
2138 (cd $testroot/wt && ln -sf nonexistent2 nonexistent.link)
2139 # modified symlink to file A vs removed symlink to file A
2140 (cd $testroot/wt && got rm zeta.link > /dev/null)
2141 # added symlink to file A vs added symlink to file B
2142 (cd $testroot/wt && ln -sf beta new.link)
2143 (cd $testroot/wt && got add new.link > /dev/null)
2145 (cd $testroot/wt && got update > $testroot/stdout)
2147 echo "C alpha.link" >> $testroot/stdout.expected
2148 echo "C dotgotbar.link" >> $testroot/stdout.expected
2149 echo "C dotgotfoo.link" >> $testroot/stdout.expected
2150 echo "C epsilon/beta.link" >> $testroot/stdout.expected
2151 echo "C epsilon.link" >> $testroot/stdout.expected
2152 echo "C new.link" >> $testroot/stdout.expected
2153 echo "C nonexistent.link" >> $testroot/stdout.expected
2154 echo "G zeta.link" >> $testroot/stdout.expected
2155 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
2156 git_show_head $testroot/repo >> $testroot/stdout.expected
2157 echo >> $testroot/stdout.expected
2158 echo "Files with new merge conflicts: 7" >> $testroot/stdout.expected
2160 cmp -s $testroot/stdout.expected $testroot/stdout
2161 ret=$?
2162 if [ $ret -ne 0 ]; then
2163 diff -u $testroot/stdout.expected $testroot/stdout
2164 test_done "$testroot" "$ret"
2165 return 1
2168 if [ -h $testroot/wt/alpha.link ]; then
2169 echo "alpha.link is a symlink"
2170 test_done "$testroot" "1"
2171 return 1
2174 echo "<<<<<<< merged change: commit $commit_id2" \
2175 > $testroot/content.expected
2176 echo "beta" >> $testroot/content.expected
2177 echo "3-way merge base: commit $commit_id1" \
2178 >> $testroot/content.expected
2179 echo "alpha" >> $testroot/content.expected
2180 echo "=======" >> $testroot/content.expected
2181 echo "gamma/delta" >> $testroot/content.expected
2182 echo '>>>>>>>' >> $testroot/content.expected
2183 echo -n "" >> $testroot/content.expected
2185 cp $testroot/wt/alpha.link $testroot/content
2186 cmp -s $testroot/content.expected $testroot/content
2187 ret=$?
2188 if [ $ret -ne 0 ]; then
2189 diff -u $testroot/content.expected $testroot/content
2190 test_done "$testroot" "$ret"
2191 return 1
2194 if [ -h $testroot/wt/epsilon.link ]; then
2195 echo "epsilon.link is a symlink"
2196 test_done "$testroot" "1"
2197 return 1
2200 echo "<<<<<<< merged change: commit $commit_id2" \
2201 > $testroot/content.expected
2202 echo "gamma" >> $testroot/content.expected
2203 echo "3-way merge base: commit $commit_id1" \
2204 >> $testroot/content.expected
2205 echo "epsilon" >> $testroot/content.expected
2206 echo "=======" >> $testroot/content.expected
2207 echo "beta" >> $testroot/content.expected
2208 echo '>>>>>>>' >> $testroot/content.expected
2209 echo -n "" >> $testroot/content.expected
2211 cp $testroot/wt/epsilon.link $testroot/content
2212 cmp -s $testroot/content.expected $testroot/content
2213 ret=$?
2214 if [ $ret -ne 0 ]; then
2215 diff -u $testroot/content.expected $testroot/content
2216 test_done "$testroot" "$ret"
2217 return 1
2220 if [ -h $testroot/wt/passwd.link ]; then
2221 echo -n "passwd.link symlink points outside of work tree: " >&2
2222 readlink $testroot/wt/passwd.link >&2
2223 test_done "$testroot" "1"
2224 return 1
2227 echo -n "/etc/passwd" > $testroot/content.expected
2228 cp $testroot/wt/passwd.link $testroot/content
2230 cmp -s $testroot/content.expected $testroot/content
2231 ret=$?
2232 if [ $ret -ne 0 ]; then
2233 diff -u $testroot/content.expected $testroot/content
2234 test_done "$testroot" "$ret"
2235 return 1
2238 if [ -h $testroot/wt/epsilon/beta.link ]; then
2239 echo "epsilon/beta.link is a symlink"
2240 test_done "$testroot" "1"
2241 return 1
2244 echo "<<<<<<< merged change: commit $commit_id2" \
2245 > $testroot/content.expected
2246 echo "../gamma/delta" >> $testroot/content.expected
2247 echo "3-way merge base: commit $commit_id1" \
2248 >> $testroot/content.expected
2249 echo "../beta" >> $testroot/content.expected
2250 echo "=======" >> $testroot/content.expected
2251 echo "../gamma" >> $testroot/content.expected
2252 echo '>>>>>>>' >> $testroot/content.expected
2253 echo -n "" >> $testroot/content.expected
2255 cp $testroot/wt/epsilon/beta.link $testroot/content
2256 cmp -s $testroot/content.expected $testroot/content
2257 ret=$?
2258 if [ $ret -ne 0 ]; then
2259 diff -u $testroot/content.expected $testroot/content
2260 test_done "$testroot" "$ret"
2261 return 1
2264 if [ -h $testroot/wt/nonexistent.link ]; then
2265 echo -n "nonexistent.link still exists on disk: " >&2
2266 readlink $testroot/wt/nonexistent.link >&2
2267 test_done "$testroot" "1"
2268 return 1
2271 echo "<<<<<<< merged change: commit $commit_id2" \
2272 > $testroot/content.expected
2273 echo "(symlink was deleted)" >> $testroot/content.expected
2274 echo "=======" >> $testroot/content.expected
2275 echo "nonexistent2" >> $testroot/content.expected
2276 echo '>>>>>>>' >> $testroot/content.expected
2277 echo -n "" >> $testroot/content.expected
2279 cp $testroot/wt/nonexistent.link $testroot/content
2280 cmp -s $testroot/content.expected $testroot/content
2281 ret=$?
2282 if [ $ret -ne 0 ]; then
2283 diff -u $testroot/content.expected $testroot/content
2284 test_done "$testroot" "$ret"
2285 return 1
2288 if [ -h $testroot/wt/dotgotfoo.link ]; then
2289 echo "dotgotfoo.link is a symlink"
2290 test_done "$testroot" "1"
2291 return 1
2294 echo "<<<<<<< merged change: commit $commit_id2" \
2295 > $testroot/content.expected
2296 echo "this is regular file foo" >> $testroot/content.expected
2297 echo "=======" >> $testroot/content.expected
2298 echo -n ".got/bar" >> $testroot/content.expected
2299 echo '>>>>>>>' >> $testroot/content.expected
2300 echo -n "" >> $testroot/content.expected
2302 cp $testroot/wt/dotgotfoo.link $testroot/content
2303 cmp -s $testroot/content.expected $testroot/content
2304 ret=$?
2305 if [ $ret -ne 0 ]; then
2306 diff -u $testroot/content.expected $testroot/content
2307 test_done "$testroot" "$ret"
2308 return 1
2311 if [ -h $testroot/wt/dotgotbar.link ]; then
2312 echo "dotgotbar.link is a symlink"
2313 test_done "$testroot" "1"
2314 return 1
2316 echo "<<<<<<< merged change: commit $commit_id2" \
2317 > $testroot/content.expected
2318 echo -n ".got/bar" >> $testroot/content.expected
2319 echo "=======" >> $testroot/content.expected
2320 echo "this is regular file bar" >> $testroot/content.expected
2321 echo '>>>>>>>' >> $testroot/content.expected
2322 echo -n "" >> $testroot/content.expected
2324 cp $testroot/wt/dotgotbar.link $testroot/content
2325 cmp -s $testroot/content.expected $testroot/content
2326 ret=$?
2327 if [ $ret -ne 0 ]; then
2328 diff -u $testroot/content.expected $testroot/content
2329 test_done "$testroot" "$ret"
2330 return 1
2333 if [ -h $testroot/wt/new.link ]; then
2334 echo "new.link is a symlink"
2335 test_done "$testroot" "1"
2336 return 1
2339 echo "<<<<<<< merged change: commit $commit_id2" \
2340 > $testroot/content.expected
2341 echo "alpha" >> $testroot/content.expected
2342 echo "=======" >> $testroot/content.expected
2343 echo "beta" >> $testroot/content.expected
2344 echo '>>>>>>>' >> $testroot/content.expected
2345 echo -n "" >> $testroot/content.expected
2347 cp $testroot/wt/new.link $testroot/content
2348 cmp -s $testroot/content.expected $testroot/content
2349 ret=$?
2350 if [ $ret -ne 0 ]; then
2351 diff -u $testroot/content.expected $testroot/content
2352 test_done "$testroot" "$ret"
2353 return 1
2356 echo "A dotgotfoo.link" > $testroot/stdout.expected
2357 echo "M new.link" >> $testroot/stdout.expected
2358 echo "D nonexistent.link" >> $testroot/stdout.expected
2359 (cd $testroot/wt && got status > $testroot/stdout)
2360 ret=$?
2361 if [ $ret -ne 0 ]; then
2362 diff -u $testroot/stdout.expected $testroot/stdout
2363 test_done "$testroot" "$ret"
2364 return 1
2367 test_done "$testroot" "0"
2371 test_update_single_file() {
2372 local testroot=`test_init update_single_file 1`
2374 echo c1 > $testroot/repo/c
2375 (cd $testroot/repo && git add .)
2376 git_commit $testroot/repo -m "adding file c"
2377 local commit_id1=`git_show_head $testroot/repo`
2379 echo a > $testroot/repo/a
2380 echo b > $testroot/repo/b
2381 echo c2 > $testroot/repo/c
2382 (cd $testroot/repo && git add .)
2383 git_commit $testroot/repo -m "add files a and b, change c"
2384 local commit_id2=`git_show_head $testroot/repo`
2386 (cd $testroot/repo && git rm -qf c)
2387 git_commit $testroot/repo -m "remove file c"
2388 local commit_id3=`git_show_head $testroot/repo`
2390 got checkout -c $commit_id2 $testroot/repo $testroot/wt > /dev/null
2391 ret=$?
2392 if [ $ret -ne 0 ]; then
2393 test_done "$testroot" "$ret"
2394 return 1
2397 echo "U c" > $testroot/stdout.expected
2398 echo "Updated to refs/heads/master: $commit_id1" \
2399 >> $testroot/stdout.expected
2401 (cd $testroot/wt && got update -c $commit_id1 c \
2402 > $testroot/stdout)
2404 cmp -s $testroot/stdout.expected $testroot/stdout
2405 ret=$?
2406 if [ $ret -ne 0 ]; then
2407 diff -u $testroot/stdout.expected $testroot/stdout
2408 test_done "$testroot" "$ret"
2409 return 1
2412 echo c1 > $testroot/content.expected
2413 cat $testroot/wt/c > $testroot/content
2415 cmp -s $testroot/content.expected $testroot/content
2416 ret=$?
2417 if [ $ret -ne 0 ]; then
2418 diff -u $testroot/content.expected $testroot/content
2419 test_done "$testroot" "$ret"
2420 return 1
2423 echo "U c" > $testroot/stdout.expected
2424 echo "Updated to refs/heads/master: $commit_id2" \
2425 >> $testroot/stdout.expected
2427 (cd $testroot/wt && got update -c $commit_id2 c > $testroot/stdout)
2429 cmp -s $testroot/stdout.expected $testroot/stdout
2430 ret=$?
2431 if [ $ret -ne 0 ]; then
2432 diff -u $testroot/stdout.expected $testroot/stdout
2433 test_done "$testroot" "$ret"
2434 return 1
2437 echo c2 > $testroot/content.expected
2438 cat $testroot/wt/c > $testroot/content
2440 cmp -s $testroot/content.expected $testroot/content
2441 ret=$?
2442 if [ $ret -ne 0 ]; then
2443 diff -u $testroot/content.expected $testroot/content
2444 test_done "$testroot" "$ret"
2445 return 1
2448 echo "D c" > $testroot/stdout.expected
2449 echo "Updated to refs/heads/master: $commit_id3" \
2450 >> $testroot/stdout.expected
2452 (cd $testroot/wt && got update -c $commit_id3 c \
2453 > $testroot/stdout 2> $testroot/stderr)
2455 echo "got: /c: no such entry found in tree" > $testroot/stderr.expected
2456 cmp -s $testroot/stderr.expected $testroot/stderr
2457 ret=$?
2458 if [ $ret -ne 0 ]; then
2459 diff -u $testroot/stderr.expected $testroot/stderr
2460 test_done "$testroot" "$ret"
2461 return 1
2464 echo -n > $testroot/stdout.expected
2465 cmp -s $testroot/stdout.expected $testroot/stdout
2466 ret=$?
2467 if [ $ret -ne 0 ]; then
2468 diff -u $testroot/stdout.expected $testroot/stdout
2469 test_done "$testroot" "$ret"
2470 return 1
2473 echo "D c" > $testroot/stdout.expected
2474 echo "Updated to refs/heads/master: $commit_id3" \
2475 >> $testroot/stdout.expected
2477 (cd $testroot/wt && got update -c $commit_id3 > $testroot/stdout)
2478 cmp -s $testroot/stdout.expected $testroot/stdout
2479 ret=$?
2480 if [ $ret -ne 0 ]; then
2481 diff -u $testroot/stdout.expected $testroot/stdout
2482 test_done "$testroot" "$ret"
2483 return 1
2486 if [ -e $testroot/wt/c ]; then
2487 echo "removed file c still exists on disk" >&2
2488 test_done "$testroot" "1"
2489 return 1
2492 test_done "$testroot" "0"
2493 return 0
2496 test_update_file_skipped_due_to_conflict() {
2497 local testroot=`test_init update_file_skipped_due_to_conflict`
2498 local commit_id0=`git_show_head $testroot/repo`
2499 blob_id0=`get_blob_id $testroot/repo "" beta`
2501 echo "changed beta" > $testroot/repo/beta
2502 git_commit $testroot/repo -m "changed beta"
2503 local commit_id1=`git_show_head $testroot/repo`
2504 blob_id1=`get_blob_id $testroot/repo "" beta`
2506 got checkout $testroot/repo $testroot/wt > /dev/null
2507 ret=$?
2508 if [ $ret -ne 0 ]; then
2509 test_done "$testroot" "$ret"
2510 return 1
2513 blob_id=`(cd $testroot/wt && got info beta | grep 'blob:' | \
2514 cut -d ':' -f 2 | tr -d ' ')`
2515 if [ "$blob_id" != "$blob_id1" ]; then
2516 echo "file beta has the wrong base blob ID" >&2
2517 test_done "$testroot" "1"
2518 return 1
2521 commit_id=`(cd $testroot/wt && got info beta | \
2522 grep 'based on commit:' | cut -d ':' -f 2 | tr -d ' ')`
2523 if [ "$commit_id" != "$commit_id1" ]; then
2524 echo "file beta has the wrong base commit ID" >&2
2525 test_done "$testroot" "1"
2526 return 1
2529 echo "modified beta" > $testroot/wt/beta
2531 (cd $testroot/wt && got update -c $commit_id0 > $testroot/stdout)
2533 echo "C beta" > $testroot/stdout.expected
2534 echo "Updated to refs/heads/master: $commit_id0" \
2535 >> $testroot/stdout.expected
2536 echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
2537 cmp -s $testroot/stdout.expected $testroot/stdout
2538 ret=$?
2539 if [ $ret -ne 0 ]; then
2540 diff -u $testroot/stdout.expected $testroot/stdout
2541 test_done "$testroot" "$ret"
2542 return 1
2545 echo "<<<<<<< merged change: commit $commit_id0" \
2546 > $testroot/content.expected
2547 echo "beta" >> $testroot/content.expected
2548 echo "||||||| 3-way merge base: commit $commit_id1" \
2549 >> $testroot/content.expected
2550 echo "changed beta" >> $testroot/content.expected
2551 echo "=======" >> $testroot/content.expected
2552 echo "modified beta" >> $testroot/content.expected
2553 echo ">>>>>>>" >> $testroot/content.expected
2555 cat $testroot/wt/beta > $testroot/content
2557 cmp -s $testroot/content.expected $testroot/content
2558 ret=$?
2559 if [ $ret -ne 0 ]; then
2560 diff -u $testroot/content.expected $testroot/content
2561 test_done "$testroot" "$ret"
2562 return 1
2565 blob_id=`(cd $testroot/wt && got info beta | grep 'blob:' | \
2566 cut -d ':' -f 2 | tr -d ' ')`
2567 if [ "$blob_id" != "$blob_id0" ]; then
2568 echo "file beta has the wrong base blob ID" >&2
2569 test_done "$testroot" "1"
2570 return 1
2573 commit_id=`(cd $testroot/wt && got info beta | \
2574 grep 'based on commit:' | cut -d ':' -f 2 | tr -d ' ')`
2575 if [ "$commit_id" != "$commit_id0" ]; then
2576 echo "file beta has the wrong base commit ID" >&2
2577 test_done "$testroot" "1"
2578 return 1
2581 # update to the latest commit again; this skips beta
2582 (cd $testroot/wt && got update > $testroot/stdout)
2583 echo "# beta" > $testroot/stdout.expected
2584 echo "Updated to refs/heads/master: $commit_id1" \
2585 >> $testroot/stdout.expected
2586 echo "Files not updated because of existing merge conflicts: 1" \
2587 >> $testroot/stdout.expected
2588 cmp -s $testroot/stdout.expected $testroot/stdout
2589 ret=$?
2590 if [ $ret -ne 0 ]; then
2591 diff -u $testroot/stdout.expected $testroot/stdout
2592 test_done "$testroot" "$ret"
2593 return 1
2596 # blob ID of beta should not have changed
2597 blob_id=`(cd $testroot/wt && got info beta | grep 'blob:' | \
2598 cut -d ':' -f 2 | tr -d ' ')`
2599 if [ "$blob_id" != "$blob_id0" ]; then
2600 echo "file beta has the wrong base blob ID" >&2
2601 test_done "$testroot" "1"
2602 return 1
2605 # commit ID of beta should not have changed; There was a bug
2606 # here where the commit ID had been changed even though the
2607 # file was not updated.
2608 commit_id=`(cd $testroot/wt && got info beta | \
2609 grep 'based on commit:' | cut -d ':' -f 2 | tr -d ' ')`
2610 if [ "$commit_id" != "$commit_id0" ]; then
2611 echo "file beta has the wrong base commit ID: $commit_id" >&2
2612 test_done "$testroot" "1"
2613 return 1
2616 # beta is still conflicted and based on commit 0
2617 echo 'C beta' > $testroot/stdout.expected
2618 (cd $testroot/wt && got status > $testroot/stdout)
2619 cmp -s $testroot/stdout.expected $testroot/stdout
2620 ret=$?
2621 if [ $ret -ne 0 ]; then
2622 diff -u $testroot/stdout.expected $testroot/stdout
2623 test_done "$testroot" "$ret"
2624 return 1
2627 # resolve the conflict via revert
2628 (cd $testroot/wt && got revert beta >/dev/null)
2630 # beta now matches its base blob which is still from commit 0
2631 echo "beta" > $testroot/content.expected
2632 cat $testroot/wt/beta > $testroot/content
2633 cmp -s $testroot/content.expected $testroot/content
2634 ret=$?
2635 if [ $ret -ne 0 ]; then
2636 diff -u $testroot/content.expected $testroot/content
2637 test_done "$testroot" "$ret"
2638 return 1
2641 # updating to the latest commit should now update beta
2642 (cd $testroot/wt && got update > $testroot/stdout)
2643 echo "U beta" > $testroot/stdout.expected
2644 echo "Updated to refs/heads/master: $commit_id1" \
2645 >> $testroot/stdout.expected
2646 cmp -s $testroot/stdout.expected $testroot/stdout
2647 ret=$?
2648 if [ $ret -ne 0 ]; then
2649 diff -u $testroot/stdout.expected $testroot/stdout
2650 test_done "$testroot" "$ret"
2651 return 1
2654 blob_id=`(cd $testroot/wt && got info beta | grep 'blob:' | \
2655 cut -d ':' -f 2 | tr -d ' ')`
2656 if [ "$blob_id" != "$blob_id1" ]; then
2657 echo "file beta has the wrong base blob ID" >&2
2658 test_done "$testroot" "1"
2659 return 1
2662 commit_id=`(cd $testroot/wt && got info beta | \
2663 grep 'based on commit:' | cut -d ':' -f 2 | tr -d ' ')`
2664 if [ "$commit_id" != "$commit_id1" ]; then
2665 echo "file beta has the wrong base commit ID: $commit_id" >&2
2666 test_done "$testroot" "1"
2667 return 1
2670 echo "changed beta" > $testroot/content.expected
2671 cat $testroot/wt/beta > $testroot/content
2672 cmp -s $testroot/content.expected $testroot/content
2673 ret=$?
2674 if [ $ret -ne 0 ]; then
2675 diff -u $testroot/content.expected $testroot/content
2677 test_done "$testroot" "$ret"
2680 test_update_file_skipped_due_to_obstruction() {
2681 local testroot=`test_init update_file_skipped_due_to_obstruction`
2682 local commit_id0=`git_show_head $testroot/repo`
2683 blob_id0=`get_blob_id $testroot/repo "" beta`
2685 echo "changed beta" > $testroot/repo/beta
2686 echo "new file" > $testroot/repo/new
2687 (cd $testroot/repo && git add new)
2688 git_commit $testroot/repo -m "changed beta"
2689 local commit_id1=`git_show_head $testroot/repo`
2690 blob_id1=`get_blob_id $testroot/repo "" beta`
2692 got checkout -c $commit_id0 $testroot/repo $testroot/wt > /dev/null
2693 ret=$?
2694 if [ $ret -ne 0 ]; then
2695 test_done "$testroot" "$ret"
2696 return 1
2699 blob_id=`(cd $testroot/wt && got info beta | grep 'blob:' | \
2700 cut -d ':' -f 2 | tr -d ' ')`
2701 if [ "$blob_id" != "$blob_id0" ]; then
2702 echo "file beta has the wrong base blob ID" >&2
2703 test_done "$testroot" "1"
2704 return 1
2707 commit_id=`(cd $testroot/wt && got info beta | \
2708 grep 'based on commit:' | cut -d ':' -f 2 | tr -d ' ')`
2709 if [ "$commit_id" != "$commit_id0" ]; then
2710 echo "file beta has the wrong base commit ID" >&2
2711 test_done "$testroot" "1"
2712 return 1
2715 rm $testroot/wt/beta
2716 mkdir -p $testroot/wt/beta/psi
2717 mkdir -p $testroot/wt/new
2719 # update to the latest commit; this skips beta and the new file
2720 (cd $testroot/wt && got update > $testroot/stdout)
2721 ret=$?
2722 if [ $ret -ne 0 ]; then
2723 echo "update failed unexpectedly" >&2
2724 test_done "$testroot" "1"
2725 return 1
2728 echo "~ beta" > $testroot/stdout.expected
2729 echo "~ new" >> $testroot/stdout.expected
2730 echo "Updated to refs/heads/master: $commit_id1" \
2731 >> $testroot/stdout.expected
2732 echo "File paths obstructed by a non-regular file: 2" \
2733 >> $testroot/stdout.expected
2734 cmp -s $testroot/stdout.expected $testroot/stdout
2735 ret=$?
2736 if [ $ret -ne 0 ]; then
2737 diff -u $testroot/stdout.expected $testroot/stdout
2738 test_done "$testroot" "$ret"
2739 return 1
2742 blob_id=`(cd $testroot/wt && got info beta | grep 'blob:' | \
2743 cut -d ':' -f 2 | tr -d ' ')`
2744 if [ "$blob_id" != "$blob_id0" ]; then
2745 echo "file beta has the wrong base blob ID" >&2
2746 test_done "$testroot" "1"
2747 return 1
2750 commit_id=`(cd $testroot/wt && got info beta | \
2751 grep 'based on commit:' | cut -d ':' -f 2 | tr -d ' ')`
2752 if [ "$commit_id" != "$commit_id0" ]; then
2753 echo "file beta has the wrong base commit ID" >&2
2754 test_done "$testroot" "1"
2755 return 1
2758 # remove the directory which obstructs file beta
2759 rm -r $testroot/wt/beta
2761 # updating to the latest commit should now update beta
2762 (cd $testroot/wt && got update > $testroot/stdout)
2763 echo "! beta" > $testroot/stdout.expected
2764 echo "~ new" >> $testroot/stdout.expected
2765 echo "Updated to refs/heads/master: $commit_id1" \
2766 >> $testroot/stdout.expected
2767 echo "File paths obstructed by a non-regular file: 1" \
2768 >> $testroot/stdout.expected
2769 cmp -s $testroot/stdout.expected $testroot/stdout
2770 ret=$?
2771 if [ $ret -ne 0 ]; then
2772 diff -u $testroot/stdout.expected $testroot/stdout
2773 test_done "$testroot" "$ret"
2774 return 1
2777 blob_id=`(cd $testroot/wt && got info beta | grep 'blob:' | \
2778 cut -d ':' -f 2 | tr -d ' ')`
2779 if [ "$blob_id" != "$blob_id1" ]; then
2780 echo "file beta has the wrong base blob ID" >&2
2781 test_done "$testroot" "1"
2782 return 1
2785 commit_id=`(cd $testroot/wt && got info beta | \
2786 grep 'based on commit:' | cut -d ':' -f 2 | tr -d ' ')`
2787 if [ "$commit_id" != "$commit_id1" ]; then
2788 echo "file beta has the wrong base commit ID: $commit_id" >&2
2789 test_done "$testroot" "1"
2790 return 1
2793 echo "changed beta" > $testroot/content.expected
2794 cat $testroot/wt/beta > $testroot/content
2795 cmp -s $testroot/content.expected $testroot/content
2796 ret=$?
2797 if [ $ret -ne 0 ]; then
2798 diff -u $testroot/content.expected $testroot/content
2800 test_done "$testroot" "$ret"
2803 test_update_quiet() {
2804 local testroot=`test_init update_quiet`
2806 got checkout $testroot/repo $testroot/wt > /dev/null
2807 ret=$?
2808 if [ $ret -ne 0 ]; then
2809 test_done "$testroot" "$ret"
2810 return 1
2813 echo "modified alpha" > $testroot/repo/alpha
2814 git_commit $testroot/repo -m "modified alpha"
2816 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
2817 git_show_head $testroot/repo >> $testroot/stdout.expected
2818 echo >> $testroot/stdout.expected
2820 (cd $testroot/wt && got update -q > $testroot/stdout)
2822 cmp -s $testroot/stdout.expected $testroot/stdout
2823 ret=$?
2824 if [ $ret -ne 0 ]; then
2825 diff -u $testroot/stdout.expected $testroot/stdout
2826 test_done "$testroot" "$ret"
2827 return 1
2830 echo "modified alpha" > $testroot/content.expected
2831 cat $testroot/wt/alpha > $testroot/content
2833 cmp -s $testroot/content.expected $testroot/content
2834 ret=$?
2835 if [ $ret -ne 0 ]; then
2836 diff -u $testroot/content.expected $testroot/content
2838 test_done "$testroot" "$ret"
2841 test_update_binary_file() {
2842 local testroot=`test_init update_binary_file`
2843 local commit_id0=`git_show_head $testroot/repo`
2845 got checkout $testroot/repo $testroot/wt > /dev/null
2846 ret=$?
2847 if [ $ret -ne 0 ]; then
2848 test_done "$testroot" "$ret"
2849 return 1
2852 cp /bin/ls $testroot/wt/foo
2853 chmod 755 $testroot/wt/foo
2854 (cd $testroot/wt && got add foo >/dev/null)
2855 (cd $testroot/wt && got commit -m 'add binary file' > /dev/null)
2856 local commit_id1=`git_show_head $testroot/repo`
2858 cp /bin/cat $testroot/wt/foo
2859 chmod 755 $testroot/wt/foo
2860 (cd $testroot/wt && got commit -m 'change binary file' > /dev/null)
2861 local commit_id2=`git_show_head $testroot/repo`
2863 cp /bin/cp $testroot/wt/foo
2864 chmod 755 $testroot/wt/foo
2865 (cd $testroot/wt && got commit -m 'change binary file' > /dev/null)
2866 local commit_id3=`git_show_head $testroot/repo`
2868 (cd $testroot/wt && got rm foo >/dev/null)
2869 (cd $testroot/wt && got commit -m 'remove binary file' > /dev/null)
2870 local commit_id4=`git_show_head $testroot/repo`
2872 # backdate the work tree to make it usable for updating
2873 (cd $testroot/wt && got up -c $commit_id0 > /dev/null)
2875 # update which adds a binary file
2876 (cd $testroot/wt && got up -c $commit_id1 > $testroot/stdout)
2878 echo "A foo" > $testroot/stdout.expected
2879 echo -n "Updated to refs/heads/master: $commit_id1" \
2880 >> $testroot/stdout.expected
2881 echo >> $testroot/stdout.expected
2882 cmp -s $testroot/stdout.expected $testroot/stdout
2883 ret=$?
2884 if [ $ret -ne 0 ]; then
2885 diff -u $testroot/stdout.expected $testroot/stdout
2886 test_done "$testroot" "$ret"
2887 return 1
2890 cp /bin/ls $testroot/content.expected
2891 chmod 755 $testroot/content.expected
2892 cat $testroot/wt/foo > $testroot/content
2894 cmp -s $testroot/content.expected $testroot/content
2895 ret=$?
2896 if [ $ret -ne 0 ]; then
2897 diff -u $testroot/content.expected $testroot/content
2898 test_done "$testroot" "$ret"
2899 return 1
2902 # update which adds a conflicting binary file
2903 (cd $testroot/wt && got up -c $commit_id0 > /dev/null)
2904 cp /bin/cat $testroot/wt/foo
2905 chmod 755 $testroot/wt/foo
2906 (cd $testroot/wt && got add foo > /dev/null)
2907 (cd $testroot/wt && got up -c $commit_id1 > $testroot/stdout)
2909 echo "C foo" > $testroot/stdout.expected
2910 echo "Updated to refs/heads/master: $commit_id1" \
2911 >> $testroot/stdout.expected
2912 echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
2913 cmp -s $testroot/stdout.expected $testroot/stdout
2914 ret=$?
2915 if [ $ret -ne 0 ]; then
2916 diff -u $testroot/stdout.expected $testroot/stdout
2917 test_done "$testroot" "$ret"
2918 return 1
2921 echo "Binary files differ and cannot be merged automatically:" \
2922 > $testroot/content.expected
2923 echo "<<<<<<< merged change: commit $commit_id1" \
2924 >> $testroot/content.expected
2925 echo -n "file " >> $testroot/content.expected
2926 ls $testroot/wt/foo-1-* >> $testroot/content.expected
2927 echo '=======' >> $testroot/content.expected
2928 echo -n "file " >> $testroot/content.expected
2929 ls $testroot/wt/foo-2-* >> $testroot/content.expected
2930 echo ">>>>>>>" >> $testroot/content.expected
2931 cat $testroot/wt/foo > $testroot/content
2933 cmp -s $testroot/content.expected $testroot/content
2934 ret=$?
2935 if [ $ret -ne 0 ]; then
2936 diff -u $testroot/content.expected $testroot/content
2937 test_done "$testroot" "$ret"
2938 return 1
2941 cp /bin/ls $testroot/content.expected
2942 chmod 755 $testroot/content.expected
2943 cat $testroot/wt/foo-1-* > $testroot/content
2945 cmp -s $testroot/content.expected $testroot/content
2946 ret=$?
2947 if [ $ret -ne 0 ]; then
2948 diff -u $testroot/content.expected $testroot/content
2949 test_done "$testroot" "$ret"
2950 return 1
2953 cp /bin/cat $testroot/content.expected
2954 chmod 755 $testroot/content.expected
2955 cat $testroot/wt/foo-2-* > $testroot/content
2957 cmp -s $testroot/content.expected $testroot/content
2958 ret=$?
2959 if [ $ret -ne 0 ]; then
2960 diff -u $testroot/content.expected $testroot/content
2961 test_done "$testroot" "$ret"
2962 return 1
2965 # tidy up
2966 (cd $testroot/wt && got revert -R . >/dev/null)
2967 rm $testroot/wt/foo-1-* $testroot/wt/foo-2-*
2968 (cd $testroot/wt && got up -c $commit_id1 > /dev/null)
2970 # update which changes a binary file
2971 (cd $testroot/wt && got up -c $commit_id2 > $testroot/stdout)
2973 echo "U foo" > $testroot/stdout.expected
2974 echo -n "Updated to refs/heads/master: $commit_id2" \
2975 >> $testroot/stdout.expected
2976 echo >> $testroot/stdout.expected
2977 cmp -s $testroot/stdout.expected $testroot/stdout
2978 ret=$?
2979 if [ $ret -ne 0 ]; then
2980 diff -u $testroot/stdout.expected $testroot/stdout
2981 test_done "$testroot" "$ret"
2982 return 1
2985 cp /bin/cat $testroot/content.expected
2986 chmod 755 $testroot/content.expected
2987 cat $testroot/wt/foo > $testroot/content
2989 cmp -s $testroot/content.expected $testroot/content
2990 ret=$?
2991 if [ $ret -ne 0 ]; then
2992 diff -u $testroot/content.expected $testroot/content
2993 test_done "$testroot" "$ret"
2994 return 1
2997 # update which changes a locally modified binary file
2998 cp /bin/ls $testroot/wt/foo
2999 chmod 755 $testroot/wt/foo
3000 (cd $testroot/wt && got up -c $commit_id3 > $testroot/stdout)
3002 echo "C foo" > $testroot/stdout.expected
3003 echo -n "Updated to refs/heads/master: $commit_id3" \
3004 >> $testroot/stdout.expected
3005 echo >> $testroot/stdout.expected
3006 echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
3007 cmp -s $testroot/stdout.expected $testroot/stdout
3008 ret=$?
3009 if [ $ret -ne 0 ]; then
3010 diff -u $testroot/stdout.expected $testroot/stdout
3011 test_done "$testroot" "$ret"
3012 return 1
3015 echo "Binary files differ and cannot be merged automatically:" \
3016 > $testroot/content.expected
3017 echo "<<<<<<< merged change: commit $commit_id3" \
3018 >> $testroot/content.expected
3019 echo -n "file " >> $testroot/content.expected
3020 ls $testroot/wt/foo-1-* >> $testroot/content.expected
3021 echo "||||||| 3-way merge base: commit $commit_id2" \
3022 >> $testroot/content.expected
3023 echo -n "file " >> $testroot/content.expected
3024 ls $testroot/wt/foo-orig-* >> $testroot/content.expected
3025 echo '=======' >> $testroot/content.expected
3026 echo -n "file " >> $testroot/content.expected
3027 ls $testroot/wt/foo-2-* >> $testroot/content.expected
3028 echo ">>>>>>>" >> $testroot/content.expected
3029 cat $testroot/wt/foo > $testroot/content
3031 cmp -s $testroot/content.expected $testroot/content
3032 ret=$?
3033 if [ $ret -ne 0 ]; then
3034 diff -u $testroot/content.expected $testroot/content
3035 test_done "$testroot" "$ret"
3036 return 1
3039 cp /bin/cp $testroot/content.expected
3040 chmod 755 $testroot/content.expected
3041 cp $testroot/wt/foo-1-* $testroot/content
3042 cmp -s $testroot/content.expected $testroot/content
3043 ret=$?
3044 if [ $ret -ne 0 ]; then
3045 diff -u $testroot/content.expected $testroot/content
3046 test_done "$testroot" "$ret"
3047 return 1
3050 cp /bin/ls $testroot/content.expected
3051 chmod 755 $testroot/content.expected
3052 cp $testroot/wt/foo-2-* $testroot/content
3053 cmp -s $testroot/content.expected $testroot/content
3054 ret=$?
3055 if [ $ret -ne 0 ]; then
3056 diff -u $testroot/content.expected $testroot/content
3057 test_done "$testroot" "$ret"
3058 return 1
3061 (cd $testroot/wt && got status > $testroot/stdout)
3062 echo 'C foo' > $testroot/stdout.expected
3063 echo -n '? ' >> $testroot/stdout.expected
3064 (cd $testroot/wt && ls foo-1-* >> $testroot/stdout.expected)
3065 echo -n '? ' >> $testroot/stdout.expected
3066 (cd $testroot/wt && ls foo-2-* >> $testroot/stdout.expected)
3067 echo -n '? ' >> $testroot/stdout.expected
3068 (cd $testroot/wt && ls foo-orig-* >> $testroot/stdout.expected)
3069 cmp -s $testroot/stdout.expected $testroot/stdout
3070 ret=$?
3071 if [ $ret -ne 0 ]; then
3072 diff -u $testroot/stdout.expected $testroot/stdout
3073 test_done "$testroot" "$ret"
3074 return 1
3077 # tidy up
3078 (cd $testroot/wt && got revert -R . > /dev/null)
3079 rm $testroot/wt/foo-orig-* $testroot/wt/foo-1-* $testroot/wt/foo-2-*
3081 # update which deletes a binary file
3082 (cd $testroot/wt && got up -c $commit_id4 > $testroot/stdout)
3083 echo "D foo" > $testroot/stdout.expected
3084 echo -n "Updated to refs/heads/master: $commit_id4" \
3085 >> $testroot/stdout.expected
3086 echo >> $testroot/stdout.expected
3087 cmp -s $testroot/stdout.expected $testroot/stdout
3088 ret=$?
3089 if [ $ret -ne 0 ]; then
3090 diff -u $testroot/stdout.expected $testroot/stdout
3091 test_done "$testroot" "$ret"
3094 if [ -e $testroot/wt/foo ]; then
3095 echo "removed file foo still exists on disk" >&2
3096 test_done "$testroot" "1"
3097 return 1
3099 test_done "$testroot" "0"
3102 test_update_umask() {
3103 local testroot=`test_init update_binary_file`
3105 got checkout "$testroot/repo" "$testroot/wt" >/dev/null
3106 ret=$?
3107 if [ $ret -ne 0 ]; then
3108 test_done "$testroot" "$ret"
3109 return 1
3112 rm "$testroot/wt/alpha"
3114 # using a subshell to avoid clobbering global umask
3115 (umask 022 && cd "$testroot/wt" && got update alpha) \
3116 >/dev/null 2>/dev/null
3117 ret=$?
3118 if [ $ret -ne 0 ]; then
3119 test_done "$testroot" $ret
3120 return 1
3123 if ! ls -l "$testroot/wt/alpha" | grep -q ^-rw-r--r--; then
3124 echo "alpha is not 0644" >&2
3125 test_done "$testroot" 1
3126 return 1
3129 rm "$testroot/wt/alpha"
3131 # using a subshell to avoid clobbering global umask
3132 (umask 044 && cd "$testroot/wt" && got update alpha) \
3133 >/dev/null 2>/dev/null
3134 ret=$?
3135 if [ $ret -ne 0 ]; then
3136 test_done "$testroot" $ret
3137 return 1
3140 if ! ls -l "$testroot/wt/alpha" | grep -q ^-rw-------; then
3141 echo "alpha is not 0600" >&2
3142 test_done "$testroot" 1
3143 return 1
3146 rm "$testroot/wt/alpha"
3148 # using a subshell to avoid clobbering global umask
3149 (umask 222 && cd "$testroot/wt" && got update alpha) \
3150 >/dev/null 2>/dev/null
3151 ret=$?
3152 if [ $ret -ne 0 ]; then
3153 test_done "$testroot" $ret
3154 return 1
3157 if ! ls -l "$testroot/wt/alpha" | grep -q ^-r--r--r--; then
3158 echo "alpha is not 0444" >&2
3159 test_done "$testroot" 1
3160 return 1;
3163 test_done "$testroot" 0
3166 test_parseargs "$@"
3167 run_test test_update_basic
3168 run_test test_update_adds_file
3169 run_test test_update_deletes_file
3170 run_test test_update_deletes_dir
3171 run_test test_update_deletes_dir_with_path_prefix
3172 run_test test_update_deletes_dir_recursively
3173 run_test test_update_sibling_dirs_with_common_prefix
3174 run_test test_update_dir_with_dot_sibling
3175 run_test test_update_moves_files_upwards
3176 run_test test_update_moves_files_to_new_dir
3177 run_test test_update_creates_missing_parent
3178 run_test test_update_creates_missing_parent_with_subdir
3179 run_test test_update_file_in_subsubdir
3180 run_test test_update_changes_file_to_dir
3181 run_test test_update_changes_modified_file_to_dir
3182 run_test test_update_merges_file_edits
3183 run_test test_update_keeps_xbit
3184 run_test test_update_clears_xbit
3185 run_test test_update_restores_missing_file
3186 run_test test_update_conflict_wt_add_vs_repo_add
3187 run_test test_update_conflict_wt_edit_vs_repo_rm
3188 run_test test_update_conflict_wt_rm_vs_repo_edit
3189 run_test test_update_conflict_wt_rm_vs_repo_rm
3190 run_test test_update_partial
3191 run_test test_update_partial_add
3192 run_test test_update_partial_rm
3193 run_test test_update_partial_dir
3194 run_test test_update_moved_branch_ref
3195 run_test test_update_to_another_branch
3196 run_test test_update_to_commit_on_wrong_branch
3197 run_test test_update_bumps_base_commit_id
3198 run_test test_update_tag
3199 run_test test_update_toggles_xbit
3200 run_test test_update_preserves_conflicted_file
3201 run_test test_update_modified_submodules
3202 run_test test_update_adds_submodule
3203 run_test test_update_conflict_wt_file_vs_repo_submodule
3204 run_test test_update_adds_symlink
3205 run_test test_update_deletes_symlink
3206 run_test test_update_symlink_conflicts
3207 run_test test_update_single_file
3208 run_test test_update_file_skipped_due_to_conflict
3209 run_test test_update_file_skipped_due_to_obstruction
3210 run_test test_update_quiet
3211 run_test test_update_binary_file
3212 run_test test_update_umask