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 # This update only records the new base commit. Otherwise it is a
1903 # no-op change because Got's file index does not track submodules.
1904 echo -n "Updated to refs/heads/master: " > $testroot/stdout.expected
1905 git_show_head $testroot/repo >> $testroot/stdout.expected
1906 echo >> $testroot/stdout.expected
1908 (cd $testroot/wt && got update > $testroot/stdout)
1910 cmp -s $testroot/stdout.expected $testroot/stdout
1911 ret=$?
1912 if [ $ret -ne 0 ]; then
1913 diff -u $testroot/stdout.expected $testroot/stdout
1915 test_done "$testroot" "$ret"
1918 test_update_adds_submodule() {
1919 local testroot=`test_init update_adds_submodule`
1921 got checkout $testroot/repo $testroot/wt > /dev/null
1923 make_single_file_repo $testroot/repo2 foo
1925 echo "modified foo" > $testroot/repo2/foo
1926 (cd $testroot/repo2 && git commit -q -a -m 'modified a submodule')
1928 (cd $testroot/repo && git -c protocol.file.allow=always \
1929 submodule -q add ../repo2)
1930 (cd $testroot/repo && git commit -q -m 'adding submodule')
1932 echo "A .gitmodules" > $testroot/stdout.expected
1933 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
1934 git_show_head $testroot/repo >> $testroot/stdout.expected
1935 echo >> $testroot/stdout.expected
1937 (cd $testroot/wt && got update > $testroot/stdout)
1939 cmp -s $testroot/stdout.expected $testroot/stdout
1940 ret=$?
1941 if [ $ret -ne 0 ]; then
1942 diff -u $testroot/stdout.expected $testroot/stdout
1944 test_done "$testroot" "$ret"
1947 test_update_conflict_wt_file_vs_repo_submodule() {
1948 local testroot=`test_init update_conflict_wt_file_vs_repo_submodule`
1950 got checkout $testroot/repo $testroot/wt > /dev/null
1952 make_single_file_repo $testroot/repo2 foo
1954 # Add a file which will clash with the submodule
1955 echo "This is a file called repo2" > $testroot/wt/repo2
1956 (cd $testroot/wt && got add repo2 > /dev/null)
1957 (cd $testroot/wt && got commit -m 'add file repo2' > /dev/null)
1958 ret=$?
1959 if [ $ret -ne 0 ]; then
1960 echo "commit failed unexpectedly" >&2
1961 test_done "$testroot" "1"
1962 return 1
1965 (cd $testroot/repo && git -c protocol.file.allow=always \
1966 submodule -q add ../repo2)
1967 (cd $testroot/repo && git commit -q -m 'adding submodule')
1969 # Modify the clashing file such that any modifications brought
1970 # in by 'got update' would require a merge.
1971 echo "This file was changed" > $testroot/wt/repo2
1973 # No conflict occurs because 'got update' ignores the submodule
1974 # and leaves the clashing file as it was.
1975 echo "A .gitmodules" > $testroot/stdout.expected
1976 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
1977 git_show_head $testroot/repo >> $testroot/stdout.expected
1978 echo >> $testroot/stdout.expected
1980 (cd $testroot/wt && got update > $testroot/stdout)
1982 cmp -s $testroot/stdout.expected $testroot/stdout
1983 ret=$?
1984 if [ $ret -ne 0 ]; then
1985 diff -u $testroot/stdout.expected $testroot/stdout
1986 test_done "$testroot" "$ret"
1987 return 1
1990 (cd $testroot/wt && got status > $testroot/stdout)
1992 echo "M repo2" > $testroot/stdout.expected
1993 cmp -s $testroot/stdout.expected $testroot/stdout
1994 ret=$?
1995 if [ $ret -ne 0 ]; then
1996 diff -u $testroot/stdout.expected $testroot/stdout
1998 test_done "$testroot" "$ret"
2001 test_update_adds_symlink() {
2002 local testroot=`test_init update_adds_symlink`
2004 got checkout $testroot/repo $testroot/wt > /dev/null
2005 ret=$?
2006 if [ $ret -ne 0 ]; then
2007 echo "checkout failed unexpectedly" >&2
2008 test_done "$testroot" "$ret"
2009 return 1
2012 (cd $testroot/repo && ln -s alpha alpha.link)
2013 (cd $testroot/repo && ln -s epsilon epsilon.link)
2014 (cd $testroot/repo && ln -s /etc/passwd passwd.link)
2015 (cd $testroot/repo && ln -s ../beta epsilon/beta.link)
2016 (cd $testroot/repo && ln -s nonexistent nonexistent.link)
2017 (cd $testroot/repo && git add .)
2018 git_commit $testroot/repo -m "add symlinks"
2020 echo "A alpha.link" > $testroot/stdout.expected
2021 echo "A epsilon/beta.link" >> $testroot/stdout.expected
2022 echo "A epsilon.link" >> $testroot/stdout.expected
2023 echo "A nonexistent.link" >> $testroot/stdout.expected
2024 echo "A passwd.link" >> $testroot/stdout.expected
2025 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
2026 git_show_head $testroot/repo >> $testroot/stdout.expected
2027 echo >> $testroot/stdout.expected
2029 (cd $testroot/wt && got update > $testroot/stdout)
2031 cmp -s $testroot/stdout.expected $testroot/stdout
2032 ret=$?
2033 if [ $ret -ne 0 ]; then
2034 diff -u $testroot/stdout.expected $testroot/stdout
2035 test_done "$testroot" "$ret"
2036 return 1
2039 if ! [ -h $testroot/wt/alpha.link ]; then
2040 echo "alpha.link is not a symlink"
2041 test_done "$testroot" "1"
2042 return 1
2045 readlink $testroot/wt/alpha.link > $testroot/stdout
2046 echo "alpha" > $testroot/stdout.expected
2047 cmp -s $testroot/stdout.expected $testroot/stdout
2048 ret=$?
2049 if [ $ret -ne 0 ]; then
2050 diff -u $testroot/stdout.expected $testroot/stdout
2051 test_done "$testroot" "$ret"
2052 return 1
2055 if ! [ -h $testroot/wt/epsilon.link ]; then
2056 echo "epsilon.link is not a symlink"
2057 test_done "$testroot" "1"
2058 return 1
2061 readlink $testroot/wt/epsilon.link > $testroot/stdout
2062 echo "epsilon" > $testroot/stdout.expected
2063 cmp -s $testroot/stdout.expected $testroot/stdout
2064 ret=$?
2065 if [ $ret -ne 0 ]; then
2066 diff -u $testroot/stdout.expected $testroot/stdout
2067 test_done "$testroot" "$ret"
2068 return 1
2071 if [ -h $testroot/wt/passwd.link ]; then
2072 echo -n "passwd.link symlink points outside of work tree: " >&2
2073 readlink $testroot/wt/passwd.link >&2
2074 test_done "$testroot" "1"
2075 return 1
2078 echo -n "/etc/passwd" > $testroot/content.expected
2079 cp $testroot/wt/passwd.link $testroot/content
2081 cmp -s $testroot/content.expected $testroot/content
2082 ret=$?
2083 if [ $ret -ne 0 ]; then
2084 diff -u $testroot/content.expected $testroot/content
2085 test_done "$testroot" "$ret"
2086 return 1
2089 readlink $testroot/wt/epsilon/beta.link > $testroot/stdout
2090 echo "../beta" > $testroot/stdout.expected
2091 cmp -s $testroot/stdout.expected $testroot/stdout
2092 ret=$?
2093 if [ $ret -ne 0 ]; then
2094 diff -u $testroot/stdout.expected $testroot/stdout
2095 test_done "$testroot" "$ret"
2096 return 1
2099 readlink $testroot/wt/nonexistent.link > $testroot/stdout
2100 echo "nonexistent" > $testroot/stdout.expected
2101 cmp -s $testroot/stdout.expected $testroot/stdout
2102 ret=$?
2103 if [ $ret -ne 0 ]; then
2104 diff -u $testroot/stdout.expected $testroot/stdout
2105 test_done "$testroot" "$ret"
2106 return 1
2109 # Updating an up-to-date symlink should be a no-op.
2110 echo 'Already up-to-date' > $testroot/stdout.expected
2111 (cd $testroot/wt && got update > $testroot/stdout)
2112 cmp -s $testroot/stdout.expected $testroot/stdout
2113 ret=$?
2114 if [ $ret -ne 0 ]; then
2115 diff -u $testroot/stdout.expected $testroot/stdout
2117 test_done "$testroot" "$ret"
2120 test_update_deletes_symlink() {
2121 local testroot=`test_init update_deletes_symlink`
2123 (cd $testroot/repo && ln -s alpha alpha.link)
2124 (cd $testroot/repo && git add .)
2125 git_commit $testroot/repo -m "add symlink"
2127 got checkout $testroot/repo $testroot/wt > /dev/null
2128 ret=$?
2129 if [ $ret -ne 0 ]; then
2130 echo "checkout failed unexpectedly" >&2
2131 test_done "$testroot" "$ret"
2132 return 1
2135 (cd $testroot/repo && git rm -q alpha.link)
2136 git_commit $testroot/repo -m "delete symlink"
2138 echo "D alpha.link" > $testroot/stdout.expected
2139 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
2140 git_show_head $testroot/repo >> $testroot/stdout.expected
2141 echo >> $testroot/stdout.expected
2143 (cd $testroot/wt && got update > $testroot/stdout)
2145 cmp -s $testroot/stdout.expected $testroot/stdout
2146 ret=$?
2147 if [ $ret -ne 0 ]; then
2148 diff -u $testroot/stdout.expected $testroot/stdout
2149 test_done "$testroot" "$ret"
2150 return 1
2153 if [ -e $testroot/wt/alpha.link ]; then
2154 echo "alpha.link still exists on disk"
2155 test_done "$testroot" "1"
2156 return 1
2159 test_done "$testroot" "0"
2162 test_update_symlink_conflicts() {
2163 local testroot=`test_init update_symlink_conflicts`
2165 (cd $testroot/repo && ln -s alpha alpha.link)
2166 (cd $testroot/repo && ln -s epsilon epsilon.link)
2167 (cd $testroot/repo && ln -s /etc/passwd passwd.link)
2168 (cd $testroot/repo && ln -s ../beta epsilon/beta.link)
2169 (cd $testroot/repo && ln -s nonexistent nonexistent.link)
2170 (cd $testroot/repo && ln -sf epsilon/zeta zeta.link)
2171 (cd $testroot/repo && git add .)
2172 git_commit $testroot/repo -m "add symlinks"
2173 local commit_id1=`git_show_head $testroot/repo`
2175 got checkout $testroot/repo $testroot/wt > /dev/null
2176 ret=$?
2177 if [ $ret -ne 0 ]; then
2178 echo "checkout failed unexpectedly" >&2
2179 test_done "$testroot" "$ret"
2180 return 1
2183 (cd $testroot/repo && ln -sf beta alpha.link)
2184 (cd $testroot/repo && rm epsilon.link && ln -s gamma epsilon.link)
2185 (cd $testroot/repo && ln -sf ../gamma/delta epsilon/beta.link)
2186 echo 'this is regular file foo' > $testroot/repo/dotgotfoo.link
2187 (cd $testroot/repo && ln -sf .got/bar dotgotbar.link)
2188 (cd $testroot/repo && git rm -q nonexistent.link)
2189 (cd $testroot/repo && ln -sf gamma/delta zeta.link)
2190 (cd $testroot/repo && ln -sf alpha new.link)
2191 (cd $testroot/repo && git add .)
2192 git_commit $testroot/repo -m "change symlinks"
2193 local commit_id2=`git_show_head $testroot/repo`
2195 # modified symlink to file A vs modified symlink to file B
2196 (cd $testroot/wt && ln -sf gamma/delta alpha.link)
2197 # modified symlink to dir A vs modified symlink to file B
2198 (cd $testroot/wt && rm epsilon.link && ln -s beta epsilon.link)
2199 # modeified symlink to file A vs modified symlink to dir B
2200 (cd $testroot/wt && rm epsilon/beta.link && ln -s ../gamma \
2201 epsilon/beta.link)
2202 # added regular file A vs added bad symlink to file A
2203 (cd $testroot/wt && ln -sf .got/bar dotgotfoo.link)
2204 (cd $testroot/wt && got add dotgotfoo.link > /dev/null)
2205 # added bad symlink to file A vs added regular file A
2206 echo 'this is regular file bar' > $testroot/wt/dotgotbar.link
2207 (cd $testroot/wt && got add dotgotbar.link > /dev/null)
2208 # removed symlink to non-existent file A vs modified symlink
2209 # to nonexistent file B
2210 (cd $testroot/wt && ln -sf nonexistent2 nonexistent.link)
2211 # modified symlink to file A vs removed symlink to file A
2212 (cd $testroot/wt && got rm zeta.link > /dev/null)
2213 # added symlink to file A vs added symlink to file B
2214 (cd $testroot/wt && ln -sf beta new.link)
2215 (cd $testroot/wt && got add new.link > /dev/null)
2217 (cd $testroot/wt && got update > $testroot/stdout)
2219 echo "C alpha.link" >> $testroot/stdout.expected
2220 echo "C dotgotbar.link" >> $testroot/stdout.expected
2221 echo "C dotgotfoo.link" >> $testroot/stdout.expected
2222 echo "C epsilon/beta.link" >> $testroot/stdout.expected
2223 echo "C epsilon.link" >> $testroot/stdout.expected
2224 echo "C new.link" >> $testroot/stdout.expected
2225 echo "C nonexistent.link" >> $testroot/stdout.expected
2226 echo "G zeta.link" >> $testroot/stdout.expected
2227 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
2228 git_show_head $testroot/repo >> $testroot/stdout.expected
2229 echo >> $testroot/stdout.expected
2230 echo "Files with new merge conflicts: 7" >> $testroot/stdout.expected
2232 cmp -s $testroot/stdout.expected $testroot/stdout
2233 ret=$?
2234 if [ $ret -ne 0 ]; then
2235 diff -u $testroot/stdout.expected $testroot/stdout
2236 test_done "$testroot" "$ret"
2237 return 1
2240 if [ -h $testroot/wt/alpha.link ]; then
2241 echo "alpha.link is a symlink"
2242 test_done "$testroot" "1"
2243 return 1
2246 echo "<<<<<<< merged change: commit $commit_id2" \
2247 > $testroot/content.expected
2248 echo "beta" >> $testroot/content.expected
2249 echo "3-way merge base: commit $commit_id1" \
2250 >> $testroot/content.expected
2251 echo "alpha" >> $testroot/content.expected
2252 echo "=======" >> $testroot/content.expected
2253 echo "gamma/delta" >> $testroot/content.expected
2254 echo '>>>>>>>' >> $testroot/content.expected
2255 echo -n "" >> $testroot/content.expected
2257 cp $testroot/wt/alpha.link $testroot/content
2258 cmp -s $testroot/content.expected $testroot/content
2259 ret=$?
2260 if [ $ret -ne 0 ]; then
2261 diff -u $testroot/content.expected $testroot/content
2262 test_done "$testroot" "$ret"
2263 return 1
2266 if [ -h $testroot/wt/epsilon.link ]; then
2267 echo "epsilon.link is a symlink"
2268 test_done "$testroot" "1"
2269 return 1
2272 echo "<<<<<<< merged change: commit $commit_id2" \
2273 > $testroot/content.expected
2274 echo "gamma" >> $testroot/content.expected
2275 echo "3-way merge base: commit $commit_id1" \
2276 >> $testroot/content.expected
2277 echo "epsilon" >> $testroot/content.expected
2278 echo "=======" >> $testroot/content.expected
2279 echo "beta" >> $testroot/content.expected
2280 echo '>>>>>>>' >> $testroot/content.expected
2281 echo -n "" >> $testroot/content.expected
2283 cp $testroot/wt/epsilon.link $testroot/content
2284 cmp -s $testroot/content.expected $testroot/content
2285 ret=$?
2286 if [ $ret -ne 0 ]; then
2287 diff -u $testroot/content.expected $testroot/content
2288 test_done "$testroot" "$ret"
2289 return 1
2292 if [ -h $testroot/wt/passwd.link ]; then
2293 echo -n "passwd.link symlink points outside of work tree: " >&2
2294 readlink $testroot/wt/passwd.link >&2
2295 test_done "$testroot" "1"
2296 return 1
2299 echo -n "/etc/passwd" > $testroot/content.expected
2300 cp $testroot/wt/passwd.link $testroot/content
2302 cmp -s $testroot/content.expected $testroot/content
2303 ret=$?
2304 if [ $ret -ne 0 ]; then
2305 diff -u $testroot/content.expected $testroot/content
2306 test_done "$testroot" "$ret"
2307 return 1
2310 if [ -h $testroot/wt/epsilon/beta.link ]; then
2311 echo "epsilon/beta.link is a symlink"
2312 test_done "$testroot" "1"
2313 return 1
2316 echo "<<<<<<< merged change: commit $commit_id2" \
2317 > $testroot/content.expected
2318 echo "../gamma/delta" >> $testroot/content.expected
2319 echo "3-way merge base: commit $commit_id1" \
2320 >> $testroot/content.expected
2321 echo "../beta" >> $testroot/content.expected
2322 echo "=======" >> $testroot/content.expected
2323 echo "../gamma" >> $testroot/content.expected
2324 echo '>>>>>>>' >> $testroot/content.expected
2325 echo -n "" >> $testroot/content.expected
2327 cp $testroot/wt/epsilon/beta.link $testroot/content
2328 cmp -s $testroot/content.expected $testroot/content
2329 ret=$?
2330 if [ $ret -ne 0 ]; then
2331 diff -u $testroot/content.expected $testroot/content
2332 test_done "$testroot" "$ret"
2333 return 1
2336 if [ -h $testroot/wt/nonexistent.link ]; then
2337 echo -n "nonexistent.link still exists on disk: " >&2
2338 readlink $testroot/wt/nonexistent.link >&2
2339 test_done "$testroot" "1"
2340 return 1
2343 echo "<<<<<<< merged change: commit $commit_id2" \
2344 > $testroot/content.expected
2345 echo "(symlink was deleted)" >> $testroot/content.expected
2346 echo "=======" >> $testroot/content.expected
2347 echo "nonexistent2" >> $testroot/content.expected
2348 echo '>>>>>>>' >> $testroot/content.expected
2349 echo -n "" >> $testroot/content.expected
2351 cp $testroot/wt/nonexistent.link $testroot/content
2352 cmp -s $testroot/content.expected $testroot/content
2353 ret=$?
2354 if [ $ret -ne 0 ]; then
2355 diff -u $testroot/content.expected $testroot/content
2356 test_done "$testroot" "$ret"
2357 return 1
2360 if [ -h $testroot/wt/dotgotfoo.link ]; then
2361 echo "dotgotfoo.link is a symlink"
2362 test_done "$testroot" "1"
2363 return 1
2366 echo "<<<<<<< merged change: commit $commit_id2" \
2367 > $testroot/content.expected
2368 echo "this is regular file foo" >> $testroot/content.expected
2369 echo "=======" >> $testroot/content.expected
2370 echo -n ".got/bar" >> $testroot/content.expected
2371 echo '>>>>>>>' >> $testroot/content.expected
2372 echo -n "" >> $testroot/content.expected
2374 cp $testroot/wt/dotgotfoo.link $testroot/content
2375 cmp -s $testroot/content.expected $testroot/content
2376 ret=$?
2377 if [ $ret -ne 0 ]; then
2378 diff -u $testroot/content.expected $testroot/content
2379 test_done "$testroot" "$ret"
2380 return 1
2383 if [ -h $testroot/wt/dotgotbar.link ]; then
2384 echo "dotgotbar.link is a symlink"
2385 test_done "$testroot" "1"
2386 return 1
2388 echo "<<<<<<< merged change: commit $commit_id2" \
2389 > $testroot/content.expected
2390 echo -n ".got/bar" >> $testroot/content.expected
2391 echo "=======" >> $testroot/content.expected
2392 echo "this is regular file bar" >> $testroot/content.expected
2393 echo '>>>>>>>' >> $testroot/content.expected
2394 echo -n "" >> $testroot/content.expected
2396 cp $testroot/wt/dotgotbar.link $testroot/content
2397 cmp -s $testroot/content.expected $testroot/content
2398 ret=$?
2399 if [ $ret -ne 0 ]; then
2400 diff -u $testroot/content.expected $testroot/content
2401 test_done "$testroot" "$ret"
2402 return 1
2405 if [ -h $testroot/wt/new.link ]; then
2406 echo "new.link is a symlink"
2407 test_done "$testroot" "1"
2408 return 1
2411 echo "<<<<<<< merged change: commit $commit_id2" \
2412 > $testroot/content.expected
2413 echo "alpha" >> $testroot/content.expected
2414 echo "=======" >> $testroot/content.expected
2415 echo "beta" >> $testroot/content.expected
2416 echo '>>>>>>>' >> $testroot/content.expected
2417 echo -n "" >> $testroot/content.expected
2419 cp $testroot/wt/new.link $testroot/content
2420 cmp -s $testroot/content.expected $testroot/content
2421 ret=$?
2422 if [ $ret -ne 0 ]; then
2423 diff -u $testroot/content.expected $testroot/content
2424 test_done "$testroot" "$ret"
2425 return 1
2428 echo "A dotgotfoo.link" > $testroot/stdout.expected
2429 echo "M new.link" >> $testroot/stdout.expected
2430 echo "D nonexistent.link" >> $testroot/stdout.expected
2431 (cd $testroot/wt && got status > $testroot/stdout)
2432 ret=$?
2433 if [ $ret -ne 0 ]; then
2434 diff -u $testroot/stdout.expected $testroot/stdout
2435 test_done "$testroot" "$ret"
2436 return 1
2439 test_done "$testroot" "0"
2443 test_update_single_file() {
2444 local testroot=`test_init update_single_file 1`
2446 echo c1 > $testroot/repo/c
2447 (cd $testroot/repo && git add .)
2448 git_commit $testroot/repo -m "adding file c"
2449 local commit_id1=`git_show_head $testroot/repo`
2451 echo a > $testroot/repo/a
2452 echo b > $testroot/repo/b
2453 echo c2 > $testroot/repo/c
2454 (cd $testroot/repo && git add .)
2455 git_commit $testroot/repo -m "add files a and b, change c"
2456 local commit_id2=`git_show_head $testroot/repo`
2458 (cd $testroot/repo && git rm -qf c)
2459 git_commit $testroot/repo -m "remove file c"
2460 local commit_id3=`git_show_head $testroot/repo`
2462 got checkout -c $commit_id2 $testroot/repo $testroot/wt > /dev/null
2463 ret=$?
2464 if [ $ret -ne 0 ]; then
2465 test_done "$testroot" "$ret"
2466 return 1
2469 echo "U c" > $testroot/stdout.expected
2470 echo "Updated to refs/heads/master: $commit_id1" \
2471 >> $testroot/stdout.expected
2473 (cd $testroot/wt && got update -c $commit_id1 c \
2474 > $testroot/stdout)
2476 cmp -s $testroot/stdout.expected $testroot/stdout
2477 ret=$?
2478 if [ $ret -ne 0 ]; then
2479 diff -u $testroot/stdout.expected $testroot/stdout
2480 test_done "$testroot" "$ret"
2481 return 1
2484 echo c1 > $testroot/content.expected
2485 cat $testroot/wt/c > $testroot/content
2487 cmp -s $testroot/content.expected $testroot/content
2488 ret=$?
2489 if [ $ret -ne 0 ]; then
2490 diff -u $testroot/content.expected $testroot/content
2491 test_done "$testroot" "$ret"
2492 return 1
2495 echo "U c" > $testroot/stdout.expected
2496 echo "Updated to refs/heads/master: $commit_id2" \
2497 >> $testroot/stdout.expected
2499 (cd $testroot/wt && got update -c $commit_id2 c > $testroot/stdout)
2501 cmp -s $testroot/stdout.expected $testroot/stdout
2502 ret=$?
2503 if [ $ret -ne 0 ]; then
2504 diff -u $testroot/stdout.expected $testroot/stdout
2505 test_done "$testroot" "$ret"
2506 return 1
2509 echo c2 > $testroot/content.expected
2510 cat $testroot/wt/c > $testroot/content
2512 cmp -s $testroot/content.expected $testroot/content
2513 ret=$?
2514 if [ $ret -ne 0 ]; then
2515 diff -u $testroot/content.expected $testroot/content
2516 test_done "$testroot" "$ret"
2517 return 1
2520 echo "D c" > $testroot/stdout.expected
2521 echo "Updated to refs/heads/master: $commit_id3" \
2522 >> $testroot/stdout.expected
2524 (cd $testroot/wt && got update -c $commit_id3 c \
2525 > $testroot/stdout 2> $testroot/stderr)
2527 echo "got: /c: no such entry found in tree" > $testroot/stderr.expected
2528 cmp -s $testroot/stderr.expected $testroot/stderr
2529 ret=$?
2530 if [ $ret -ne 0 ]; then
2531 diff -u $testroot/stderr.expected $testroot/stderr
2532 test_done "$testroot" "$ret"
2533 return 1
2536 echo -n > $testroot/stdout.expected
2537 cmp -s $testroot/stdout.expected $testroot/stdout
2538 ret=$?
2539 if [ $ret -ne 0 ]; then
2540 diff -u $testroot/stdout.expected $testroot/stdout
2541 test_done "$testroot" "$ret"
2542 return 1
2545 echo "D c" > $testroot/stdout.expected
2546 echo "Updated to refs/heads/master: $commit_id3" \
2547 >> $testroot/stdout.expected
2549 (cd $testroot/wt && got update -c $commit_id3 > $testroot/stdout)
2550 cmp -s $testroot/stdout.expected $testroot/stdout
2551 ret=$?
2552 if [ $ret -ne 0 ]; then
2553 diff -u $testroot/stdout.expected $testroot/stdout
2554 test_done "$testroot" "$ret"
2555 return 1
2558 if [ -e $testroot/wt/c ]; then
2559 echo "removed file c still exists on disk" >&2
2560 test_done "$testroot" "1"
2561 return 1
2564 test_done "$testroot" "0"
2565 return 0
2568 test_update_file_skipped_due_to_conflict() {
2569 local testroot=`test_init update_file_skipped_due_to_conflict`
2570 local commit_id0=`git_show_head $testroot/repo`
2571 blob_id0=`get_blob_id $testroot/repo "" beta`
2573 echo "changed beta" > $testroot/repo/beta
2574 git_commit $testroot/repo -m "changed beta"
2575 local commit_id1=`git_show_head $testroot/repo`
2576 blob_id1=`get_blob_id $testroot/repo "" beta`
2578 got checkout $testroot/repo $testroot/wt > /dev/null
2579 ret=$?
2580 if [ $ret -ne 0 ]; then
2581 test_done "$testroot" "$ret"
2582 return 1
2585 blob_id=`(cd $testroot/wt && got info beta | grep 'blob:' | \
2586 cut -d ':' -f 2 | tr -d ' ')`
2587 if [ "$blob_id" != "$blob_id1" ]; then
2588 echo "file beta has the wrong base blob ID" >&2
2589 test_done "$testroot" "1"
2590 return 1
2593 commit_id=`(cd $testroot/wt && got info beta | \
2594 grep 'based on commit:' | cut -d ':' -f 2 | tr -d ' ')`
2595 if [ "$commit_id" != "$commit_id1" ]; then
2596 echo "file beta has the wrong base commit ID" >&2
2597 test_done "$testroot" "1"
2598 return 1
2601 echo "modified beta" > $testroot/wt/beta
2603 (cd $testroot/wt && got update -c $commit_id0 > $testroot/stdout)
2605 echo "C beta" > $testroot/stdout.expected
2606 echo "Updated to refs/heads/master: $commit_id0" \
2607 >> $testroot/stdout.expected
2608 echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
2609 cmp -s $testroot/stdout.expected $testroot/stdout
2610 ret=$?
2611 if [ $ret -ne 0 ]; then
2612 diff -u $testroot/stdout.expected $testroot/stdout
2613 test_done "$testroot" "$ret"
2614 return 1
2617 echo "<<<<<<< merged change: commit $commit_id0" \
2618 > $testroot/content.expected
2619 echo "beta" >> $testroot/content.expected
2620 echo "||||||| 3-way merge base: commit $commit_id1" \
2621 >> $testroot/content.expected
2622 echo "changed beta" >> $testroot/content.expected
2623 echo "=======" >> $testroot/content.expected
2624 echo "modified beta" >> $testroot/content.expected
2625 echo ">>>>>>>" >> $testroot/content.expected
2627 cat $testroot/wt/beta > $testroot/content
2629 cmp -s $testroot/content.expected $testroot/content
2630 ret=$?
2631 if [ $ret -ne 0 ]; then
2632 diff -u $testroot/content.expected $testroot/content
2633 test_done "$testroot" "$ret"
2634 return 1
2637 blob_id=`(cd $testroot/wt && got info beta | grep 'blob:' | \
2638 cut -d ':' -f 2 | tr -d ' ')`
2639 if [ "$blob_id" != "$blob_id0" ]; then
2640 echo "file beta has the wrong base blob ID" >&2
2641 test_done "$testroot" "1"
2642 return 1
2645 commit_id=`(cd $testroot/wt && got info beta | \
2646 grep 'based on commit:' | cut -d ':' -f 2 | tr -d ' ')`
2647 if [ "$commit_id" != "$commit_id0" ]; then
2648 echo "file beta has the wrong base commit ID" >&2
2649 test_done "$testroot" "1"
2650 return 1
2653 # update to the latest commit again; this skips beta
2654 (cd $testroot/wt && got update > $testroot/stdout)
2655 echo "# beta" > $testroot/stdout.expected
2656 echo "Updated to refs/heads/master: $commit_id1" \
2657 >> $testroot/stdout.expected
2658 echo "Files not updated because of existing merge conflicts: 1" \
2659 >> $testroot/stdout.expected
2660 cmp -s $testroot/stdout.expected $testroot/stdout
2661 ret=$?
2662 if [ $ret -ne 0 ]; then
2663 diff -u $testroot/stdout.expected $testroot/stdout
2664 test_done "$testroot" "$ret"
2665 return 1
2668 # blob ID of beta should not have changed
2669 blob_id=`(cd $testroot/wt && got info beta | grep 'blob:' | \
2670 cut -d ':' -f 2 | tr -d ' ')`
2671 if [ "$blob_id" != "$blob_id0" ]; then
2672 echo "file beta has the wrong base blob ID" >&2
2673 test_done "$testroot" "1"
2674 return 1
2677 # commit ID of beta should not have changed; There was a bug
2678 # here where the commit ID had been changed even though the
2679 # file was not updated.
2680 commit_id=`(cd $testroot/wt && got info beta | \
2681 grep 'based on commit:' | cut -d ':' -f 2 | tr -d ' ')`
2682 if [ "$commit_id" != "$commit_id0" ]; then
2683 echo "file beta has the wrong base commit ID: $commit_id" >&2
2684 test_done "$testroot" "1"
2685 return 1
2688 # beta is still conflicted and based on commit 0
2689 echo 'C beta' > $testroot/stdout.expected
2690 (cd $testroot/wt && got status > $testroot/stdout)
2691 cmp -s $testroot/stdout.expected $testroot/stdout
2692 ret=$?
2693 if [ $ret -ne 0 ]; then
2694 diff -u $testroot/stdout.expected $testroot/stdout
2695 test_done "$testroot" "$ret"
2696 return 1
2699 # resolve the conflict via revert
2700 (cd $testroot/wt && got revert beta >/dev/null)
2702 # beta now matches its base blob which is still from commit 0
2703 echo "beta" > $testroot/content.expected
2704 cat $testroot/wt/beta > $testroot/content
2705 cmp -s $testroot/content.expected $testroot/content
2706 ret=$?
2707 if [ $ret -ne 0 ]; then
2708 diff -u $testroot/content.expected $testroot/content
2709 test_done "$testroot" "$ret"
2710 return 1
2713 # updating to the latest commit should now update beta
2714 (cd $testroot/wt && got update > $testroot/stdout)
2715 echo "U beta" > $testroot/stdout.expected
2716 echo "Updated to refs/heads/master: $commit_id1" \
2717 >> $testroot/stdout.expected
2718 cmp -s $testroot/stdout.expected $testroot/stdout
2719 ret=$?
2720 if [ $ret -ne 0 ]; then
2721 diff -u $testroot/stdout.expected $testroot/stdout
2722 test_done "$testroot" "$ret"
2723 return 1
2726 blob_id=`(cd $testroot/wt && got info beta | grep 'blob:' | \
2727 cut -d ':' -f 2 | tr -d ' ')`
2728 if [ "$blob_id" != "$blob_id1" ]; then
2729 echo "file beta has the wrong base blob ID" >&2
2730 test_done "$testroot" "1"
2731 return 1
2734 commit_id=`(cd $testroot/wt && got info beta | \
2735 grep 'based on commit:' | cut -d ':' -f 2 | tr -d ' ')`
2736 if [ "$commit_id" != "$commit_id1" ]; then
2737 echo "file beta has the wrong base commit ID: $commit_id" >&2
2738 test_done "$testroot" "1"
2739 return 1
2742 echo "changed beta" > $testroot/content.expected
2743 cat $testroot/wt/beta > $testroot/content
2744 cmp -s $testroot/content.expected $testroot/content
2745 ret=$?
2746 if [ $ret -ne 0 ]; then
2747 diff -u $testroot/content.expected $testroot/content
2749 test_done "$testroot" "$ret"
2752 test_update_file_skipped_due_to_obstruction() {
2753 local testroot=`test_init update_file_skipped_due_to_obstruction`
2754 local commit_id0=`git_show_head $testroot/repo`
2755 blob_id0=`get_blob_id $testroot/repo "" beta`
2757 echo "changed beta" > $testroot/repo/beta
2758 echo "new file" > $testroot/repo/new
2759 (cd $testroot/repo && git add new)
2760 git_commit $testroot/repo -m "changed beta"
2761 local commit_id1=`git_show_head $testroot/repo`
2762 blob_id1=`get_blob_id $testroot/repo "" beta`
2764 got checkout -c $commit_id0 $testroot/repo $testroot/wt > /dev/null
2765 ret=$?
2766 if [ $ret -ne 0 ]; then
2767 test_done "$testroot" "$ret"
2768 return 1
2771 blob_id=`(cd $testroot/wt && got info beta | grep 'blob:' | \
2772 cut -d ':' -f 2 | tr -d ' ')`
2773 if [ "$blob_id" != "$blob_id0" ]; then
2774 echo "file beta has the wrong base blob ID" >&2
2775 test_done "$testroot" "1"
2776 return 1
2779 commit_id=`(cd $testroot/wt && got info beta | \
2780 grep 'based on commit:' | cut -d ':' -f 2 | tr -d ' ')`
2781 if [ "$commit_id" != "$commit_id0" ]; then
2782 echo "file beta has the wrong base commit ID" >&2
2783 test_done "$testroot" "1"
2784 return 1
2787 rm $testroot/wt/beta
2788 mkdir -p $testroot/wt/beta/psi
2789 mkdir -p $testroot/wt/new
2791 # update to the latest commit; this skips beta and the new file
2792 (cd $testroot/wt && got update > $testroot/stdout)
2793 ret=$?
2794 if [ $ret -ne 0 ]; then
2795 echo "update failed unexpectedly" >&2
2796 test_done "$testroot" "1"
2797 return 1
2800 echo "~ beta" > $testroot/stdout.expected
2801 echo "~ new" >> $testroot/stdout.expected
2802 echo "Updated to refs/heads/master: $commit_id1" \
2803 >> $testroot/stdout.expected
2804 echo "File paths obstructed by a non-regular file: 2" \
2805 >> $testroot/stdout.expected
2806 cmp -s $testroot/stdout.expected $testroot/stdout
2807 ret=$?
2808 if [ $ret -ne 0 ]; then
2809 diff -u $testroot/stdout.expected $testroot/stdout
2810 test_done "$testroot" "$ret"
2811 return 1
2814 blob_id=`(cd $testroot/wt && got info beta | grep 'blob:' | \
2815 cut -d ':' -f 2 | tr -d ' ')`
2816 if [ "$blob_id" != "$blob_id0" ]; then
2817 echo "file beta has the wrong base blob ID" >&2
2818 test_done "$testroot" "1"
2819 return 1
2822 commit_id=`(cd $testroot/wt && got info beta | \
2823 grep 'based on commit:' | cut -d ':' -f 2 | tr -d ' ')`
2824 if [ "$commit_id" != "$commit_id0" ]; then
2825 echo "file beta has the wrong base commit ID" >&2
2826 test_done "$testroot" "1"
2827 return 1
2830 # remove the directory which obstructs file beta
2831 rm -r $testroot/wt/beta
2833 # updating to the latest commit should now update beta
2834 (cd $testroot/wt && got update > $testroot/stdout)
2835 echo "! beta" > $testroot/stdout.expected
2836 echo "~ new" >> $testroot/stdout.expected
2837 echo "Updated to refs/heads/master: $commit_id1" \
2838 >> $testroot/stdout.expected
2839 echo "File paths obstructed by a non-regular file: 1" \
2840 >> $testroot/stdout.expected
2841 cmp -s $testroot/stdout.expected $testroot/stdout
2842 ret=$?
2843 if [ $ret -ne 0 ]; then
2844 diff -u $testroot/stdout.expected $testroot/stdout
2845 test_done "$testroot" "$ret"
2846 return 1
2849 blob_id=`(cd $testroot/wt && got info beta | grep 'blob:' | \
2850 cut -d ':' -f 2 | tr -d ' ')`
2851 if [ "$blob_id" != "$blob_id1" ]; then
2852 echo "file beta has the wrong base blob ID" >&2
2853 test_done "$testroot" "1"
2854 return 1
2857 commit_id=`(cd $testroot/wt && got info beta | \
2858 grep 'based on commit:' | cut -d ':' -f 2 | tr -d ' ')`
2859 if [ "$commit_id" != "$commit_id1" ]; then
2860 echo "file beta has the wrong base commit ID: $commit_id" >&2
2861 test_done "$testroot" "1"
2862 return 1
2865 echo "changed beta" > $testroot/content.expected
2866 cat $testroot/wt/beta > $testroot/content
2867 cmp -s $testroot/content.expected $testroot/content
2868 ret=$?
2869 if [ $ret -ne 0 ]; then
2870 diff -u $testroot/content.expected $testroot/content
2872 test_done "$testroot" "$ret"
2875 test_update_quiet() {
2876 local testroot=`test_init update_quiet`
2878 got checkout $testroot/repo $testroot/wt > /dev/null
2879 ret=$?
2880 if [ $ret -ne 0 ]; then
2881 test_done "$testroot" "$ret"
2882 return 1
2885 echo "modified alpha" > $testroot/repo/alpha
2886 git_commit $testroot/repo -m "modified alpha"
2888 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
2889 git_show_head $testroot/repo >> $testroot/stdout.expected
2890 echo >> $testroot/stdout.expected
2892 (cd $testroot/wt && got update -q > $testroot/stdout)
2894 cmp -s $testroot/stdout.expected $testroot/stdout
2895 ret=$?
2896 if [ $ret -ne 0 ]; then
2897 diff -u $testroot/stdout.expected $testroot/stdout
2898 test_done "$testroot" "$ret"
2899 return 1
2902 echo "modified alpha" > $testroot/content.expected
2903 cat $testroot/wt/alpha > $testroot/content
2905 cmp -s $testroot/content.expected $testroot/content
2906 ret=$?
2907 if [ $ret -ne 0 ]; then
2908 diff -u $testroot/content.expected $testroot/content
2910 test_done "$testroot" "$ret"
2913 test_update_binary_file() {
2914 local testroot=`test_init update_binary_file`
2915 local commit_id0=`git_show_head $testroot/repo`
2917 got checkout $testroot/repo $testroot/wt > /dev/null
2918 ret=$?
2919 if [ $ret -ne 0 ]; then
2920 test_done "$testroot" "$ret"
2921 return 1
2924 cp /bin/ls $testroot/wt/foo
2925 chmod 755 $testroot/wt/foo
2926 (cd $testroot/wt && got add foo >/dev/null)
2927 (cd $testroot/wt && got commit -m 'add binary file' > /dev/null)
2928 local commit_id1=`git_show_head $testroot/repo`
2930 cp /bin/cat $testroot/wt/foo
2931 chmod 755 $testroot/wt/foo
2932 (cd $testroot/wt && got commit -m 'change binary file' > /dev/null)
2933 local commit_id2=`git_show_head $testroot/repo`
2935 cp /bin/cp $testroot/wt/foo
2936 chmod 755 $testroot/wt/foo
2937 (cd $testroot/wt && got commit -m 'change binary file' > /dev/null)
2938 local commit_id3=`git_show_head $testroot/repo`
2940 (cd $testroot/wt && got rm foo >/dev/null)
2941 (cd $testroot/wt && got commit -m 'remove binary file' > /dev/null)
2942 local commit_id4=`git_show_head $testroot/repo`
2944 # backdate the work tree to make it usable for updating
2945 (cd $testroot/wt && got up -c $commit_id0 > /dev/null)
2947 # update which adds a binary file
2948 (cd $testroot/wt && got up -c $commit_id1 > $testroot/stdout)
2950 echo "A foo" > $testroot/stdout.expected
2951 echo -n "Updated to refs/heads/master: $commit_id1" \
2952 >> $testroot/stdout.expected
2953 echo >> $testroot/stdout.expected
2954 cmp -s $testroot/stdout.expected $testroot/stdout
2955 ret=$?
2956 if [ $ret -ne 0 ]; then
2957 diff -u $testroot/stdout.expected $testroot/stdout
2958 test_done "$testroot" "$ret"
2959 return 1
2962 cp /bin/ls $testroot/content.expected
2963 chmod 755 $testroot/content.expected
2964 cat $testroot/wt/foo > $testroot/content
2966 cmp -s $testroot/content.expected $testroot/content
2967 ret=$?
2968 if [ $ret -ne 0 ]; then
2969 diff -u $testroot/content.expected $testroot/content
2970 test_done "$testroot" "$ret"
2971 return 1
2974 # update which adds a conflicting binary file
2975 (cd $testroot/wt && got up -c $commit_id0 > /dev/null)
2976 cp /bin/cat $testroot/wt/foo
2977 chmod 755 $testroot/wt/foo
2978 (cd $testroot/wt && got add foo > /dev/null)
2979 (cd $testroot/wt && got up -c $commit_id1 > $testroot/stdout)
2981 echo "C foo" > $testroot/stdout.expected
2982 echo "Updated to refs/heads/master: $commit_id1" \
2983 >> $testroot/stdout.expected
2984 echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
2985 cmp -s $testroot/stdout.expected $testroot/stdout
2986 ret=$?
2987 if [ $ret -ne 0 ]; then
2988 diff -u $testroot/stdout.expected $testroot/stdout
2989 test_done "$testroot" "$ret"
2990 return 1
2993 echo "Binary files differ and cannot be merged automatically:" \
2994 > $testroot/content.expected
2995 echo "<<<<<<< merged change: commit $commit_id1" \
2996 >> $testroot/content.expected
2997 echo -n "file " >> $testroot/content.expected
2998 ls $testroot/wt/foo-1-* >> $testroot/content.expected
2999 echo '=======' >> $testroot/content.expected
3000 echo -n "file " >> $testroot/content.expected
3001 ls $testroot/wt/foo-2-* >> $testroot/content.expected
3002 echo ">>>>>>>" >> $testroot/content.expected
3003 cat $testroot/wt/foo > $testroot/content
3005 cmp -s $testroot/content.expected $testroot/content
3006 ret=$?
3007 if [ $ret -ne 0 ]; then
3008 diff -u $testroot/content.expected $testroot/content
3009 test_done "$testroot" "$ret"
3010 return 1
3013 cp /bin/ls $testroot/content.expected
3014 chmod 755 $testroot/content.expected
3015 cat $testroot/wt/foo-1-* > $testroot/content
3017 cmp -s $testroot/content.expected $testroot/content
3018 ret=$?
3019 if [ $ret -ne 0 ]; then
3020 diff -u $testroot/content.expected $testroot/content
3021 test_done "$testroot" "$ret"
3022 return 1
3025 cp /bin/cat $testroot/content.expected
3026 chmod 755 $testroot/content.expected
3027 cat $testroot/wt/foo-2-* > $testroot/content
3029 cmp -s $testroot/content.expected $testroot/content
3030 ret=$?
3031 if [ $ret -ne 0 ]; then
3032 diff -u $testroot/content.expected $testroot/content
3033 test_done "$testroot" "$ret"
3034 return 1
3037 # tidy up
3038 (cd $testroot/wt && got revert -R . >/dev/null)
3039 rm $testroot/wt/foo-1-* $testroot/wt/foo-2-*
3040 (cd $testroot/wt && got up -c $commit_id1 > /dev/null)
3042 # update which changes a binary file
3043 (cd $testroot/wt && got up -c $commit_id2 > $testroot/stdout)
3045 echo "U foo" > $testroot/stdout.expected
3046 echo -n "Updated to refs/heads/master: $commit_id2" \
3047 >> $testroot/stdout.expected
3048 echo >> $testroot/stdout.expected
3049 cmp -s $testroot/stdout.expected $testroot/stdout
3050 ret=$?
3051 if [ $ret -ne 0 ]; then
3052 diff -u $testroot/stdout.expected $testroot/stdout
3053 test_done "$testroot" "$ret"
3054 return 1
3057 cp /bin/cat $testroot/content.expected
3058 chmod 755 $testroot/content.expected
3059 cat $testroot/wt/foo > $testroot/content
3061 cmp -s $testroot/content.expected $testroot/content
3062 ret=$?
3063 if [ $ret -ne 0 ]; then
3064 diff -u $testroot/content.expected $testroot/content
3065 test_done "$testroot" "$ret"
3066 return 1
3069 # update which changes a locally modified binary file
3070 cp /bin/ls $testroot/wt/foo
3071 chmod 755 $testroot/wt/foo
3072 (cd $testroot/wt && got up -c $commit_id3 > $testroot/stdout)
3074 echo "C foo" > $testroot/stdout.expected
3075 echo -n "Updated to refs/heads/master: $commit_id3" \
3076 >> $testroot/stdout.expected
3077 echo >> $testroot/stdout.expected
3078 echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
3079 cmp -s $testroot/stdout.expected $testroot/stdout
3080 ret=$?
3081 if [ $ret -ne 0 ]; then
3082 diff -u $testroot/stdout.expected $testroot/stdout
3083 test_done "$testroot" "$ret"
3084 return 1
3087 echo "Binary files differ and cannot be merged automatically:" \
3088 > $testroot/content.expected
3089 echo "<<<<<<< merged change: commit $commit_id3" \
3090 >> $testroot/content.expected
3091 echo -n "file " >> $testroot/content.expected
3092 ls $testroot/wt/foo-1-* >> $testroot/content.expected
3093 echo "||||||| 3-way merge base: commit $commit_id2" \
3094 >> $testroot/content.expected
3095 echo -n "file " >> $testroot/content.expected
3096 ls $testroot/wt/foo-orig-* >> $testroot/content.expected
3097 echo '=======' >> $testroot/content.expected
3098 echo -n "file " >> $testroot/content.expected
3099 ls $testroot/wt/foo-2-* >> $testroot/content.expected
3100 echo ">>>>>>>" >> $testroot/content.expected
3101 cat $testroot/wt/foo > $testroot/content
3103 cmp -s $testroot/content.expected $testroot/content
3104 ret=$?
3105 if [ $ret -ne 0 ]; then
3106 diff -u $testroot/content.expected $testroot/content
3107 test_done "$testroot" "$ret"
3108 return 1
3111 cp /bin/cp $testroot/content.expected
3112 chmod 755 $testroot/content.expected
3113 cp $testroot/wt/foo-1-* $testroot/content
3114 cmp -s $testroot/content.expected $testroot/content
3115 ret=$?
3116 if [ $ret -ne 0 ]; then
3117 diff -u $testroot/content.expected $testroot/content
3118 test_done "$testroot" "$ret"
3119 return 1
3122 cp /bin/ls $testroot/content.expected
3123 chmod 755 $testroot/content.expected
3124 cp $testroot/wt/foo-2-* $testroot/content
3125 cmp -s $testroot/content.expected $testroot/content
3126 ret=$?
3127 if [ $ret -ne 0 ]; then
3128 diff -u $testroot/content.expected $testroot/content
3129 test_done "$testroot" "$ret"
3130 return 1
3133 (cd $testroot/wt && got status > $testroot/stdout)
3134 echo 'C foo' > $testroot/stdout.expected
3135 echo -n '? ' >> $testroot/stdout.expected
3136 (cd $testroot/wt && ls foo-1-* >> $testroot/stdout.expected)
3137 echo -n '? ' >> $testroot/stdout.expected
3138 (cd $testroot/wt && ls foo-2-* >> $testroot/stdout.expected)
3139 echo -n '? ' >> $testroot/stdout.expected
3140 (cd $testroot/wt && ls foo-orig-* >> $testroot/stdout.expected)
3141 cmp -s $testroot/stdout.expected $testroot/stdout
3142 ret=$?
3143 if [ $ret -ne 0 ]; then
3144 diff -u $testroot/stdout.expected $testroot/stdout
3145 test_done "$testroot" "$ret"
3146 return 1
3149 # tidy up
3150 (cd $testroot/wt && got revert -R . > /dev/null)
3151 rm $testroot/wt/foo-orig-* $testroot/wt/foo-1-* $testroot/wt/foo-2-*
3153 # update which deletes a binary file
3154 (cd $testroot/wt && got up -c $commit_id4 > $testroot/stdout)
3155 echo "D foo" > $testroot/stdout.expected
3156 echo -n "Updated to refs/heads/master: $commit_id4" \
3157 >> $testroot/stdout.expected
3158 echo >> $testroot/stdout.expected
3159 cmp -s $testroot/stdout.expected $testroot/stdout
3160 ret=$?
3161 if [ $ret -ne 0 ]; then
3162 diff -u $testroot/stdout.expected $testroot/stdout
3163 test_done "$testroot" "$ret"
3166 if [ -e $testroot/wt/foo ]; then
3167 echo "removed file foo still exists on disk" >&2
3168 test_done "$testroot" "1"
3169 return 1
3171 test_done "$testroot" "0"
3174 test_update_umask() {
3175 local testroot=`test_init update_binary_file`
3177 got checkout "$testroot/repo" "$testroot/wt" >/dev/null
3178 ret=$?
3179 if [ $ret -ne 0 ]; then
3180 test_done "$testroot" "$ret"
3181 return 1
3184 rm "$testroot/wt/alpha"
3186 # using a subshell to avoid clobbering global umask
3187 (umask 022 && cd "$testroot/wt" && got update alpha) \
3188 >/dev/null 2>/dev/null
3189 ret=$?
3190 if [ $ret -ne 0 ]; then
3191 test_done "$testroot" $ret
3192 return 1
3195 if ! ls -l "$testroot/wt/alpha" | grep -q ^-rw-r--r--; then
3196 echo "alpha is not 0644" >&2
3197 test_done "$testroot" 1
3198 return 1
3201 rm "$testroot/wt/alpha"
3203 # using a subshell to avoid clobbering global umask
3204 (umask 044 && cd "$testroot/wt" && got update alpha) \
3205 >/dev/null 2>/dev/null
3206 ret=$?
3207 if [ $ret -ne 0 ]; then
3208 test_done "$testroot" $ret
3209 return 1
3212 if ! ls -l "$testroot/wt/alpha" | grep -q ^-rw-------; then
3213 echo "alpha is not 0600" >&2
3214 test_done "$testroot" 1
3215 return 1
3218 rm "$testroot/wt/alpha"
3220 # using a subshell to avoid clobbering global umask
3221 (umask 222 && cd "$testroot/wt" && got update alpha) \
3222 >/dev/null 2>/dev/null
3223 ret=$?
3224 if [ $ret -ne 0 ]; then
3225 test_done "$testroot" $ret
3226 return 1
3229 if ! ls -l "$testroot/wt/alpha" | grep -q ^-r--r--r--; then
3230 echo "alpha is not 0444" >&2
3231 test_done "$testroot" 1
3232 return 1;
3235 test_done "$testroot" 0
3238 test_parseargs "$@"
3239 run_test test_update_basic
3240 run_test test_update_adds_file
3241 run_test test_update_deletes_file
3242 run_test test_update_deletes_dir
3243 run_test test_update_deletes_dir_with_path_prefix
3244 run_test test_update_deletes_dir_recursively
3245 run_test test_update_sibling_dirs_with_common_prefix
3246 run_test test_update_dir_with_dot_sibling
3247 run_test test_update_moves_files_upwards
3248 run_test test_update_moves_files_to_new_dir
3249 run_test test_update_creates_missing_parent
3250 run_test test_update_creates_missing_parent_with_subdir
3251 run_test test_update_file_in_subsubdir
3252 run_test test_update_changes_file_to_dir
3253 run_test test_update_changes_dir_to_file
3254 run_test test_update_changes_modified_file_to_dir
3255 run_test test_update_merges_file_edits
3256 run_test test_update_keeps_xbit
3257 run_test test_update_clears_xbit
3258 run_test test_update_restores_missing_file
3259 run_test test_update_conflict_wt_add_vs_repo_add
3260 run_test test_update_conflict_wt_edit_vs_repo_rm
3261 run_test test_update_conflict_wt_rm_vs_repo_edit
3262 run_test test_update_conflict_wt_rm_vs_repo_rm
3263 run_test test_update_partial
3264 run_test test_update_partial_add
3265 run_test test_update_partial_rm
3266 run_test test_update_partial_dir
3267 run_test test_update_moved_branch_ref
3268 run_test test_update_to_another_branch
3269 run_test test_update_to_commit_on_wrong_branch
3270 run_test test_update_bumps_base_commit_id
3271 run_test test_update_tag
3272 run_test test_update_toggles_xbit
3273 run_test test_update_preserves_conflicted_file
3274 run_test test_update_modified_submodules
3275 run_test test_update_adds_submodule
3276 run_test test_update_conflict_wt_file_vs_repo_submodule
3277 run_test test_update_adds_symlink
3278 run_test test_update_deletes_symlink
3279 run_test test_update_symlink_conflicts
3280 run_test test_update_single_file
3281 run_test test_update_file_skipped_due_to_conflict
3282 run_test test_update_file_skipped_due_to_obstruction
3283 run_test test_update_quiet
3284 run_test test_update_binary_file
3285 run_test test_update_umask