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_dir_to_file() {
678 local testroot=`test_init update_changes_dir_to_file`
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_rmdir $testroot/repo epsilon
688 echo epsilon > $testroot/repo/epsilon
689 cp $testroot/repo/epsilon $testroot/content.expected
690 (cd $testroot/repo && git add epsilon)
691 git_commit $testroot/repo -m "changed epsilon into file"
693 (cd $testroot/wt && got update > $testroot/stdout 2> $testroot/stderr)
694 ret=$?
695 if [ $ret -ne 0 ]; then
696 echo "update failed unexpectedly" >&2
697 test_done "$testroot" "1"
698 return 1
699 fi
701 # The current behaviour is not perfect, but we accept it for now.
702 echo "~ epsilon" > $testroot/stdout.expected
703 echo "D epsilon/zeta" >> $testroot/stdout.expected
704 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
705 git_show_head $testroot/repo >> $testroot/stdout.expected
706 echo >> $testroot/stdout.expected
707 echo "File paths obstructed by a non-regular file: 1" \
708 >> $testroot/stdout.expected
710 cmp -s $testroot/stdout.expected $testroot/stdout
711 ret=$?
712 if [ $ret -ne 0 ]; then
713 diff -u $testroot/stdout.expected $testroot/stdout
714 test_done "$testroot" "$ret"
715 return 1
716 fi
718 # Updating again now restores the file which was obstructed by a
719 # directory in the previous update operation. Ideally, a single
720 # update operation would suffice.
721 (cd $testroot/wt && got update > $testroot/stdout 2> $testroot/stderr)
722 ret=$?
723 if [ $ret -ne 0 ]; then
724 echo "update failed unexpectedly" >&2
725 test_done "$testroot" "1"
726 return 1
727 fi
728 echo "A epsilon" > $testroot/stdout.expected
729 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
730 git_show_head $testroot/repo >> $testroot/stdout.expected
731 echo >> $testroot/stdout.expected
733 cmp -s $testroot/stdout.expected $testroot/stdout
734 ret=$?
735 if [ $ret -ne 0 ]; then
736 diff -u $testroot/stdout.expected $testroot/stdout
737 test_done "$testroot" "$ret"
738 return 1
739 fi
741 cmp -s $testroot/content.expected $testroot/wt/epsilon
742 ret=$?
743 if [ $ret -ne 0 ]; then
744 diff -u $testroot/content.expected $testroot/wt/epsilon
745 fi
746 test_done "$testroot" "$ret"
749 test_update_changes_modified_file_to_dir() {
750 local testroot=`test_init update_changes_modified_file_to_dir`
752 got checkout $testroot/repo $testroot/wt > /dev/null
753 ret=$?
754 if [ $ret -ne 0 ]; then
755 test_done "$testroot" "$ret"
756 return 1
757 fi
759 git_rm $testroot/repo alpha
760 mkdir $testroot/repo/alpha
761 echo eta > $testroot/repo/alpha/eta
762 (cd $testroot/repo && git add alpha/eta)
763 git_commit $testroot/repo -m "changed alpha into directory"
765 echo "modified alpha" >> $testroot/wt/alpha
766 cp $testroot/wt/alpha $testroot/wt/content.expected
767 (cd $testroot/wt && got update > $testroot/stdout 2> $testroot/stderr)
768 ret=$?
769 if [ $ret -eq 0 ]; then
770 echo "update succeeded unexpectedly" >&2
771 test_done "$testroot" "1"
772 return 1
773 fi
775 echo "d alpha" > $testroot/stdout.expected
776 cmp -s $testroot/stdout.expected $testroot/stdout
777 ret=$?
778 if [ $ret -ne 0 ]; then
779 diff -u $testroot/stdout.expected $testroot/stdout
780 test_done "$testroot" "$ret"
781 return 1
782 fi
784 echo "got: alpha/eta: file is obstructed" > $testroot/stderr.expected
785 cmp -s $testroot/stderr.expected $testroot/stderr
786 ret=$?
787 if [ $ret -ne 0 ]; then
788 diff -u $testroot/stderr.expected $testroot/stderr
789 fi
790 test_done "$testroot" "$ret"
793 test_update_merges_file_edits() {
794 local testroot=`test_init update_merges_file_edits`
796 echo "1" > $testroot/repo/numbers
797 echo "2" >> $testroot/repo/numbers
798 echo "3" >> $testroot/repo/numbers
799 echo "4" >> $testroot/repo/numbers
800 echo "5" >> $testroot/repo/numbers
801 echo "6" >> $testroot/repo/numbers
802 echo "7" >> $testroot/repo/numbers
803 echo "8" >> $testroot/repo/numbers
804 (cd $testroot/repo && git add numbers)
805 git_commit $testroot/repo -m "added numbers file"
806 local base_commit=`git_show_head $testroot/repo`
808 got checkout $testroot/repo $testroot/wt > /dev/null
809 ret=$?
810 if [ $ret -ne 0 ]; then
811 test_done "$testroot" "$ret"
812 return 1
813 fi
815 echo "modified alpha" > $testroot/repo/alpha
816 echo "modified beta" > $testroot/repo/beta
817 ed -s $testroot/repo/numbers <<-\EOF
818 ,s/2/22/
820 EOF
821 git_commit $testroot/repo -m "modified 3 files"
823 echo "modified alpha, too" > $testroot/wt/alpha
824 touch $testroot/wt/beta
825 ed -s $testroot/wt/numbers <<-\EOF
826 ,s/7/77/
828 EOF
830 echo "C alpha" > $testroot/stdout.expected
831 echo "U beta" >> $testroot/stdout.expected
832 echo "G numbers" >> $testroot/stdout.expected
833 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
834 git_show_head $testroot/repo >> $testroot/stdout.expected
835 echo >> $testroot/stdout.expected
836 echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
838 (cd $testroot/wt && got update > $testroot/stdout)
840 cmp -s $testroot/stdout.expected $testroot/stdout
841 ret=$?
842 if [ $ret -ne 0 ]; then
843 diff -u $testroot/stdout.expected $testroot/stdout
844 test_done "$testroot" "$ret"
845 return 1
846 fi
848 echo -n "<<<<<<< merged change: commit " > $testroot/content.expected
849 git_show_head $testroot/repo >> $testroot/content.expected
850 echo >> $testroot/content.expected
851 echo "modified alpha" >> $testroot/content.expected
852 echo "||||||| 3-way merge base: commit $base_commit" \
853 >> $testroot/content.expected
854 echo "alpha" >> $testroot/content.expected
855 echo "=======" >> $testroot/content.expected
856 echo "modified alpha, too" >> $testroot/content.expected
857 echo '>>>>>>>' >> $testroot/content.expected
858 echo "modified beta" >> $testroot/content.expected
859 echo "1" >> $testroot/content.expected
860 echo "22" >> $testroot/content.expected
861 echo "3" >> $testroot/content.expected
862 echo "4" >> $testroot/content.expected
863 echo "5" >> $testroot/content.expected
864 echo "6" >> $testroot/content.expected
865 echo "77" >> $testroot/content.expected
866 echo "8" >> $testroot/content.expected
868 cat $testroot/wt/alpha > $testroot/content
869 cat $testroot/wt/beta >> $testroot/content
870 cat $testroot/wt/numbers >> $testroot/content
872 cmp -s $testroot/content.expected $testroot/content
873 ret=$?
874 if [ $ret -ne 0 ]; then
875 diff -u $testroot/content.expected $testroot/content
876 fi
877 test_done "$testroot" "$ret"
880 test_update_keeps_xbit() {
881 local testroot=`test_init update_keeps_xbit 1`
883 touch $testroot/repo/xfile
884 chmod +x $testroot/repo/xfile
885 (cd $testroot/repo && git add .)
886 git_commit $testroot/repo -m "adding executable file"
888 got checkout $testroot/repo $testroot/wt > $testroot/stdout
889 ret=$?
890 if [ $ret -ne 0 ]; then
891 test_done "$testroot" "$ret"
892 return 1
893 fi
895 echo foo > $testroot/repo/xfile
896 git_commit $testroot/repo -m "changed executable file"
898 echo "U xfile" > $testroot/stdout.expected
899 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
900 git_show_head $testroot/repo >> $testroot/stdout.expected
901 echo >> $testroot/stdout.expected
903 (cd $testroot/wt && got update > $testroot/stdout)
904 ret=$?
905 if [ $ret -ne 0 ]; then
906 test_done "$testroot" "$ret"
907 return 1
908 fi
910 cmp -s $testroot/stdout.expected $testroot/stdout
911 ret=$?
912 if [ $ret -ne 0 ]; then
913 diff -u $testroot/stdout.expected $testroot/stdout
914 test_done "$testroot" "$ret"
915 return 1
916 fi
918 ls -l $testroot/wt/xfile | grep -q '^-rwx'
919 ret=$?
920 if [ $ret -ne 0 ]; then
921 echo "file is not executable" >&2
922 ls -l $testroot/wt/xfile >&2
923 fi
924 test_done "$testroot" "$ret"
927 test_update_clears_xbit() {
928 local testroot=`test_init update_clears_xbit 1`
930 touch $testroot/repo/xfile
931 chmod +x $testroot/repo/xfile
932 (cd $testroot/repo && git add .)
933 git_commit $testroot/repo -m "adding executable file"
935 got checkout $testroot/repo $testroot/wt > $testroot/stdout
936 ret=$?
937 if [ $ret -ne 0 ]; then
938 test_done "$testroot" "$ret"
939 return 1
940 fi
942 ls -l $testroot/wt/xfile | grep -q '^-rwx'
943 ret=$?
944 if [ $ret -ne 0 ]; then
945 echo "file is not executable" >&2
946 ls -l $testroot/wt/xfile >&2
947 test_done "$testroot" "$ret"
948 return 1
949 fi
951 # XXX git seems to require a file edit when flipping the x bit?
952 echo foo > $testroot/repo/xfile
953 chmod -x $testroot/repo/xfile
954 git_commit $testroot/repo -m "not an executable file anymore"
956 echo "U xfile" > $testroot/stdout.expected
957 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
958 git_show_head $testroot/repo >> $testroot/stdout.expected
959 echo >> $testroot/stdout.expected
961 (cd $testroot/wt && got update > $testroot/stdout)
962 ret=$?
963 if [ $ret -ne 0 ]; then
964 test_done "$testroot" "$ret"
965 return 1
966 fi
968 cmp -s $testroot/stdout.expected $testroot/stdout
969 ret=$?
970 if [ $ret -ne 0 ]; then
971 diff -u $testroot/stdout.expected $testroot/stdout
972 test_done "$testroot" "$ret"
973 return 1
974 fi
976 ls -l $testroot/wt/xfile | grep -q '^-rw-'
977 ret=$?
978 if [ $ret -ne 0 ]; then
979 echo "file is unexpectedly executable" >&2
980 ls -l $testroot/wt/xfile >&2
981 fi
982 test_done "$testroot" "$ret"
985 test_update_restores_missing_file() {
986 local testroot=`test_init update_restores_missing_file`
988 got checkout $testroot/repo $testroot/wt > /dev/null
989 ret=$?
990 if [ $ret -ne 0 ]; then
991 test_done "$testroot" "$ret"
992 return 1
993 fi
995 rm $testroot/wt/alpha
997 echo "! alpha" > $testroot/stdout.expected
998 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
999 git_show_head $testroot/repo >> $testroot/stdout.expected
1000 echo >> $testroot/stdout.expected
1001 (cd $testroot/wt && got update > $testroot/stdout)
1003 cmp -s $testroot/stdout.expected $testroot/stdout
1004 ret=$?
1005 if [ $ret -ne 0 ]; then
1006 diff -u $testroot/stdout.expected $testroot/stdout
1007 test_done "$testroot" "$ret"
1008 return 1
1011 echo "alpha" > $testroot/content.expected
1013 cat $testroot/wt/alpha > $testroot/content
1015 cmp -s $testroot/content.expected $testroot/content
1016 ret=$?
1017 if [ $ret -ne 0 ]; then
1018 diff -u $testroot/content.expected $testroot/content
1020 test_done "$testroot" "$ret"
1023 test_update_conflict_wt_add_vs_repo_add() {
1024 local testroot=`test_init update_conflict_wt_add_vs_repo_add`
1026 got checkout $testroot/repo $testroot/wt > /dev/null
1027 ret=$?
1028 if [ $ret -ne 0 ]; then
1029 test_done "$testroot" "$ret"
1030 return 1
1033 echo "new" > $testroot/repo/gamma/new
1034 (cd $testroot/repo && git add .)
1035 git_commit $testroot/repo -m "adding a new file"
1037 echo "also new" > $testroot/wt/gamma/new
1038 (cd $testroot/wt && got add gamma/new >/dev/null)
1040 (cd $testroot/wt && got update > $testroot/stdout)
1042 echo "C gamma/new" > $testroot/stdout.expected
1043 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
1044 git_show_head $testroot/repo >> $testroot/stdout.expected
1045 echo >> $testroot/stdout.expected
1046 echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
1048 cmp -s $testroot/stdout.expected $testroot/stdout
1049 ret=$?
1050 if [ $ret -ne 0 ]; then
1051 diff -u $testroot/stdout.expected $testroot/stdout
1052 test_done "$testroot" "$ret"
1053 return 1
1056 echo -n "<<<<<<< merged change: commit " > $testroot/content.expected
1057 git_show_head $testroot/repo >> $testroot/content.expected
1058 echo >> $testroot/content.expected
1059 echo "new" >> $testroot/content.expected
1060 echo "=======" >> $testroot/content.expected
1061 echo "also new" >> $testroot/content.expected
1062 echo '>>>>>>>' >> $testroot/content.expected
1064 cat $testroot/wt/gamma/new > $testroot/content
1066 cmp -s $testroot/content.expected $testroot/content
1067 ret=$?
1068 if [ $ret -ne 0 ]; then
1069 diff -u $testroot/content.expected $testroot/content
1070 test_done "$testroot" "$ret"
1071 return 1
1074 # resolve the conflict
1075 echo "new and also new" > $testroot/wt/gamma/new
1076 echo 'M gamma/new' > $testroot/stdout.expected
1077 (cd $testroot/wt && got status > $testroot/stdout)
1078 cmp -s $testroot/stdout.expected $testroot/stdout
1079 ret=$?
1080 if [ $ret -ne 0 ]; then
1081 diff -u $testroot/stdout.expected $testroot/stdout
1083 test_done "$testroot" "$ret"
1086 test_update_conflict_wt_edit_vs_repo_rm() {
1087 local testroot=`test_init update_conflict_wt_edit_vs_repo_rm`
1089 got checkout $testroot/repo $testroot/wt > /dev/null
1090 ret=$?
1091 if [ $ret -ne 0 ]; then
1092 test_done "$testroot" "$ret"
1093 return 1
1096 (cd $testroot/repo && git rm -q beta)
1097 git_commit $testroot/repo -m "removing a file"
1099 echo "modified beta" > $testroot/wt/beta
1101 (cd $testroot/wt && got update > $testroot/stdout)
1103 echo "G beta" > $testroot/stdout.expected
1104 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
1105 git_show_head $testroot/repo >> $testroot/stdout.expected
1106 echo >> $testroot/stdout.expected
1107 cmp -s $testroot/stdout.expected $testroot/stdout
1108 ret=$?
1109 if [ $ret -ne 0 ]; then
1110 diff -u $testroot/stdout.expected $testroot/stdout
1111 test_done "$testroot" "$ret"
1112 return 1
1115 echo "modified beta" > $testroot/content.expected
1117 cat $testroot/wt/beta > $testroot/content
1119 cmp -s $testroot/content.expected $testroot/content
1120 ret=$?
1121 if [ $ret -ne 0 ]; then
1122 diff -u $testroot/content.expected $testroot/content
1123 test_done "$testroot" "$ret"
1124 return 1
1127 # beta is now an added file... we don't flag tree conflicts yet
1128 echo 'A beta' > $testroot/stdout.expected
1129 (cd $testroot/wt && got status > $testroot/stdout)
1130 cmp -s $testroot/stdout.expected $testroot/stdout
1131 ret=$?
1132 if [ $ret -ne 0 ]; then
1133 diff -u $testroot/stdout.expected $testroot/stdout
1135 test_done "$testroot" "$ret"
1138 test_update_conflict_wt_rm_vs_repo_edit() {
1139 local testroot=`test_init update_conflict_wt_rm_vs_repo_edit`
1141 got checkout $testroot/repo $testroot/wt > /dev/null
1142 ret=$?
1143 if [ $ret -ne 0 ]; then
1144 test_done "$testroot" "$ret"
1145 return 1
1148 echo "modified beta" > $testroot/repo/beta
1149 git_commit $testroot/repo -m "modified a file"
1151 (cd $testroot/wt && got rm beta > /dev/null)
1153 (cd $testroot/wt && got update > $testroot/stdout)
1155 echo "G beta" > $testroot/stdout.expected
1156 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
1157 git_show_head $testroot/repo >> $testroot/stdout.expected
1158 echo >> $testroot/stdout.expected
1159 cmp -s $testroot/stdout.expected $testroot/stdout
1160 ret=$?
1161 if [ $ret -ne 0 ]; then
1162 diff -u $testroot/stdout.expected $testroot/stdout
1163 test_done "$testroot" "$ret"
1164 return 1
1167 # beta remains a deleted file... we don't flag tree conflicts yet
1168 echo 'D beta' > $testroot/stdout.expected
1169 (cd $testroot/wt && got status > $testroot/stdout)
1170 cmp -s $testroot/stdout.expected $testroot/stdout
1171 ret=$?
1172 if [ $ret -ne 0 ]; then
1173 diff -u $testroot/stdout.expected $testroot/stdout
1174 test_done "$testroot" "$ret"
1175 return 1
1178 # 'got diff' should show post-update contents of beta being deleted
1179 local head_rev=`git_show_head $testroot/repo`
1180 echo "diff $testroot/wt" > $testroot/stdout.expected
1181 echo "commit - $head_rev" >> $testroot/stdout.expected
1182 echo "path + $testroot/wt" >> $testroot/stdout.expected
1183 echo -n 'blob - ' >> $testroot/stdout.expected
1184 got tree -r $testroot/repo -i | grep 'beta$' | cut -d' ' -f 1 \
1185 >> $testroot/stdout.expected
1186 echo 'file + /dev/null' >> $testroot/stdout.expected
1187 echo '--- beta' >> $testroot/stdout.expected
1188 echo '+++ /dev/null' >> $testroot/stdout.expected
1189 echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
1190 echo '-modified beta' >> $testroot/stdout.expected
1192 (cd $testroot/wt && got diff > $testroot/stdout)
1193 cmp -s $testroot/stdout.expected $testroot/stdout
1194 ret=$?
1195 if [ $ret -ne 0 ]; then
1196 diff -u $testroot/stdout.expected $testroot/stdout
1198 test_done "$testroot" "$ret"
1201 test_update_conflict_wt_rm_vs_repo_rm() {
1202 local testroot=`test_init update_conflict_wt_rm_vs_repo_rm`
1204 got checkout $testroot/repo $testroot/wt > /dev/null
1205 ret=$?
1206 if [ $ret -ne 0 ]; then
1207 test_done "$testroot" "$ret"
1208 return 1
1211 (cd $testroot/repo && git rm -q beta)
1212 git_commit $testroot/repo -m "removing a file"
1214 (cd $testroot/wt && got rm beta > /dev/null)
1216 (cd $testroot/wt && got update > $testroot/stdout)
1218 echo "D beta" > $testroot/stdout.expected
1219 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
1220 git_show_head $testroot/repo >> $testroot/stdout.expected
1221 echo >> $testroot/stdout.expected
1222 cmp -s $testroot/stdout.expected $testroot/stdout
1223 ret=$?
1224 if [ $ret -ne 0 ]; then
1225 diff -u $testroot/stdout.expected $testroot/stdout
1226 test_done "$testroot" "$ret"
1227 return 1
1230 # beta is now gone... we don't flag tree conflicts yet
1231 echo "N beta" > $testroot/stdout.expected
1232 echo -n > $testroot/stderr.expected
1233 (cd $testroot/wt && got status beta > $testroot/stdout \
1234 2> $testroot/stderr)
1235 cmp -s $testroot/stdout.expected $testroot/stdout
1236 ret=$?
1237 if [ $ret -ne 0 ]; then
1238 diff -u $testroot/stdout.expected $testroot/stdout
1239 test_done "$testroot" "$ret"
1240 return 1
1242 cmp -s $testroot/stderr.expected $testroot/stderr
1243 ret=$?
1244 if [ $ret -ne 0 ]; then
1245 diff -u $testroot/stderr.expected $testroot/stderr
1246 test_done "$testroot" "$ret"
1247 return 1
1250 if [ -e $testroot/wt/beta ]; then
1251 echo "removed file beta still exists on disk" >&2
1252 test_done "$testroot" "1"
1253 return 1
1256 test_done "$testroot" "0"
1259 test_update_partial() {
1260 local testroot=`test_init update_partial`
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 "modified alpha" > $testroot/repo/alpha
1270 echo "modified beta" > $testroot/repo/beta
1271 echo "modified epsilon/zeta" > $testroot/repo/epsilon/zeta
1272 git_commit $testroot/repo -m "modified two files"
1274 echo "U alpha" > $testroot/stdout.expected
1275 echo "U beta" >> $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 alpha beta > $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 "modified alpha" > $testroot/content.expected
1291 echo "modified beta" >> $testroot/content.expected
1293 cat $testroot/wt/alpha $testroot/wt/beta > $testroot/content
1294 cmp -s $testroot/content.expected $testroot/content
1295 ret=$?
1296 if [ $ret -ne 0 ]; then
1297 diff -u $testroot/content.expected $testroot/content
1298 test_done "$testroot" "$ret"
1299 return 1
1302 echo "U epsilon/zeta" > $testroot/stdout.expected
1303 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
1304 git_show_head $testroot/repo >> $testroot/stdout.expected
1305 echo >> $testroot/stdout.expected
1307 (cd $testroot/wt && got update epsilon > $testroot/stdout)
1309 cmp -s $testroot/stdout.expected $testroot/stdout
1310 ret=$?
1311 if [ $ret -ne 0 ]; then
1312 diff -u $testroot/stdout.expected $testroot/stdout
1313 test_done "$testroot" "$ret"
1314 return 1
1317 echo "modified epsilon/zeta" > $testroot/content.expected
1318 cat $testroot/wt/epsilon/zeta > $testroot/content
1320 cmp -s $testroot/content.expected $testroot/content
1321 ret=$?
1322 if [ $ret -ne 0 ]; then
1323 diff -u $testroot/content.expected $testroot/content
1324 test_done "$testroot" "$ret"
1325 return 1
1328 test_done "$testroot" "$ret"
1331 test_update_partial_add() {
1332 local testroot=`test_init update_partial_add`
1334 got checkout $testroot/repo $testroot/wt > /dev/null
1335 ret=$?
1336 if [ $ret -ne 0 ]; then
1337 test_done "$testroot" "$ret"
1338 return 1
1341 echo "new" > $testroot/repo/new
1342 echo "epsilon/new2" > $testroot/repo/epsilon/new2
1343 (cd $testroot/repo && git add .)
1344 git_commit $testroot/repo -m "added two files"
1346 echo "A epsilon/new2" > $testroot/stdout.expected
1347 echo "A new" >> $testroot/stdout.expected
1348 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
1349 git_show_head $testroot/repo >> $testroot/stdout.expected
1350 echo >> $testroot/stdout.expected
1352 (cd $testroot/wt && got update new epsilon/new2 > $testroot/stdout)
1354 cmp -s $testroot/stdout.expected $testroot/stdout
1355 ret=$?
1356 if [ $ret -ne 0 ]; then
1357 diff -u $testroot/stdout.expected $testroot/stdout
1358 test_done "$testroot" "$ret"
1359 return 1
1362 echo "new" > $testroot/content.expected
1363 echo "epsilon/new2" >> $testroot/content.expected
1365 cat $testroot/wt/new $testroot/wt/epsilon/new2 > $testroot/content
1367 cmp -s $testroot/content.expected $testroot/content
1368 ret=$?
1369 if [ $ret -ne 0 ]; then
1370 diff -u $testroot/content.expected $testroot/content
1372 test_done "$testroot" "$ret"
1375 test_update_partial_rm() {
1376 local testroot=`test_init update_partial_rm`
1378 got checkout $testroot/repo $testroot/wt > /dev/null
1379 ret=$?
1380 if [ $ret -ne 0 ]; then
1381 test_done "$testroot" "$ret"
1382 return 1
1385 (cd $testroot/repo && git rm -q alpha epsilon/zeta)
1386 git_commit $testroot/repo -m "removed two files"
1388 echo "got: /alpha: no such entry found in tree" \
1389 > $testroot/stderr.expected
1391 (cd $testroot/wt && got update alpha epsilon/zeta 2> $testroot/stderr)
1392 ret=$?
1393 if [ $ret -eq 0 ]; then
1394 echo "update succeeded unexpectedly" >&2
1395 test_done "$testroot" "1"
1396 return 1
1399 cmp -s $testroot/stderr.expected $testroot/stderr
1400 ret=$?
1401 if [ $ret -ne 0 ]; then
1402 diff -u $testroot/stderr.expected $testroot/stderr
1403 test_done "$testroot" "$ret"
1404 return 1
1406 test_done "$testroot" "$ret"
1409 test_update_partial_dir() {
1410 local testroot=`test_init update_partial_dir`
1412 got checkout $testroot/repo $testroot/wt > /dev/null
1413 ret=$?
1414 if [ $ret -ne 0 ]; then
1415 test_done "$testroot" "$ret"
1416 return 1
1419 echo "modified alpha" > $testroot/repo/alpha
1420 echo "modified beta" > $testroot/repo/beta
1421 echo "modified epsilon/zeta" > $testroot/repo/epsilon/zeta
1422 git_commit $testroot/repo -m "modified two files"
1424 echo "U epsilon/zeta" > $testroot/stdout.expected
1425 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
1426 git_show_head $testroot/repo >> $testroot/stdout.expected
1427 echo >> $testroot/stdout.expected
1429 (cd $testroot/wt && got update epsilon > $testroot/stdout)
1431 cmp -s $testroot/stdout.expected $testroot/stdout
1432 ret=$?
1433 if [ $ret -ne 0 ]; then
1434 diff -u $testroot/stdout.expected $testroot/stdout
1435 test_done "$testroot" "$ret"
1436 return 1
1439 echo "modified epsilon/zeta" > $testroot/content.expected
1440 cat $testroot/wt/epsilon/zeta > $testroot/content
1442 cmp -s $testroot/content.expected $testroot/content
1443 ret=$?
1444 if [ $ret -ne 0 ]; then
1445 diff -u $testroot/content.expected $testroot/content
1446 test_done "$testroot" "$ret"
1447 return 1
1449 test_done "$testroot" "$ret"
1453 test_update_moved_branch_ref() {
1454 local testroot=`test_init update_moved_branch_ref`
1456 git clone -q --mirror $testroot/repo $testroot/repo2
1458 echo "modified alpha with git" > $testroot/repo/alpha
1459 git_commit $testroot/repo -m "modified alpha with git"
1461 got checkout $testroot/repo2 $testroot/wt > /dev/null
1462 ret=$?
1463 if [ $ret -ne 0 ]; then
1464 test_done "$testroot" "$ret"
1465 return 1
1468 echo "modified alpha with got" > $testroot/wt/alpha
1469 (cd $testroot/wt && got commit -m "modified alpha with got" > /dev/null)
1471 # + xxxxxxx...yyyyyyy master -> master (forced update)
1472 (cd $testroot/repo2 && git fetch -q --all)
1474 echo -n > $testroot/stdout.expected
1475 echo -n "got: work tree's head reference now points to a different " \
1476 > $testroot/stderr.expected
1477 echo "branch; new head reference and/or update -b required" \
1478 >> $testroot/stderr.expected
1480 (cd $testroot/wt && got update > $testroot/stdout 2> $testroot/stderr)
1482 cmp -s $testroot/stdout.expected $testroot/stdout
1483 ret=$?
1484 if [ $ret -ne 0 ]; then
1485 diff -u $testroot/stdout.expected $testroot/stdout
1486 test_done "$testroot" "$ret"
1487 return 1
1490 cmp -s $testroot/stderr.expected $testroot/stderr
1491 ret=$?
1492 if [ $ret -ne 0 ]; then
1493 diff -u $testroot/stderr.expected $testroot/stderr
1495 test_done "$testroot" "$ret"
1498 test_update_to_another_branch() {
1499 local testroot=`test_init update_to_another_branch`
1500 local base_commit=`git_show_head $testroot/repo`
1502 got checkout $testroot/repo $testroot/wt > /dev/null
1503 ret=$?
1504 if [ $ret -ne 0 ]; then
1505 test_done "$testroot" "$ret"
1506 return 1
1509 echo 'refs/heads/master'> $testroot/head-ref.expected
1510 cmp -s $testroot/head-ref.expected $testroot/wt/.got/head-ref
1511 ret=$?
1512 if [ $ret -ne 0 ]; then
1513 diff -u $testroot/head-ref.expected $testroot/wt/.got/head-ref
1514 test_done "$testroot" "$ret"
1515 return 1
1518 (cd $testroot/repo && git checkout -q -b newbranch)
1519 echo "modified alpha on new branch" > $testroot/repo/alpha
1520 git_commit $testroot/repo -m "modified alpha on new branch"
1522 echo "modified alpha in work tree" > $testroot/wt/alpha
1524 echo "Switching work tree from refs/heads/master to refs/heads/newbranch" > $testroot/stdout.expected
1525 echo "C alpha" >> $testroot/stdout.expected
1526 echo -n "Updated to refs/heads/newbranch: " >> $testroot/stdout.expected
1527 git_show_head $testroot/repo >> $testroot/stdout.expected
1528 echo >> $testroot/stdout.expected
1529 echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
1531 (cd $testroot/wt && got update -b newbranch > $testroot/stdout)
1533 cmp -s $testroot/stdout.expected $testroot/stdout
1534 ret=$?
1535 if [ $ret -ne 0 ]; then
1536 diff -u $testroot/stdout.expected $testroot/stdout
1537 test_done "$testroot" "$ret"
1538 return 1
1541 echo -n "<<<<<<< merged change: commit " > $testroot/content.expected
1542 git_show_head $testroot/repo >> $testroot/content.expected
1543 echo >> $testroot/content.expected
1544 echo "modified alpha on new branch" >> $testroot/content.expected
1545 echo "||||||| 3-way merge base: commit $base_commit" \
1546 >> $testroot/content.expected
1547 echo "alpha" >> $testroot/content.expected
1548 echo "=======" >> $testroot/content.expected
1549 echo "modified alpha in work tree" >> $testroot/content.expected
1550 echo '>>>>>>>' >> $testroot/content.expected
1552 cat $testroot/wt/alpha > $testroot/content
1554 cmp -s $testroot/content.expected $testroot/content
1555 ret=$?
1556 if [ $ret -ne 0 ]; then
1557 diff -u $testroot/content.expected $testroot/content
1558 test_done "$testroot" "$ret"
1559 return 1
1562 echo 'refs/heads/newbranch'> $testroot/head-ref.expected
1563 cmp -s $testroot/head-ref.expected $testroot/wt/.got/head-ref
1564 ret=$?
1565 if [ $ret -ne 0 ]; then
1566 diff -u $testroot/head-ref.expected $testroot/wt/.got/head-ref
1567 test_done "$testroot" "$ret"
1568 return 1
1571 test_done "$testroot" "$ret"
1574 test_update_to_commit_on_wrong_branch() {
1575 local testroot=`test_init update_to_commit_on_wrong_branch`
1577 got checkout $testroot/repo $testroot/wt > /dev/null
1578 ret=$?
1579 if [ $ret -ne 0 ]; then
1580 test_done "$testroot" "$ret"
1581 return 1
1584 (cd $testroot/repo && git checkout -q -b newbranch)
1585 echo "modified alpha on new branch" > $testroot/repo/alpha
1586 git_commit $testroot/repo -m "modified alpha on new branch"
1588 echo -n "" > $testroot/stdout.expected
1589 echo "got: target commit is on a different branch" \
1590 > $testroot/stderr.expected
1592 local head_rev=`git_show_head $testroot/repo`
1593 (cd $testroot/wt && got update -c $head_rev > $testroot/stdout \
1594 2> $testroot/stderr)
1596 cmp -s $testroot/stdout.expected $testroot/stdout
1597 ret=$?
1598 if [ $ret -ne 0 ]; then
1599 diff -u $testroot/stdout.expected $testroot/stdout
1600 test_done "$testroot" "$ret"
1601 return 1
1604 cmp -s $testroot/stderr.expected $testroot/stderr
1605 ret=$?
1606 if [ $ret -ne 0 ]; then
1607 diff -u $testroot/stderr.expected $testroot/stderr
1608 test_done "$testroot" "$ret"
1609 return 1
1612 test_done "$testroot" "$ret"
1615 test_update_bumps_base_commit_id() {
1616 local testroot=`test_init update_bumps_base_commit_id`
1618 echo "psi" > $testroot/repo/epsilon/psi
1619 (cd $testroot/repo && git add .)
1620 git_commit $testroot/repo -m "adding another file"
1622 got checkout $testroot/repo $testroot/wt > /dev/null
1623 ret=$?
1624 if [ $ret -ne 0 ]; then
1625 test_done "$testroot" "$ret"
1626 return 1
1629 echo "modified psi" > $testroot/wt/epsilon/psi
1630 (cd $testroot/wt && got commit -m "changed psi" > $testroot/stdout)
1632 local head_rev=`git_show_head $testroot/repo`
1633 echo "M epsilon/psi" > $testroot/stdout.expected
1634 echo "Created commit $head_rev" >> $testroot/stdout.expected
1635 cmp -s $testroot/stdout.expected $testroot/stdout
1636 ret=$?
1637 if [ $ret -ne 0 ]; then
1638 diff -u $testroot/stdout.expected $testroot/stdout
1639 test_done "$testroot" "$ret"
1640 return 1
1643 echo "changed zeta with git" > $testroot/repo/epsilon/zeta
1644 (cd $testroot/repo && git add .)
1645 git_commit $testroot/repo -m "changing zeta with git"
1647 echo "modified zeta" > $testroot/wt/epsilon/zeta
1648 (cd $testroot/wt && got commit -m "changed zeta" > $testroot/stdout \
1649 2> $testroot/stderr)
1651 echo -n "" > $testroot/stdout.expected
1652 echo "got: work tree must be updated before these changes can be committed" > $testroot/stderr.expected
1653 cmp -s $testroot/stderr.expected $testroot/stderr
1654 ret=$?
1655 if [ $ret -ne 0 ]; then
1656 diff -u $testroot/stderr.expected $testroot/stderr
1657 test_done "$testroot" "$ret"
1658 return 1
1661 (cd $testroot/wt && got update > $testroot/stdout)
1663 echo "U epsilon/psi" > $testroot/stdout.expected
1664 echo "C epsilon/zeta" >> $testroot/stdout.expected
1665 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
1666 git_show_head $testroot/repo >> $testroot/stdout.expected
1667 echo >> $testroot/stdout.expected
1668 echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
1670 cmp -s $testroot/stdout.expected $testroot/stdout
1671 ret=$?
1672 if [ $ret -ne 0 ]; then
1673 diff -u $testroot/stdout.expected $testroot/stdout
1674 test_done "$testroot" "$ret"
1675 return 1
1678 # resolve conflict
1679 echo "modified zeta with got and git" > $testroot/wt/epsilon/zeta
1681 (cd $testroot/wt && got commit -m "changed zeta" > $testroot/stdout)
1683 local head_rev=`git_show_head $testroot/repo`
1684 echo "M epsilon/zeta" > $testroot/stdout.expected
1685 echo "Created commit $head_rev" >> $testroot/stdout.expected
1686 cmp -s $testroot/stdout.expected $testroot/stdout
1687 ret=$?
1688 if [ $ret -ne 0 ]; then
1689 diff -u $testroot/stdout.expected $testroot/stdout
1690 test_done "$testroot" "$ret"
1691 return 1
1694 test_done "$testroot" "$ret"
1697 test_update_tag() {
1698 local testroot=`test_init update_tag`
1699 local tag="1.0.0"
1701 got checkout $testroot/repo $testroot/wt > /dev/null
1702 ret=$?
1703 if [ $ret -ne 0 ]; then
1704 test_done "$testroot" "$ret"
1705 return 1
1708 echo "modified alpha" > $testroot/repo/alpha
1709 git_commit $testroot/repo -m "modified alpha"
1710 (cd $testroot/repo && git tag -m "test" -a $tag)
1712 echo "U alpha" > $testroot/stdout.expected
1713 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
1714 git_show_head $testroot/repo >> $testroot/stdout.expected
1715 echo >> $testroot/stdout.expected
1717 (cd $testroot/wt && got update -c $tag > $testroot/stdout)
1719 cmp -s $testroot/stdout.expected $testroot/stdout
1720 ret=$?
1721 if [ $ret -ne 0 ]; then
1722 diff -u $testroot/stdout.expected $testroot/stdout
1723 test_done "$testroot" "$ret"
1724 return 1
1727 echo "modified alpha" > $testroot/content.expected
1728 cat $testroot/wt/alpha > $testroot/content
1730 cmp -s $testroot/content.expected $testroot/content
1731 ret=$?
1732 if [ $ret -ne 0 ]; then
1733 diff -u $testroot/content.expected $testroot/content
1735 test_done "$testroot" "$ret"
1738 test_update_toggles_xbit() {
1739 local testroot=`test_init update_toggles_xbit 1`
1741 touch $testroot/repo/xfile
1742 chmod +x $testroot/repo/xfile
1743 (cd $testroot/repo && git add .)
1744 git_commit $testroot/repo -m "adding executable file"
1745 local commit_id1=`git_show_head $testroot/repo`
1747 got checkout $testroot/repo $testroot/wt > $testroot/stdout
1748 ret=$?
1749 if [ $ret -ne 0 ]; then
1750 test_done "$testroot" "$ret"
1751 return 1
1754 ls -l $testroot/wt/xfile | grep -q '^-rwx'
1755 ret=$?
1756 if [ $ret -ne 0 ]; then
1757 echo "file is not executable" >&2
1758 ls -l $testroot/wt/xfile >&2
1759 test_done "$testroot" "$ret"
1760 return 1
1763 chmod -x $testroot/wt/xfile
1764 (cd $testroot/wt && got commit -m "clear x bit" >/dev/null)
1765 local commit_id2=`git_show_head $testroot/repo`
1767 echo "U xfile" > $testroot/stdout.expected
1768 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
1769 git_show_head $testroot/repo >> $testroot/stdout.expected
1770 echo >> $testroot/stdout.expected
1772 (cd $testroot/wt && got update -c $commit_id1 > $testroot/stdout)
1773 ret=$?
1774 if [ $ret -ne 0 ]; then
1775 test_done "$testroot" "$ret"
1776 return 1
1779 echo "U xfile" > $testroot/stdout.expected
1780 echo "Updated to refs/heads/master: $commit_id1" >> $testroot/stdout.expected
1781 cmp -s $testroot/stdout.expected $testroot/stdout
1782 ret=$?
1783 if [ $ret -ne 0 ]; then
1784 diff -u $testroot/stdout.expected $testroot/stdout
1785 test_done "$testroot" "$ret"
1786 return 1
1790 ls -l $testroot/wt/xfile | grep -q '^-rwx'
1791 ret=$?
1792 if [ $ret -ne 0 ]; then
1793 echo "file is not executable" >&2
1794 ls -l $testroot/wt/xfile >&2
1795 test_done "$testroot" "$ret"
1796 return 1
1799 (cd $testroot/wt && got update > $testroot/stdout)
1800 ret=$?
1801 if [ $ret -ne 0 ]; then
1802 test_done "$testroot" "$ret"
1803 return 1
1806 echo "U xfile" > $testroot/stdout.expected
1807 echo "Updated to refs/heads/master: $commit_id2" \
1808 >> $testroot/stdout.expected
1809 cmp -s $testroot/stdout.expected $testroot/stdout
1810 ret=$?
1811 if [ $ret -ne 0 ]; then
1812 diff -u $testroot/stdout.expected $testroot/stdout
1813 test_done "$testroot" "$ret"
1814 return 1
1817 ls -l $testroot/wt/xfile | grep -q '^-rw-'
1818 ret=$?
1819 if [ $ret -ne 0 ]; then
1820 echo "file is unexpectedly executable" >&2
1821 ls -l $testroot/wt/xfile >&2
1823 test_done "$testroot" "$ret"
1826 test_update_preserves_conflicted_file() {
1827 local testroot=`test_init update_preserves_conflicted_file`
1828 local commit_id0=`git_show_head $testroot/repo`
1830 echo "modified alpha" > $testroot/repo/alpha
1831 git_commit $testroot/repo -m "modified alpha"
1832 local commit_id1=`git_show_head $testroot/repo`
1834 got checkout -c $commit_id0 $testroot/repo $testroot/wt > /dev/null
1835 ret=$?
1836 if [ $ret -ne 0 ]; then
1837 test_done "$testroot" "$ret"
1838 return 1
1841 # fake a merge conflict
1842 echo '<<<<<<<' > $testroot/wt/alpha
1843 echo 'alpha' >> $testroot/wt/alpha
1844 echo '=======' >> $testroot/wt/alpha
1845 echo 'alpha, too' >> $testroot/wt/alpha
1846 echo '>>>>>>>' >> $testroot/wt/alpha
1847 cp $testroot/wt/alpha $testroot/content.expected
1849 echo "C alpha" > $testroot/stdout.expected
1850 (cd $testroot/wt && got status > $testroot/stdout)
1851 cmp -s $testroot/stdout.expected $testroot/stdout
1852 ret=$?
1853 if [ $ret -ne 0 ]; then
1854 diff -u $testroot/stdout.expected $testroot/stdout
1855 test_done "$testroot" "$ret"
1856 return 1
1859 echo "# alpha" > $testroot/stdout.expected
1860 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
1861 git_show_head $testroot/repo >> $testroot/stdout.expected
1862 echo >> $testroot/stdout.expected
1863 echo "Files not updated because of existing merge conflicts: 1" \
1864 >> $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
1871 test_done "$testroot" "$ret"
1872 return 1
1875 cmp -s $testroot/content.expected $testroot/wt/alpha
1876 ret=$?
1877 if [ $ret -ne 0 ]; then
1878 diff -u $testroot/content.expected $testroot/wt/alpha
1880 test_done "$testroot" "$ret"
1883 test_update_modified_submodules() {
1884 local testroot=`test_init update_modified_submodules`
1886 make_single_file_repo $testroot/repo2 foo
1888 (cd $testroot/repo && git -c protocol.file.allow=always \
1889 submodule -q add ../repo2)
1890 (cd $testroot/repo && git commit -q -m 'adding submodule')
1892 got checkout $testroot/repo $testroot/wt > /dev/null
1894 echo "modified foo" > $testroot/repo2/foo
1895 (cd $testroot/repo2 && git commit -q -a -m 'modified a submodule')
1897 # Update the repo/repo2 submodule link
1898 (cd $testroot/repo && git -C repo2 pull -q)
1899 (cd $testroot/repo && git add repo2)
1900 git_commit $testroot/repo -m "modified submodule link"
1902 echo "Already up-to-date" > $testroot/stdout.expected
1903 (cd $testroot/wt && got update > $testroot/stdout)
1905 cmp -s $testroot/stdout.expected $testroot/stdout
1906 ret=$?
1907 if [ $ret -ne 0 ]; then
1908 diff -u $testroot/stdout.expected $testroot/stdout
1910 test_done "$testroot" "$ret"
1913 test_update_adds_submodule() {
1914 local testroot=`test_init update_adds_submodule`
1916 got checkout $testroot/repo $testroot/wt > /dev/null
1918 make_single_file_repo $testroot/repo2 foo
1920 echo "modified foo" > $testroot/repo2/foo
1921 (cd $testroot/repo2 && git commit -q -a -m 'modified a submodule')
1923 (cd $testroot/repo && git -c protocol.file.allow=always \
1924 submodule -q add ../repo2)
1925 (cd $testroot/repo && git commit -q -m 'adding submodule')
1927 echo "A .gitmodules" > $testroot/stdout.expected
1928 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
1929 git_show_head $testroot/repo >> $testroot/stdout.expected
1930 echo >> $testroot/stdout.expected
1932 (cd $testroot/wt && got update > $testroot/stdout)
1934 cmp -s $testroot/stdout.expected $testroot/stdout
1935 ret=$?
1936 if [ $ret -ne 0 ]; then
1937 diff -u $testroot/stdout.expected $testroot/stdout
1939 test_done "$testroot" "$ret"
1942 test_update_conflict_wt_file_vs_repo_submodule() {
1943 local testroot=`test_init update_conflict_wt_file_vs_repo_submodule`
1945 got checkout $testroot/repo $testroot/wt > /dev/null
1947 make_single_file_repo $testroot/repo2 foo
1949 # Add a file which will clash with the submodule
1950 echo "This is a file called repo2" > $testroot/wt/repo2
1951 (cd $testroot/wt && got add repo2 > /dev/null)
1952 (cd $testroot/wt && got commit -m 'add file repo2' > /dev/null)
1953 ret=$?
1954 if [ $ret -ne 0 ]; then
1955 echo "commit failed unexpectedly" >&2
1956 test_done "$testroot" "1"
1957 return 1
1960 (cd $testroot/repo && git -c protocol.file.allow=always \
1961 submodule -q add ../repo2)
1962 (cd $testroot/repo && git commit -q -m 'adding submodule')
1964 # Modify the clashing file such that any modifications brought
1965 # in by 'got update' would require a merge.
1966 echo "This file was changed" > $testroot/wt/repo2
1968 # No conflict occurs because 'got update' ignores the submodule
1969 # and leaves the clashing file as it was.
1970 echo "A .gitmodules" > $testroot/stdout.expected
1971 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
1972 git_show_head $testroot/repo >> $testroot/stdout.expected
1973 echo >> $testroot/stdout.expected
1975 (cd $testroot/wt && got update > $testroot/stdout)
1977 cmp -s $testroot/stdout.expected $testroot/stdout
1978 ret=$?
1979 if [ $ret -ne 0 ]; then
1980 diff -u $testroot/stdout.expected $testroot/stdout
1981 test_done "$testroot" "$ret"
1982 return 1
1985 (cd $testroot/wt && got status > $testroot/stdout)
1987 echo "M repo2" > $testroot/stdout.expected
1988 cmp -s $testroot/stdout.expected $testroot/stdout
1989 ret=$?
1990 if [ $ret -ne 0 ]; then
1991 diff -u $testroot/stdout.expected $testroot/stdout
1993 test_done "$testroot" "$ret"
1996 test_update_adds_symlink() {
1997 local testroot=`test_init update_adds_symlink`
1999 got checkout $testroot/repo $testroot/wt > /dev/null
2000 ret=$?
2001 if [ $ret -ne 0 ]; then
2002 echo "checkout failed unexpectedly" >&2
2003 test_done "$testroot" "$ret"
2004 return 1
2007 (cd $testroot/repo && ln -s alpha alpha.link)
2008 (cd $testroot/repo && ln -s epsilon epsilon.link)
2009 (cd $testroot/repo && ln -s /etc/passwd passwd.link)
2010 (cd $testroot/repo && ln -s ../beta epsilon/beta.link)
2011 (cd $testroot/repo && ln -s nonexistent nonexistent.link)
2012 (cd $testroot/repo && git add .)
2013 git_commit $testroot/repo -m "add symlinks"
2015 echo "A alpha.link" > $testroot/stdout.expected
2016 echo "A epsilon/beta.link" >> $testroot/stdout.expected
2017 echo "A epsilon.link" >> $testroot/stdout.expected
2018 echo "A nonexistent.link" >> $testroot/stdout.expected
2019 echo "A passwd.link" >> $testroot/stdout.expected
2020 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
2021 git_show_head $testroot/repo >> $testroot/stdout.expected
2022 echo >> $testroot/stdout.expected
2024 (cd $testroot/wt && got update > $testroot/stdout)
2026 cmp -s $testroot/stdout.expected $testroot/stdout
2027 ret=$?
2028 if [ $ret -ne 0 ]; then
2029 diff -u $testroot/stdout.expected $testroot/stdout
2030 test_done "$testroot" "$ret"
2031 return 1
2034 if ! [ -h $testroot/wt/alpha.link ]; then
2035 echo "alpha.link is not a symlink"
2036 test_done "$testroot" "1"
2037 return 1
2040 readlink $testroot/wt/alpha.link > $testroot/stdout
2041 echo "alpha" > $testroot/stdout.expected
2042 cmp -s $testroot/stdout.expected $testroot/stdout
2043 ret=$?
2044 if [ $ret -ne 0 ]; then
2045 diff -u $testroot/stdout.expected $testroot/stdout
2046 test_done "$testroot" "$ret"
2047 return 1
2050 if ! [ -h $testroot/wt/epsilon.link ]; then
2051 echo "epsilon.link is not a symlink"
2052 test_done "$testroot" "1"
2053 return 1
2056 readlink $testroot/wt/epsilon.link > $testroot/stdout
2057 echo "epsilon" > $testroot/stdout.expected
2058 cmp -s $testroot/stdout.expected $testroot/stdout
2059 ret=$?
2060 if [ $ret -ne 0 ]; then
2061 diff -u $testroot/stdout.expected $testroot/stdout
2062 test_done "$testroot" "$ret"
2063 return 1
2066 if [ -h $testroot/wt/passwd.link ]; then
2067 echo -n "passwd.link symlink points outside of work tree: " >&2
2068 readlink $testroot/wt/passwd.link >&2
2069 test_done "$testroot" "1"
2070 return 1
2073 echo -n "/etc/passwd" > $testroot/content.expected
2074 cp $testroot/wt/passwd.link $testroot/content
2076 cmp -s $testroot/content.expected $testroot/content
2077 ret=$?
2078 if [ $ret -ne 0 ]; then
2079 diff -u $testroot/content.expected $testroot/content
2080 test_done "$testroot" "$ret"
2081 return 1
2084 readlink $testroot/wt/epsilon/beta.link > $testroot/stdout
2085 echo "../beta" > $testroot/stdout.expected
2086 cmp -s $testroot/stdout.expected $testroot/stdout
2087 ret=$?
2088 if [ $ret -ne 0 ]; then
2089 diff -u $testroot/stdout.expected $testroot/stdout
2090 test_done "$testroot" "$ret"
2091 return 1
2094 readlink $testroot/wt/nonexistent.link > $testroot/stdout
2095 echo "nonexistent" > $testroot/stdout.expected
2096 cmp -s $testroot/stdout.expected $testroot/stdout
2097 ret=$?
2098 if [ $ret -ne 0 ]; then
2099 diff -u $testroot/stdout.expected $testroot/stdout
2100 test_done "$testroot" "$ret"
2101 return 1
2104 # Updating an up-to-date symlink should be a no-op.
2105 echo 'Already up-to-date' > $testroot/stdout.expected
2106 (cd $testroot/wt && got update > $testroot/stdout)
2107 cmp -s $testroot/stdout.expected $testroot/stdout
2108 ret=$?
2109 if [ $ret -ne 0 ]; then
2110 diff -u $testroot/stdout.expected $testroot/stdout
2112 test_done "$testroot" "$ret"
2115 test_update_deletes_symlink() {
2116 local testroot=`test_init update_deletes_symlink`
2118 (cd $testroot/repo && ln -s alpha alpha.link)
2119 (cd $testroot/repo && git add .)
2120 git_commit $testroot/repo -m "add symlink"
2122 got checkout $testroot/repo $testroot/wt > /dev/null
2123 ret=$?
2124 if [ $ret -ne 0 ]; then
2125 echo "checkout failed unexpectedly" >&2
2126 test_done "$testroot" "$ret"
2127 return 1
2130 (cd $testroot/repo && git rm -q alpha.link)
2131 git_commit $testroot/repo -m "delete symlink"
2133 echo "D alpha.link" > $testroot/stdout.expected
2134 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
2135 git_show_head $testroot/repo >> $testroot/stdout.expected
2136 echo >> $testroot/stdout.expected
2138 (cd $testroot/wt && got update > $testroot/stdout)
2140 cmp -s $testroot/stdout.expected $testroot/stdout
2141 ret=$?
2142 if [ $ret -ne 0 ]; then
2143 diff -u $testroot/stdout.expected $testroot/stdout
2144 test_done "$testroot" "$ret"
2145 return 1
2148 if [ -e $testroot/wt/alpha.link ]; then
2149 echo "alpha.link still exists on disk"
2150 test_done "$testroot" "1"
2151 return 1
2154 test_done "$testroot" "0"
2157 test_update_symlink_conflicts() {
2158 local testroot=`test_init update_symlink_conflicts`
2160 (cd $testroot/repo && ln -s alpha alpha.link)
2161 (cd $testroot/repo && ln -s epsilon epsilon.link)
2162 (cd $testroot/repo && ln -s /etc/passwd passwd.link)
2163 (cd $testroot/repo && ln -s ../beta epsilon/beta.link)
2164 (cd $testroot/repo && ln -s nonexistent nonexistent.link)
2165 (cd $testroot/repo && ln -sf epsilon/zeta zeta.link)
2166 (cd $testroot/repo && git add .)
2167 git_commit $testroot/repo -m "add symlinks"
2168 local commit_id1=`git_show_head $testroot/repo`
2170 got checkout $testroot/repo $testroot/wt > /dev/null
2171 ret=$?
2172 if [ $ret -ne 0 ]; then
2173 echo "checkout failed unexpectedly" >&2
2174 test_done "$testroot" "$ret"
2175 return 1
2178 (cd $testroot/repo && ln -sf beta alpha.link)
2179 (cd $testroot/repo && rm epsilon.link && ln -s gamma epsilon.link)
2180 (cd $testroot/repo && ln -sf ../gamma/delta epsilon/beta.link)
2181 echo 'this is regular file foo' > $testroot/repo/dotgotfoo.link
2182 (cd $testroot/repo && ln -sf .got/bar dotgotbar.link)
2183 (cd $testroot/repo && git rm -q nonexistent.link)
2184 (cd $testroot/repo && ln -sf gamma/delta zeta.link)
2185 (cd $testroot/repo && ln -sf alpha new.link)
2186 (cd $testroot/repo && git add .)
2187 git_commit $testroot/repo -m "change symlinks"
2188 local commit_id2=`git_show_head $testroot/repo`
2190 # modified symlink to file A vs modified symlink to file B
2191 (cd $testroot/wt && ln -sf gamma/delta alpha.link)
2192 # modified symlink to dir A vs modified symlink to file B
2193 (cd $testroot/wt && rm epsilon.link && ln -s beta epsilon.link)
2194 # modeified symlink to file A vs modified symlink to dir B
2195 (cd $testroot/wt && rm epsilon/beta.link && ln -s ../gamma \
2196 epsilon/beta.link)
2197 # added regular file A vs added bad symlink to file A
2198 (cd $testroot/wt && ln -sf .got/bar dotgotfoo.link)
2199 (cd $testroot/wt && got add dotgotfoo.link > /dev/null)
2200 # added bad symlink to file A vs added regular file A
2201 echo 'this is regular file bar' > $testroot/wt/dotgotbar.link
2202 (cd $testroot/wt && got add dotgotbar.link > /dev/null)
2203 # removed symlink to non-existent file A vs modified symlink
2204 # to nonexistent file B
2205 (cd $testroot/wt && ln -sf nonexistent2 nonexistent.link)
2206 # modified symlink to file A vs removed symlink to file A
2207 (cd $testroot/wt && got rm zeta.link > /dev/null)
2208 # added symlink to file A vs added symlink to file B
2209 (cd $testroot/wt && ln -sf beta new.link)
2210 (cd $testroot/wt && got add new.link > /dev/null)
2212 (cd $testroot/wt && got update > $testroot/stdout)
2214 echo "C alpha.link" >> $testroot/stdout.expected
2215 echo "C dotgotbar.link" >> $testroot/stdout.expected
2216 echo "C dotgotfoo.link" >> $testroot/stdout.expected
2217 echo "C epsilon/beta.link" >> $testroot/stdout.expected
2218 echo "C epsilon.link" >> $testroot/stdout.expected
2219 echo "C new.link" >> $testroot/stdout.expected
2220 echo "C nonexistent.link" >> $testroot/stdout.expected
2221 echo "G zeta.link" >> $testroot/stdout.expected
2222 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
2223 git_show_head $testroot/repo >> $testroot/stdout.expected
2224 echo >> $testroot/stdout.expected
2225 echo "Files with new merge conflicts: 7" >> $testroot/stdout.expected
2227 cmp -s $testroot/stdout.expected $testroot/stdout
2228 ret=$?
2229 if [ $ret -ne 0 ]; then
2230 diff -u $testroot/stdout.expected $testroot/stdout
2231 test_done "$testroot" "$ret"
2232 return 1
2235 if [ -h $testroot/wt/alpha.link ]; then
2236 echo "alpha.link is a symlink"
2237 test_done "$testroot" "1"
2238 return 1
2241 echo "<<<<<<< merged change: commit $commit_id2" \
2242 > $testroot/content.expected
2243 echo "beta" >> $testroot/content.expected
2244 echo "3-way merge base: commit $commit_id1" \
2245 >> $testroot/content.expected
2246 echo "alpha" >> $testroot/content.expected
2247 echo "=======" >> $testroot/content.expected
2248 echo "gamma/delta" >> $testroot/content.expected
2249 echo '>>>>>>>' >> $testroot/content.expected
2250 echo -n "" >> $testroot/content.expected
2252 cp $testroot/wt/alpha.link $testroot/content
2253 cmp -s $testroot/content.expected $testroot/content
2254 ret=$?
2255 if [ $ret -ne 0 ]; then
2256 diff -u $testroot/content.expected $testroot/content
2257 test_done "$testroot" "$ret"
2258 return 1
2261 if [ -h $testroot/wt/epsilon.link ]; then
2262 echo "epsilon.link is a symlink"
2263 test_done "$testroot" "1"
2264 return 1
2267 echo "<<<<<<< merged change: commit $commit_id2" \
2268 > $testroot/content.expected
2269 echo "gamma" >> $testroot/content.expected
2270 echo "3-way merge base: commit $commit_id1" \
2271 >> $testroot/content.expected
2272 echo "epsilon" >> $testroot/content.expected
2273 echo "=======" >> $testroot/content.expected
2274 echo "beta" >> $testroot/content.expected
2275 echo '>>>>>>>' >> $testroot/content.expected
2276 echo -n "" >> $testroot/content.expected
2278 cp $testroot/wt/epsilon.link $testroot/content
2279 cmp -s $testroot/content.expected $testroot/content
2280 ret=$?
2281 if [ $ret -ne 0 ]; then
2282 diff -u $testroot/content.expected $testroot/content
2283 test_done "$testroot" "$ret"
2284 return 1
2287 if [ -h $testroot/wt/passwd.link ]; then
2288 echo -n "passwd.link symlink points outside of work tree: " >&2
2289 readlink $testroot/wt/passwd.link >&2
2290 test_done "$testroot" "1"
2291 return 1
2294 echo -n "/etc/passwd" > $testroot/content.expected
2295 cp $testroot/wt/passwd.link $testroot/content
2297 cmp -s $testroot/content.expected $testroot/content
2298 ret=$?
2299 if [ $ret -ne 0 ]; then
2300 diff -u $testroot/content.expected $testroot/content
2301 test_done "$testroot" "$ret"
2302 return 1
2305 if [ -h $testroot/wt/epsilon/beta.link ]; then
2306 echo "epsilon/beta.link is a symlink"
2307 test_done "$testroot" "1"
2308 return 1
2311 echo "<<<<<<< merged change: commit $commit_id2" \
2312 > $testroot/content.expected
2313 echo "../gamma/delta" >> $testroot/content.expected
2314 echo "3-way merge base: commit $commit_id1" \
2315 >> $testroot/content.expected
2316 echo "../beta" >> $testroot/content.expected
2317 echo "=======" >> $testroot/content.expected
2318 echo "../gamma" >> $testroot/content.expected
2319 echo '>>>>>>>' >> $testroot/content.expected
2320 echo -n "" >> $testroot/content.expected
2322 cp $testroot/wt/epsilon/beta.link $testroot/content
2323 cmp -s $testroot/content.expected $testroot/content
2324 ret=$?
2325 if [ $ret -ne 0 ]; then
2326 diff -u $testroot/content.expected $testroot/content
2327 test_done "$testroot" "$ret"
2328 return 1
2331 if [ -h $testroot/wt/nonexistent.link ]; then
2332 echo -n "nonexistent.link still exists on disk: " >&2
2333 readlink $testroot/wt/nonexistent.link >&2
2334 test_done "$testroot" "1"
2335 return 1
2338 echo "<<<<<<< merged change: commit $commit_id2" \
2339 > $testroot/content.expected
2340 echo "(symlink was deleted)" >> $testroot/content.expected
2341 echo "=======" >> $testroot/content.expected
2342 echo "nonexistent2" >> $testroot/content.expected
2343 echo '>>>>>>>' >> $testroot/content.expected
2344 echo -n "" >> $testroot/content.expected
2346 cp $testroot/wt/nonexistent.link $testroot/content
2347 cmp -s $testroot/content.expected $testroot/content
2348 ret=$?
2349 if [ $ret -ne 0 ]; then
2350 diff -u $testroot/content.expected $testroot/content
2351 test_done "$testroot" "$ret"
2352 return 1
2355 if [ -h $testroot/wt/dotgotfoo.link ]; then
2356 echo "dotgotfoo.link is a symlink"
2357 test_done "$testroot" "1"
2358 return 1
2361 echo "<<<<<<< merged change: commit $commit_id2" \
2362 > $testroot/content.expected
2363 echo "this is regular file foo" >> $testroot/content.expected
2364 echo "=======" >> $testroot/content.expected
2365 echo -n ".got/bar" >> $testroot/content.expected
2366 echo '>>>>>>>' >> $testroot/content.expected
2367 echo -n "" >> $testroot/content.expected
2369 cp $testroot/wt/dotgotfoo.link $testroot/content
2370 cmp -s $testroot/content.expected $testroot/content
2371 ret=$?
2372 if [ $ret -ne 0 ]; then
2373 diff -u $testroot/content.expected $testroot/content
2374 test_done "$testroot" "$ret"
2375 return 1
2378 if [ -h $testroot/wt/dotgotbar.link ]; then
2379 echo "dotgotbar.link is a symlink"
2380 test_done "$testroot" "1"
2381 return 1
2383 echo "<<<<<<< merged change: commit $commit_id2" \
2384 > $testroot/content.expected
2385 echo -n ".got/bar" >> $testroot/content.expected
2386 echo "=======" >> $testroot/content.expected
2387 echo "this is regular file bar" >> $testroot/content.expected
2388 echo '>>>>>>>' >> $testroot/content.expected
2389 echo -n "" >> $testroot/content.expected
2391 cp $testroot/wt/dotgotbar.link $testroot/content
2392 cmp -s $testroot/content.expected $testroot/content
2393 ret=$?
2394 if [ $ret -ne 0 ]; then
2395 diff -u $testroot/content.expected $testroot/content
2396 test_done "$testroot" "$ret"
2397 return 1
2400 if [ -h $testroot/wt/new.link ]; then
2401 echo "new.link is a symlink"
2402 test_done "$testroot" "1"
2403 return 1
2406 echo "<<<<<<< merged change: commit $commit_id2" \
2407 > $testroot/content.expected
2408 echo "alpha" >> $testroot/content.expected
2409 echo "=======" >> $testroot/content.expected
2410 echo "beta" >> $testroot/content.expected
2411 echo '>>>>>>>' >> $testroot/content.expected
2412 echo -n "" >> $testroot/content.expected
2414 cp $testroot/wt/new.link $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 "A dotgotfoo.link" > $testroot/stdout.expected
2424 echo "M new.link" >> $testroot/stdout.expected
2425 echo "D nonexistent.link" >> $testroot/stdout.expected
2426 (cd $testroot/wt && got status > $testroot/stdout)
2427 ret=$?
2428 if [ $ret -ne 0 ]; then
2429 diff -u $testroot/stdout.expected $testroot/stdout
2430 test_done "$testroot" "$ret"
2431 return 1
2434 test_done "$testroot" "0"
2438 test_update_single_file() {
2439 local testroot=`test_init update_single_file 1`
2441 echo c1 > $testroot/repo/c
2442 (cd $testroot/repo && git add .)
2443 git_commit $testroot/repo -m "adding file c"
2444 local commit_id1=`git_show_head $testroot/repo`
2446 echo a > $testroot/repo/a
2447 echo b > $testroot/repo/b
2448 echo c2 > $testroot/repo/c
2449 (cd $testroot/repo && git add .)
2450 git_commit $testroot/repo -m "add files a and b, change c"
2451 local commit_id2=`git_show_head $testroot/repo`
2453 (cd $testroot/repo && git rm -qf c)
2454 git_commit $testroot/repo -m "remove file c"
2455 local commit_id3=`git_show_head $testroot/repo`
2457 got checkout -c $commit_id2 $testroot/repo $testroot/wt > /dev/null
2458 ret=$?
2459 if [ $ret -ne 0 ]; then
2460 test_done "$testroot" "$ret"
2461 return 1
2464 echo "U c" > $testroot/stdout.expected
2465 echo "Updated to refs/heads/master: $commit_id1" \
2466 >> $testroot/stdout.expected
2468 (cd $testroot/wt && got update -c $commit_id1 c \
2469 > $testroot/stdout)
2471 cmp -s $testroot/stdout.expected $testroot/stdout
2472 ret=$?
2473 if [ $ret -ne 0 ]; then
2474 diff -u $testroot/stdout.expected $testroot/stdout
2475 test_done "$testroot" "$ret"
2476 return 1
2479 echo c1 > $testroot/content.expected
2480 cat $testroot/wt/c > $testroot/content
2482 cmp -s $testroot/content.expected $testroot/content
2483 ret=$?
2484 if [ $ret -ne 0 ]; then
2485 diff -u $testroot/content.expected $testroot/content
2486 test_done "$testroot" "$ret"
2487 return 1
2490 echo "U c" > $testroot/stdout.expected
2491 echo "Updated to refs/heads/master: $commit_id2" \
2492 >> $testroot/stdout.expected
2494 (cd $testroot/wt && got update -c $commit_id2 c > $testroot/stdout)
2496 cmp -s $testroot/stdout.expected $testroot/stdout
2497 ret=$?
2498 if [ $ret -ne 0 ]; then
2499 diff -u $testroot/stdout.expected $testroot/stdout
2500 test_done "$testroot" "$ret"
2501 return 1
2504 echo c2 > $testroot/content.expected
2505 cat $testroot/wt/c > $testroot/content
2507 cmp -s $testroot/content.expected $testroot/content
2508 ret=$?
2509 if [ $ret -ne 0 ]; then
2510 diff -u $testroot/content.expected $testroot/content
2511 test_done "$testroot" "$ret"
2512 return 1
2515 echo "D c" > $testroot/stdout.expected
2516 echo "Updated to refs/heads/master: $commit_id3" \
2517 >> $testroot/stdout.expected
2519 (cd $testroot/wt && got update -c $commit_id3 c \
2520 > $testroot/stdout 2> $testroot/stderr)
2522 echo "got: /c: no such entry found in tree" > $testroot/stderr.expected
2523 cmp -s $testroot/stderr.expected $testroot/stderr
2524 ret=$?
2525 if [ $ret -ne 0 ]; then
2526 diff -u $testroot/stderr.expected $testroot/stderr
2527 test_done "$testroot" "$ret"
2528 return 1
2531 echo -n > $testroot/stdout.expected
2532 cmp -s $testroot/stdout.expected $testroot/stdout
2533 ret=$?
2534 if [ $ret -ne 0 ]; then
2535 diff -u $testroot/stdout.expected $testroot/stdout
2536 test_done "$testroot" "$ret"
2537 return 1
2540 echo "D c" > $testroot/stdout.expected
2541 echo "Updated to refs/heads/master: $commit_id3" \
2542 >> $testroot/stdout.expected
2544 (cd $testroot/wt && got update -c $commit_id3 > $testroot/stdout)
2545 cmp -s $testroot/stdout.expected $testroot/stdout
2546 ret=$?
2547 if [ $ret -ne 0 ]; then
2548 diff -u $testroot/stdout.expected $testroot/stdout
2549 test_done "$testroot" "$ret"
2550 return 1
2553 if [ -e $testroot/wt/c ]; then
2554 echo "removed file c still exists on disk" >&2
2555 test_done "$testroot" "1"
2556 return 1
2559 test_done "$testroot" "0"
2560 return 0
2563 test_update_file_skipped_due_to_conflict() {
2564 local testroot=`test_init update_file_skipped_due_to_conflict`
2565 local commit_id0=`git_show_head $testroot/repo`
2566 blob_id0=`get_blob_id $testroot/repo "" beta`
2568 echo "changed beta" > $testroot/repo/beta
2569 git_commit $testroot/repo -m "changed beta"
2570 local commit_id1=`git_show_head $testroot/repo`
2571 blob_id1=`get_blob_id $testroot/repo "" beta`
2573 got checkout $testroot/repo $testroot/wt > /dev/null
2574 ret=$?
2575 if [ $ret -ne 0 ]; then
2576 test_done "$testroot" "$ret"
2577 return 1
2580 blob_id=`(cd $testroot/wt && got info beta | grep 'blob:' | \
2581 cut -d ':' -f 2 | tr -d ' ')`
2582 if [ "$blob_id" != "$blob_id1" ]; then
2583 echo "file beta has the wrong base blob ID" >&2
2584 test_done "$testroot" "1"
2585 return 1
2588 commit_id=`(cd $testroot/wt && got info beta | \
2589 grep 'based on commit:' | cut -d ':' -f 2 | tr -d ' ')`
2590 if [ "$commit_id" != "$commit_id1" ]; then
2591 echo "file beta has the wrong base commit ID" >&2
2592 test_done "$testroot" "1"
2593 return 1
2596 echo "modified beta" > $testroot/wt/beta
2598 (cd $testroot/wt && got update -c $commit_id0 > $testroot/stdout)
2600 echo "C beta" > $testroot/stdout.expected
2601 echo "Updated to refs/heads/master: $commit_id0" \
2602 >> $testroot/stdout.expected
2603 echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
2604 cmp -s $testroot/stdout.expected $testroot/stdout
2605 ret=$?
2606 if [ $ret -ne 0 ]; then
2607 diff -u $testroot/stdout.expected $testroot/stdout
2608 test_done "$testroot" "$ret"
2609 return 1
2612 echo "<<<<<<< merged change: commit $commit_id0" \
2613 > $testroot/content.expected
2614 echo "beta" >> $testroot/content.expected
2615 echo "||||||| 3-way merge base: commit $commit_id1" \
2616 >> $testroot/content.expected
2617 echo "changed beta" >> $testroot/content.expected
2618 echo "=======" >> $testroot/content.expected
2619 echo "modified beta" >> $testroot/content.expected
2620 echo ">>>>>>>" >> $testroot/content.expected
2622 cat $testroot/wt/beta > $testroot/content
2624 cmp -s $testroot/content.expected $testroot/content
2625 ret=$?
2626 if [ $ret -ne 0 ]; then
2627 diff -u $testroot/content.expected $testroot/content
2628 test_done "$testroot" "$ret"
2629 return 1
2632 blob_id=`(cd $testroot/wt && got info beta | grep 'blob:' | \
2633 cut -d ':' -f 2 | tr -d ' ')`
2634 if [ "$blob_id" != "$blob_id0" ]; then
2635 echo "file beta has the wrong base blob ID" >&2
2636 test_done "$testroot" "1"
2637 return 1
2640 commit_id=`(cd $testroot/wt && got info beta | \
2641 grep 'based on commit:' | cut -d ':' -f 2 | tr -d ' ')`
2642 if [ "$commit_id" != "$commit_id0" ]; then
2643 echo "file beta has the wrong base commit ID" >&2
2644 test_done "$testroot" "1"
2645 return 1
2648 # update to the latest commit again; this skips beta
2649 (cd $testroot/wt && got update > $testroot/stdout)
2650 echo "# beta" > $testroot/stdout.expected
2651 echo "Updated to refs/heads/master: $commit_id1" \
2652 >> $testroot/stdout.expected
2653 echo "Files not updated because of existing merge conflicts: 1" \
2654 >> $testroot/stdout.expected
2655 cmp -s $testroot/stdout.expected $testroot/stdout
2656 ret=$?
2657 if [ $ret -ne 0 ]; then
2658 diff -u $testroot/stdout.expected $testroot/stdout
2659 test_done "$testroot" "$ret"
2660 return 1
2663 # blob ID of beta should not have changed
2664 blob_id=`(cd $testroot/wt && got info beta | grep 'blob:' | \
2665 cut -d ':' -f 2 | tr -d ' ')`
2666 if [ "$blob_id" != "$blob_id0" ]; then
2667 echo "file beta has the wrong base blob ID" >&2
2668 test_done "$testroot" "1"
2669 return 1
2672 # commit ID of beta should not have changed; There was a bug
2673 # here where the commit ID had been changed even though the
2674 # file was not updated.
2675 commit_id=`(cd $testroot/wt && got info beta | \
2676 grep 'based on commit:' | cut -d ':' -f 2 | tr -d ' ')`
2677 if [ "$commit_id" != "$commit_id0" ]; then
2678 echo "file beta has the wrong base commit ID: $commit_id" >&2
2679 test_done "$testroot" "1"
2680 return 1
2683 # beta is still conflicted and based on commit 0
2684 echo 'C beta' > $testroot/stdout.expected
2685 (cd $testroot/wt && got status > $testroot/stdout)
2686 cmp -s $testroot/stdout.expected $testroot/stdout
2687 ret=$?
2688 if [ $ret -ne 0 ]; then
2689 diff -u $testroot/stdout.expected $testroot/stdout
2690 test_done "$testroot" "$ret"
2691 return 1
2694 # resolve the conflict via revert
2695 (cd $testroot/wt && got revert beta >/dev/null)
2697 # beta now matches its base blob which is still from commit 0
2698 echo "beta" > $testroot/content.expected
2699 cat $testroot/wt/beta > $testroot/content
2700 cmp -s $testroot/content.expected $testroot/content
2701 ret=$?
2702 if [ $ret -ne 0 ]; then
2703 diff -u $testroot/content.expected $testroot/content
2704 test_done "$testroot" "$ret"
2705 return 1
2708 # updating to the latest commit should now update beta
2709 (cd $testroot/wt && got update > $testroot/stdout)
2710 echo "U beta" > $testroot/stdout.expected
2711 echo "Updated to refs/heads/master: $commit_id1" \
2712 >> $testroot/stdout.expected
2713 cmp -s $testroot/stdout.expected $testroot/stdout
2714 ret=$?
2715 if [ $ret -ne 0 ]; then
2716 diff -u $testroot/stdout.expected $testroot/stdout
2717 test_done "$testroot" "$ret"
2718 return 1
2721 blob_id=`(cd $testroot/wt && got info beta | grep 'blob:' | \
2722 cut -d ':' -f 2 | tr -d ' ')`
2723 if [ "$blob_id" != "$blob_id1" ]; then
2724 echo "file beta has the wrong base blob ID" >&2
2725 test_done "$testroot" "1"
2726 return 1
2729 commit_id=`(cd $testroot/wt && got info beta | \
2730 grep 'based on commit:' | cut -d ':' -f 2 | tr -d ' ')`
2731 if [ "$commit_id" != "$commit_id1" ]; then
2732 echo "file beta has the wrong base commit ID: $commit_id" >&2
2733 test_done "$testroot" "1"
2734 return 1
2737 echo "changed beta" > $testroot/content.expected
2738 cat $testroot/wt/beta > $testroot/content
2739 cmp -s $testroot/content.expected $testroot/content
2740 ret=$?
2741 if [ $ret -ne 0 ]; then
2742 diff -u $testroot/content.expected $testroot/content
2744 test_done "$testroot" "$ret"
2747 test_update_file_skipped_due_to_obstruction() {
2748 local testroot=`test_init update_file_skipped_due_to_obstruction`
2749 local commit_id0=`git_show_head $testroot/repo`
2750 blob_id0=`get_blob_id $testroot/repo "" beta`
2752 echo "changed beta" > $testroot/repo/beta
2753 echo "new file" > $testroot/repo/new
2754 (cd $testroot/repo && git add new)
2755 git_commit $testroot/repo -m "changed beta"
2756 local commit_id1=`git_show_head $testroot/repo`
2757 blob_id1=`get_blob_id $testroot/repo "" beta`
2759 got checkout -c $commit_id0 $testroot/repo $testroot/wt > /dev/null
2760 ret=$?
2761 if [ $ret -ne 0 ]; then
2762 test_done "$testroot" "$ret"
2763 return 1
2766 blob_id=`(cd $testroot/wt && got info beta | grep 'blob:' | \
2767 cut -d ':' -f 2 | tr -d ' ')`
2768 if [ "$blob_id" != "$blob_id0" ]; then
2769 echo "file beta has the wrong base blob ID" >&2
2770 test_done "$testroot" "1"
2771 return 1
2774 commit_id=`(cd $testroot/wt && got info beta | \
2775 grep 'based on commit:' | cut -d ':' -f 2 | tr -d ' ')`
2776 if [ "$commit_id" != "$commit_id0" ]; then
2777 echo "file beta has the wrong base commit ID" >&2
2778 test_done "$testroot" "1"
2779 return 1
2782 rm $testroot/wt/beta
2783 mkdir -p $testroot/wt/beta/psi
2784 mkdir -p $testroot/wt/new
2786 # update to the latest commit; this skips beta and the new file
2787 (cd $testroot/wt && got update > $testroot/stdout)
2788 ret=$?
2789 if [ $ret -ne 0 ]; then
2790 echo "update failed unexpectedly" >&2
2791 test_done "$testroot" "1"
2792 return 1
2795 echo "~ beta" > $testroot/stdout.expected
2796 echo "~ new" >> $testroot/stdout.expected
2797 echo "Updated to refs/heads/master: $commit_id1" \
2798 >> $testroot/stdout.expected
2799 echo "File paths obstructed by a non-regular file: 2" \
2800 >> $testroot/stdout.expected
2801 cmp -s $testroot/stdout.expected $testroot/stdout
2802 ret=$?
2803 if [ $ret -ne 0 ]; then
2804 diff -u $testroot/stdout.expected $testroot/stdout
2805 test_done "$testroot" "$ret"
2806 return 1
2809 blob_id=`(cd $testroot/wt && got info beta | grep 'blob:' | \
2810 cut -d ':' -f 2 | tr -d ' ')`
2811 if [ "$blob_id" != "$blob_id0" ]; then
2812 echo "file beta has the wrong base blob ID" >&2
2813 test_done "$testroot" "1"
2814 return 1
2817 commit_id=`(cd $testroot/wt && got info beta | \
2818 grep 'based on commit:' | cut -d ':' -f 2 | tr -d ' ')`
2819 if [ "$commit_id" != "$commit_id0" ]; then
2820 echo "file beta has the wrong base commit ID" >&2
2821 test_done "$testroot" "1"
2822 return 1
2825 # remove the directory which obstructs file beta
2826 rm -r $testroot/wt/beta
2828 # updating to the latest commit should now update beta
2829 (cd $testroot/wt && got update > $testroot/stdout)
2830 echo "! beta" > $testroot/stdout.expected
2831 echo "~ new" >> $testroot/stdout.expected
2832 echo "Updated to refs/heads/master: $commit_id1" \
2833 >> $testroot/stdout.expected
2834 echo "File paths obstructed by a non-regular file: 1" \
2835 >> $testroot/stdout.expected
2836 cmp -s $testroot/stdout.expected $testroot/stdout
2837 ret=$?
2838 if [ $ret -ne 0 ]; then
2839 diff -u $testroot/stdout.expected $testroot/stdout
2840 test_done "$testroot" "$ret"
2841 return 1
2844 blob_id=`(cd $testroot/wt && got info beta | grep 'blob:' | \
2845 cut -d ':' -f 2 | tr -d ' ')`
2846 if [ "$blob_id" != "$blob_id1" ]; then
2847 echo "file beta has the wrong base blob ID" >&2
2848 test_done "$testroot" "1"
2849 return 1
2852 commit_id=`(cd $testroot/wt && got info beta | \
2853 grep 'based on commit:' | cut -d ':' -f 2 | tr -d ' ')`
2854 if [ "$commit_id" != "$commit_id1" ]; then
2855 echo "file beta has the wrong base commit ID: $commit_id" >&2
2856 test_done "$testroot" "1"
2857 return 1
2860 echo "changed beta" > $testroot/content.expected
2861 cat $testroot/wt/beta > $testroot/content
2862 cmp -s $testroot/content.expected $testroot/content
2863 ret=$?
2864 if [ $ret -ne 0 ]; then
2865 diff -u $testroot/content.expected $testroot/content
2867 test_done "$testroot" "$ret"
2870 test_update_quiet() {
2871 local testroot=`test_init update_quiet`
2873 got checkout $testroot/repo $testroot/wt > /dev/null
2874 ret=$?
2875 if [ $ret -ne 0 ]; then
2876 test_done "$testroot" "$ret"
2877 return 1
2880 echo "modified alpha" > $testroot/repo/alpha
2881 git_commit $testroot/repo -m "modified alpha"
2883 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
2884 git_show_head $testroot/repo >> $testroot/stdout.expected
2885 echo >> $testroot/stdout.expected
2887 (cd $testroot/wt && got update -q > $testroot/stdout)
2889 cmp -s $testroot/stdout.expected $testroot/stdout
2890 ret=$?
2891 if [ $ret -ne 0 ]; then
2892 diff -u $testroot/stdout.expected $testroot/stdout
2893 test_done "$testroot" "$ret"
2894 return 1
2897 echo "modified alpha" > $testroot/content.expected
2898 cat $testroot/wt/alpha > $testroot/content
2900 cmp -s $testroot/content.expected $testroot/content
2901 ret=$?
2902 if [ $ret -ne 0 ]; then
2903 diff -u $testroot/content.expected $testroot/content
2905 test_done "$testroot" "$ret"
2908 test_update_binary_file() {
2909 local testroot=`test_init update_binary_file`
2910 local commit_id0=`git_show_head $testroot/repo`
2912 got checkout $testroot/repo $testroot/wt > /dev/null
2913 ret=$?
2914 if [ $ret -ne 0 ]; then
2915 test_done "$testroot" "$ret"
2916 return 1
2919 cp /bin/ls $testroot/wt/foo
2920 chmod 755 $testroot/wt/foo
2921 (cd $testroot/wt && got add foo >/dev/null)
2922 (cd $testroot/wt && got commit -m 'add binary file' > /dev/null)
2923 local commit_id1=`git_show_head $testroot/repo`
2925 cp /bin/cat $testroot/wt/foo
2926 chmod 755 $testroot/wt/foo
2927 (cd $testroot/wt && got commit -m 'change binary file' > /dev/null)
2928 local commit_id2=`git_show_head $testroot/repo`
2930 cp /bin/cp $testroot/wt/foo
2931 chmod 755 $testroot/wt/foo
2932 (cd $testroot/wt && got commit -m 'change binary file' > /dev/null)
2933 local commit_id3=`git_show_head $testroot/repo`
2935 (cd $testroot/wt && got rm foo >/dev/null)
2936 (cd $testroot/wt && got commit -m 'remove binary file' > /dev/null)
2937 local commit_id4=`git_show_head $testroot/repo`
2939 # backdate the work tree to make it usable for updating
2940 (cd $testroot/wt && got up -c $commit_id0 > /dev/null)
2942 # update which adds a binary file
2943 (cd $testroot/wt && got up -c $commit_id1 > $testroot/stdout)
2945 echo "A foo" > $testroot/stdout.expected
2946 echo -n "Updated to refs/heads/master: $commit_id1" \
2947 >> $testroot/stdout.expected
2948 echo >> $testroot/stdout.expected
2949 cmp -s $testroot/stdout.expected $testroot/stdout
2950 ret=$?
2951 if [ $ret -ne 0 ]; then
2952 diff -u $testroot/stdout.expected $testroot/stdout
2953 test_done "$testroot" "$ret"
2954 return 1
2957 cp /bin/ls $testroot/content.expected
2958 chmod 755 $testroot/content.expected
2959 cat $testroot/wt/foo > $testroot/content
2961 cmp -s $testroot/content.expected $testroot/content
2962 ret=$?
2963 if [ $ret -ne 0 ]; then
2964 diff -u $testroot/content.expected $testroot/content
2965 test_done "$testroot" "$ret"
2966 return 1
2969 # update which adds a conflicting binary file
2970 (cd $testroot/wt && got up -c $commit_id0 > /dev/null)
2971 cp /bin/cat $testroot/wt/foo
2972 chmod 755 $testroot/wt/foo
2973 (cd $testroot/wt && got add foo > /dev/null)
2974 (cd $testroot/wt && got up -c $commit_id1 > $testroot/stdout)
2976 echo "C foo" > $testroot/stdout.expected
2977 echo "Updated to refs/heads/master: $commit_id1" \
2978 >> $testroot/stdout.expected
2979 echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
2980 cmp -s $testroot/stdout.expected $testroot/stdout
2981 ret=$?
2982 if [ $ret -ne 0 ]; then
2983 diff -u $testroot/stdout.expected $testroot/stdout
2984 test_done "$testroot" "$ret"
2985 return 1
2988 echo "Binary files differ and cannot be merged automatically:" \
2989 > $testroot/content.expected
2990 echo "<<<<<<< merged change: commit $commit_id1" \
2991 >> $testroot/content.expected
2992 echo -n "file " >> $testroot/content.expected
2993 ls $testroot/wt/foo-1-* >> $testroot/content.expected
2994 echo '=======' >> $testroot/content.expected
2995 echo -n "file " >> $testroot/content.expected
2996 ls $testroot/wt/foo-2-* >> $testroot/content.expected
2997 echo ">>>>>>>" >> $testroot/content.expected
2998 cat $testroot/wt/foo > $testroot/content
3000 cmp -s $testroot/content.expected $testroot/content
3001 ret=$?
3002 if [ $ret -ne 0 ]; then
3003 diff -u $testroot/content.expected $testroot/content
3004 test_done "$testroot" "$ret"
3005 return 1
3008 cp /bin/ls $testroot/content.expected
3009 chmod 755 $testroot/content.expected
3010 cat $testroot/wt/foo-1-* > $testroot/content
3012 cmp -s $testroot/content.expected $testroot/content
3013 ret=$?
3014 if [ $ret -ne 0 ]; then
3015 diff -u $testroot/content.expected $testroot/content
3016 test_done "$testroot" "$ret"
3017 return 1
3020 cp /bin/cat $testroot/content.expected
3021 chmod 755 $testroot/content.expected
3022 cat $testroot/wt/foo-2-* > $testroot/content
3024 cmp -s $testroot/content.expected $testroot/content
3025 ret=$?
3026 if [ $ret -ne 0 ]; then
3027 diff -u $testroot/content.expected $testroot/content
3028 test_done "$testroot" "$ret"
3029 return 1
3032 # tidy up
3033 (cd $testroot/wt && got revert -R . >/dev/null)
3034 rm $testroot/wt/foo-1-* $testroot/wt/foo-2-*
3035 (cd $testroot/wt && got up -c $commit_id1 > /dev/null)
3037 # update which changes a binary file
3038 (cd $testroot/wt && got up -c $commit_id2 > $testroot/stdout)
3040 echo "U foo" > $testroot/stdout.expected
3041 echo -n "Updated to refs/heads/master: $commit_id2" \
3042 >> $testroot/stdout.expected
3043 echo >> $testroot/stdout.expected
3044 cmp -s $testroot/stdout.expected $testroot/stdout
3045 ret=$?
3046 if [ $ret -ne 0 ]; then
3047 diff -u $testroot/stdout.expected $testroot/stdout
3048 test_done "$testroot" "$ret"
3049 return 1
3052 cp /bin/cat $testroot/content.expected
3053 chmod 755 $testroot/content.expected
3054 cat $testroot/wt/foo > $testroot/content
3056 cmp -s $testroot/content.expected $testroot/content
3057 ret=$?
3058 if [ $ret -ne 0 ]; then
3059 diff -u $testroot/content.expected $testroot/content
3060 test_done "$testroot" "$ret"
3061 return 1
3064 # update which changes a locally modified binary file
3065 cp /bin/ls $testroot/wt/foo
3066 chmod 755 $testroot/wt/foo
3067 (cd $testroot/wt && got up -c $commit_id3 > $testroot/stdout)
3069 echo "C foo" > $testroot/stdout.expected
3070 echo -n "Updated to refs/heads/master: $commit_id3" \
3071 >> $testroot/stdout.expected
3072 echo >> $testroot/stdout.expected
3073 echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
3074 cmp -s $testroot/stdout.expected $testroot/stdout
3075 ret=$?
3076 if [ $ret -ne 0 ]; then
3077 diff -u $testroot/stdout.expected $testroot/stdout
3078 test_done "$testroot" "$ret"
3079 return 1
3082 echo "Binary files differ and cannot be merged automatically:" \
3083 > $testroot/content.expected
3084 echo "<<<<<<< merged change: commit $commit_id3" \
3085 >> $testroot/content.expected
3086 echo -n "file " >> $testroot/content.expected
3087 ls $testroot/wt/foo-1-* >> $testroot/content.expected
3088 echo "||||||| 3-way merge base: commit $commit_id2" \
3089 >> $testroot/content.expected
3090 echo -n "file " >> $testroot/content.expected
3091 ls $testroot/wt/foo-orig-* >> $testroot/content.expected
3092 echo '=======' >> $testroot/content.expected
3093 echo -n "file " >> $testroot/content.expected
3094 ls $testroot/wt/foo-2-* >> $testroot/content.expected
3095 echo ">>>>>>>" >> $testroot/content.expected
3096 cat $testroot/wt/foo > $testroot/content
3098 cmp -s $testroot/content.expected $testroot/content
3099 ret=$?
3100 if [ $ret -ne 0 ]; then
3101 diff -u $testroot/content.expected $testroot/content
3102 test_done "$testroot" "$ret"
3103 return 1
3106 cp /bin/cp $testroot/content.expected
3107 chmod 755 $testroot/content.expected
3108 cp $testroot/wt/foo-1-* $testroot/content
3109 cmp -s $testroot/content.expected $testroot/content
3110 ret=$?
3111 if [ $ret -ne 0 ]; then
3112 diff -u $testroot/content.expected $testroot/content
3113 test_done "$testroot" "$ret"
3114 return 1
3117 cp /bin/ls $testroot/content.expected
3118 chmod 755 $testroot/content.expected
3119 cp $testroot/wt/foo-2-* $testroot/content
3120 cmp -s $testroot/content.expected $testroot/content
3121 ret=$?
3122 if [ $ret -ne 0 ]; then
3123 diff -u $testroot/content.expected $testroot/content
3124 test_done "$testroot" "$ret"
3125 return 1
3128 (cd $testroot/wt && got status > $testroot/stdout)
3129 echo 'C foo' > $testroot/stdout.expected
3130 echo -n '? ' >> $testroot/stdout.expected
3131 (cd $testroot/wt && ls foo-1-* >> $testroot/stdout.expected)
3132 echo -n '? ' >> $testroot/stdout.expected
3133 (cd $testroot/wt && ls foo-2-* >> $testroot/stdout.expected)
3134 echo -n '? ' >> $testroot/stdout.expected
3135 (cd $testroot/wt && ls foo-orig-* >> $testroot/stdout.expected)
3136 cmp -s $testroot/stdout.expected $testroot/stdout
3137 ret=$?
3138 if [ $ret -ne 0 ]; then
3139 diff -u $testroot/stdout.expected $testroot/stdout
3140 test_done "$testroot" "$ret"
3141 return 1
3144 # tidy up
3145 (cd $testroot/wt && got revert -R . > /dev/null)
3146 rm $testroot/wt/foo-orig-* $testroot/wt/foo-1-* $testroot/wt/foo-2-*
3148 # update which deletes a binary file
3149 (cd $testroot/wt && got up -c $commit_id4 > $testroot/stdout)
3150 echo "D foo" > $testroot/stdout.expected
3151 echo -n "Updated to refs/heads/master: $commit_id4" \
3152 >> $testroot/stdout.expected
3153 echo >> $testroot/stdout.expected
3154 cmp -s $testroot/stdout.expected $testroot/stdout
3155 ret=$?
3156 if [ $ret -ne 0 ]; then
3157 diff -u $testroot/stdout.expected $testroot/stdout
3158 test_done "$testroot" "$ret"
3161 if [ -e $testroot/wt/foo ]; then
3162 echo "removed file foo still exists on disk" >&2
3163 test_done "$testroot" "1"
3164 return 1
3166 test_done "$testroot" "0"
3169 test_update_umask() {
3170 local testroot=`test_init update_binary_file`
3172 got checkout "$testroot/repo" "$testroot/wt" >/dev/null
3173 ret=$?
3174 if [ $ret -ne 0 ]; then
3175 test_done "$testroot" "$ret"
3176 return 1
3179 rm "$testroot/wt/alpha"
3181 # using a subshell to avoid clobbering global umask
3182 (umask 022 && cd "$testroot/wt" && got update alpha) \
3183 >/dev/null 2>/dev/null
3184 ret=$?
3185 if [ $ret -ne 0 ]; then
3186 test_done "$testroot" $ret
3187 return 1
3190 if ! ls -l "$testroot/wt/alpha" | grep -q ^-rw-r--r--; then
3191 echo "alpha is not 0644" >&2
3192 test_done "$testroot" 1
3193 return 1
3196 rm "$testroot/wt/alpha"
3198 # using a subshell to avoid clobbering global umask
3199 (umask 044 && cd "$testroot/wt" && got update alpha) \
3200 >/dev/null 2>/dev/null
3201 ret=$?
3202 if [ $ret -ne 0 ]; then
3203 test_done "$testroot" $ret
3204 return 1
3207 if ! ls -l "$testroot/wt/alpha" | grep -q ^-rw-------; then
3208 echo "alpha is not 0600" >&2
3209 test_done "$testroot" 1
3210 return 1
3213 rm "$testroot/wt/alpha"
3215 # using a subshell to avoid clobbering global umask
3216 (umask 222 && cd "$testroot/wt" && got update alpha) \
3217 >/dev/null 2>/dev/null
3218 ret=$?
3219 if [ $ret -ne 0 ]; then
3220 test_done "$testroot" $ret
3221 return 1
3224 if ! ls -l "$testroot/wt/alpha" | grep -q ^-r--r--r--; then
3225 echo "alpha is not 0444" >&2
3226 test_done "$testroot" 1
3227 return 1;
3230 test_done "$testroot" 0
3233 test_parseargs "$@"
3234 run_test test_update_basic
3235 run_test test_update_adds_file
3236 run_test test_update_deletes_file
3237 run_test test_update_deletes_dir
3238 run_test test_update_deletes_dir_with_path_prefix
3239 run_test test_update_deletes_dir_recursively
3240 run_test test_update_sibling_dirs_with_common_prefix
3241 run_test test_update_dir_with_dot_sibling
3242 run_test test_update_moves_files_upwards
3243 run_test test_update_moves_files_to_new_dir
3244 run_test test_update_creates_missing_parent
3245 run_test test_update_creates_missing_parent_with_subdir
3246 run_test test_update_file_in_subsubdir
3247 run_test test_update_changes_file_to_dir
3248 run_test test_update_changes_dir_to_file
3249 run_test test_update_changes_modified_file_to_dir
3250 run_test test_update_merges_file_edits
3251 run_test test_update_keeps_xbit
3252 run_test test_update_clears_xbit
3253 run_test test_update_restores_missing_file
3254 run_test test_update_conflict_wt_add_vs_repo_add
3255 run_test test_update_conflict_wt_edit_vs_repo_rm
3256 run_test test_update_conflict_wt_rm_vs_repo_edit
3257 run_test test_update_conflict_wt_rm_vs_repo_rm
3258 run_test test_update_partial
3259 run_test test_update_partial_add
3260 run_test test_update_partial_rm
3261 run_test test_update_partial_dir
3262 run_test test_update_moved_branch_ref
3263 run_test test_update_to_another_branch
3264 run_test test_update_to_commit_on_wrong_branch
3265 run_test test_update_bumps_base_commit_id
3266 run_test test_update_tag
3267 run_test test_update_toggles_xbit
3268 run_test test_update_preserves_conflicted_file
3269 run_test test_update_modified_submodules
3270 run_test test_update_adds_submodule
3271 run_test test_update_conflict_wt_file_vs_repo_submodule
3272 run_test test_update_adds_symlink
3273 run_test test_update_deletes_symlink
3274 run_test test_update_symlink_conflicts
3275 run_test test_update_single_file
3276 run_test test_update_file_skipped_due_to_conflict
3277 run_test test_update_file_skipped_due_to_obstruction
3278 run_test test_update_quiet
3279 run_test test_update_binary_file
3280 run_test test_update_umask