3 # Copyright (c) 2019 Stefan Sperling <stsp@openbsd.org>
5 # Permission to use, copy, modify, and distribute this software for any
6 # purpose with or without fee is hereby granted, provided that the above
7 # copyright notice and this permission notice appear in all copies.
9 # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20 local testroot
=`test_init update_basic`
22 got checkout
$testroot/repo
$testroot/wt
> /dev
/null
24 if [ "$ret" != "0" ]; then
25 test_done
"$testroot" "$ret"
29 echo "modified alpha" > $testroot/repo
/alpha
30 git_commit
$testroot/repo
-m "modified alpha"
32 echo "U alpha" > $testroot/stdout.expected
33 echo -n "Updated to 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
41 if [ "$ret" != "0" ]; then
42 diff -u $testroot/stdout.expected
$testroot/stdout
43 test_done
"$testroot" "$ret"
47 echo "modified alpha" > $testroot/content.expected
48 cat $testroot/wt
/alpha
> $testroot/content
50 cmp -s $testroot/content.expected
$testroot/content
52 if [ "$ret" != "0" ]; then
53 diff -u $testroot/content.expected
$testroot/content
55 test_done
"$testroot" "$ret"
58 test_update_adds_file
() {
59 local testroot
=`test_init update_adds_file`
61 got checkout
$testroot/repo
$testroot/wt
> /dev
/null
63 if [ "$ret" != "0" ]; then
64 test_done
"$testroot" "$ret"
68 echo "new" > $testroot/repo
/gamma
/new
69 (cd $testroot/repo
&& git add .
)
70 git_commit
$testroot/repo
-m "adding a new file"
72 echo "A gamma/new" > $testroot/stdout.expected
73 echo -n "Updated to 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
81 if [ "$ret" != "0" ]; then
82 diff -u $testroot/stdout.expected
$testroot/stdout
83 test_done
"$testroot" "$ret"
87 echo "new" >> $testroot/content.expected
88 cat $testroot/wt
/gamma
/new
> $testroot/content
90 cmp -s $testroot/content.expected
$testroot/content
92 if [ "$ret" != "0" ]; then
93 diff -u $testroot/content.expected
$testroot/content
95 test_done
"$testroot" "$ret"
98 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
104 if [ "$ret" != "0" ]; then
105 test_done
"$testroot" "$ret"
109 (cd $testroot/repo
&& 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
125 if [ "$ret" != "0" ]; then
126 diff -u $testroot/stdout.expected
$testroot/stdout
127 test_done
"$testroot" "$ret"
131 if [ -e $testroot/wtparent
/wt
/beta
]; then
132 echo "removed file beta still exists on disk" >&2
133 test_done
"$testroot" "1"
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
145 if [ "$ret" != "0" ]; then
146 test_done
"$testroot" "$ret"
150 (cd $testroot/repo
&& 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
162 if [ "$ret" != "0" ]; then
163 diff -u $testroot/stdout.expected
$testroot/stdout
164 test_done
"$testroot" "$ret"
168 if [ -e $testroot/wt
/epsilon
]; then
169 echo "removed dir epsilon still exists on disk" >&2
170 test_done
"$testroot" "1"
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
189 if [ "$ret" != "0" ]; then
190 test_done
"$testroot" "$ret"
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
203 if [ "$ret" != "0" ]; then
204 diff -u $testroot/stdout.expected
$testroot/stdout
205 test_done
"$testroot" "$ret"
209 if [ -e $testroot/wt
/psi
]; then
210 echo "removed dir psi still exists on disk" >&2
211 test_done
"$testroot" "1"
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
232 if [ "$ret" != "0" ]; then
233 test_done
"$testroot" "$ret"
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
247 if [ "$?" != "0" ]; then
248 diff -u $testroot/stdout.expected
$testroot/stdout
249 test_done
"$testroot" "$ret"
253 if [ -e $testroot/wt
/psi
]; then
254 echo "removed dir psi still exists on disk" >&2
255 test_done
"$testroot" "1"
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
267 if [ "$ret" != "0" ]; then
268 test_done
"$testroot" "$ret"
272 mkdir
$testroot/repo
/epsilon2
273 echo mu
> $testroot/repo
/epsilon
2/mu
274 (cd $testroot/repo
&& git add epsilon
2/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
289 if [ "$ret" != "0" ]; then
290 diff -u $testroot/stdout.expected
$testroot/stdout
291 test_done
"$testroot" "$ret"
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:
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
311 if [ "$ret" != "0" ]; then
312 diff -u $testroot/stdout.expected
$testroot/stdout
313 test_done
"$testroot" "$ret"
317 cmp -s $testroot/stdout.expected
$testroot/stdout
319 if [ "$ret" != "0" ]; then
320 diff -u $testroot/stdout.expected
$testroot/stdout
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
330 if [ "$ret" != "0" ]; then
331 test_done
"$testroot" "$ret"
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
351 if [ "$ret" != "0" ]; then
352 diff -u $testroot/stdout.expected
$testroot/stdout
353 test_done
"$testroot" "$ret"
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
369 if [ "$ret" != "0" ]; then
370 diff -u $testroot/stdout.expected
$testroot/stdout
371 test_done
"$testroot" "$ret"
375 cmp -s $testroot/stdout.expected
$testroot/stdout
377 if [ "$ret" != "0" ]; then
378 diff -u $testroot/stdout.expected
$testroot/stdout
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
395 if [ "$ret" != "0" ]; then
396 test_done
"$testroot" "$ret"
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
416 if [ "$ret" != "0" ]; then
417 diff -u $testroot/stdout.expected
$testroot/stdout
418 test_done
"$testroot" "$ret"
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"
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"
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
449 if [ "$ret" != "0" ]; then
450 test_done
"$testroot" "$ret"
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
471 if [ "$ret" != "0" ]; then
472 diff -u $testroot/stdout.expected
$testroot/stdout
473 test_done
"$testroot" "$ret"
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"
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"
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
503 if [ "$ret" != "0" ]; then
504 test_done
"$testroot" "$ret"
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
538 if [ "$ret" != "0" ]; then
539 diff -u $testroot/stdout.expected
$testroot/stdout
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
555 if [ "$ret" != "0" ]; then
556 test_done
"$testroot" "$ret"
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
590 if [ "$ret" != "0" ]; then
591 diff -u $testroot/stdout.expected
$testroot/stdout
592 test_done
"$testroot" "$ret"
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
612 if [ "$ret" != "0" ]; then
613 test_done
"$testroot" "$ret"
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
630 if [ "$ret" != "0" ]; then
631 diff -u $testroot/stdout.expected
$testroot/stdout
632 test_done
"$testroot" "$ret"
636 test_done
"$testroot" "0"
639 test_update_merges_file_edits
() {
640 local testroot
=`test_init update_merges_file_edits`
642 echo "1" > $testroot/repo
/numbers
643 echo "2" >> $testroot/repo
/numbers
644 echo "3" >> $testroot/repo
/numbers
645 echo "4" >> $testroot/repo
/numbers
646 echo "5" >> $testroot/repo
/numbers
647 echo "6" >> $testroot/repo
/numbers
648 echo "7" >> $testroot/repo
/numbers
649 echo "8" >> $testroot/repo
/numbers
650 (cd $testroot/repo
&& git add numbers
)
651 git_commit
$testroot/repo
-m "added numbers file"
652 local base_commit
=`git_show_head $testroot/repo`
654 got checkout
$testroot/repo
$testroot/wt
> /dev
/null
656 if [ "$ret" != "0" ]; then
657 test_done
"$testroot" "$ret"
661 echo "modified alpha" > $testroot/repo
/alpha
662 echo "modified beta" > $testroot/repo
/beta
663 sed -i '' -e 's/2/22/' $testroot/repo
/numbers
664 git_commit
$testroot/repo
-m "modified 3 files"
666 echo "modified alpha, too" > $testroot/wt
/alpha
667 touch $testroot/wt
/beta
668 sed -i '' -e 's/7/77/' $testroot/wt
/numbers
670 echo "C alpha" > $testroot/stdout.expected
671 echo "U beta" >> $testroot/stdout.expected
672 echo "G numbers" >> $testroot/stdout.expected
673 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
674 git_show_head
$testroot/repo
>> $testroot/stdout.expected
675 echo >> $testroot/stdout.expected
676 echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
678 (cd $testroot/wt
&& got update
> $testroot/stdout
)
680 cmp -s $testroot/stdout.expected
$testroot/stdout
682 if [ "$ret" != "0" ]; then
683 diff -u $testroot/stdout.expected
$testroot/stdout
684 test_done
"$testroot" "$ret"
688 echo -n "<<<<<<< merged change: commit " > $testroot/content.expected
689 git_show_head
$testroot/repo
>> $testroot/content.expected
690 echo >> $testroot/content.expected
691 echo "modified alpha" >> $testroot/content.expected
692 echo "||||||| 3-way merge base: commit $base_commit" \
693 >> $testroot/content.expected
694 echo "alpha" >> $testroot/content.expected
695 echo "=======" >> $testroot/content.expected
696 echo "modified alpha, too" >> $testroot/content.expected
697 echo '>>>>>>>' >> $testroot/content.expected
698 echo "modified beta" >> $testroot/content.expected
699 echo "1" >> $testroot/content.expected
700 echo "22" >> $testroot/content.expected
701 echo "3" >> $testroot/content.expected
702 echo "4" >> $testroot/content.expected
703 echo "5" >> $testroot/content.expected
704 echo "6" >> $testroot/content.expected
705 echo "77" >> $testroot/content.expected
706 echo "8" >> $testroot/content.expected
708 cat $testroot/wt
/alpha
> $testroot/content
709 cat $testroot/wt
/beta
>> $testroot/content
710 cat $testroot/wt
/numbers
>> $testroot/content
712 cmp -s $testroot/content.expected
$testroot/content
714 if [ "$ret" != "0" ]; then
715 diff -u $testroot/content.expected
$testroot/content
717 test_done
"$testroot" "$ret"
720 test_update_keeps_xbit
() {
721 local testroot
=`test_init update_keeps_xbit 1`
723 touch $testroot/repo
/xfile
724 chmod +x
$testroot/repo
/xfile
725 (cd $testroot/repo
&& git add .
)
726 git_commit
$testroot/repo
-m "adding executable file"
728 got checkout
$testroot/repo
$testroot/wt
> $testroot/stdout
730 if [ "$ret" != "0" ]; then
731 test_done
"$testroot" "$ret"
735 echo foo
> $testroot/repo
/xfile
736 git_commit
$testroot/repo
-m "changed executable file"
738 echo "U xfile" > $testroot/stdout.expected
739 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
740 git_show_head
$testroot/repo
>> $testroot/stdout.expected
741 echo >> $testroot/stdout.expected
743 (cd $testroot/wt
&& got update
> $testroot/stdout
)
745 if [ "$ret" != "0" ]; then
746 test_done
"$testroot" "$ret"
750 cmp -s $testroot/stdout.expected
$testroot/stdout
752 if [ "$ret" != "0" ]; then
753 diff -u $testroot/stdout.expected
$testroot/stdout
754 test_done
"$testroot" "$ret"
758 ls -l $testroot/wt
/xfile |
grep -q '^-rwx'
760 if [ "$ret" != "0" ]; then
761 echo "file is not executable" >&2
762 ls -l $testroot/wt
/xfile
>&2
764 test_done
"$testroot" "$ret"
767 test_update_clears_xbit
() {
768 local testroot
=`test_init update_clears_xbit 1`
770 touch $testroot/repo
/xfile
771 chmod +x
$testroot/repo
/xfile
772 (cd $testroot/repo
&& git add .
)
773 git_commit
$testroot/repo
-m "adding executable file"
775 got checkout
$testroot/repo
$testroot/wt
> $testroot/stdout
777 if [ "$ret" != "0" ]; then
778 test_done
"$testroot" "$ret"
782 ls -l $testroot/wt
/xfile |
grep -q '^-rwx'
784 if [ "$ret" != "0" ]; then
785 echo "file is not executable" >&2
786 ls -l $testroot/wt
/xfile
>&2
787 test_done
"$testroot" "$ret"
791 # XXX git seems to require a file edit when flipping the x bit?
792 echo foo
> $testroot/repo
/xfile
793 chmod -x $testroot/repo
/xfile
794 git_commit
$testroot/repo
-m "not an executable file anymore"
796 echo "U xfile" > $testroot/stdout.expected
797 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
798 git_show_head
$testroot/repo
>> $testroot/stdout.expected
799 echo >> $testroot/stdout.expected
801 (cd $testroot/wt
&& got update
> $testroot/stdout
)
803 if [ "$ret" != "0" ]; then
804 test_done
"$testroot" "$ret"
808 cmp -s $testroot/stdout.expected
$testroot/stdout
810 if [ "$ret" != "0" ]; then
811 diff -u $testroot/stdout.expected
$testroot/stdout
812 test_done
"$testroot" "$ret"
816 ls -l $testroot/wt
/xfile |
grep -q '^-rw-'
818 if [ "$ret" != "0" ]; then
819 echo "file is unexpectedly executable" >&2
820 ls -l $testroot/wt
/xfile
>&2
822 test_done
"$testroot" "$ret"
825 test_update_restores_missing_file
() {
826 local testroot
=`test_init update_restores_missing_file`
828 got checkout
$testroot/repo
$testroot/wt
> /dev
/null
830 if [ "$ret" != "0" ]; then
831 test_done
"$testroot" "$ret"
835 rm $testroot/wt
/alpha
837 echo "! alpha" > $testroot/stdout.expected
838 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
839 git_show_head
$testroot/repo
>> $testroot/stdout.expected
840 echo >> $testroot/stdout.expected
841 (cd $testroot/wt
&& got update
> $testroot/stdout
)
843 cmp -s $testroot/stdout.expected
$testroot/stdout
845 if [ "$ret" != "0" ]; then
846 diff -u $testroot/stdout.expected
$testroot/stdout
847 test_done
"$testroot" "$ret"
851 echo "alpha" > $testroot/content.expected
853 cat $testroot/wt
/alpha
> $testroot/content
855 cmp -s $testroot/content.expected
$testroot/content
857 if [ "$ret" != "0" ]; then
858 diff -u $testroot/content.expected
$testroot/content
860 test_done
"$testroot" "$ret"
863 test_update_conflict_wt_add_vs_repo_add
() {
864 local testroot
=`test_init update_conflict_wt_add_vs_repo_add`
866 got checkout
$testroot/repo
$testroot/wt
> /dev
/null
868 if [ "$ret" != "0" ]; then
869 test_done
"$testroot" "$ret"
873 echo "new" > $testroot/repo
/gamma
/new
874 (cd $testroot/repo
&& git add .
)
875 git_commit
$testroot/repo
-m "adding a new file"
877 echo "also new" > $testroot/wt
/gamma
/new
878 (cd $testroot/wt
&& got add gamma
/new
>/dev
/null
)
880 (cd $testroot/wt
&& got update
> $testroot/stdout
)
882 echo "C gamma/new" > $testroot/stdout.expected
883 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
884 git_show_head
$testroot/repo
>> $testroot/stdout.expected
885 echo >> $testroot/stdout.expected
886 echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
888 cmp -s $testroot/stdout.expected
$testroot/stdout
890 if [ "$ret" != "0" ]; then
891 diff -u $testroot/stdout.expected
$testroot/stdout
892 test_done
"$testroot" "$ret"
896 echo -n "<<<<<<< merged change: commit " > $testroot/content.expected
897 git_show_head
$testroot/repo
>> $testroot/content.expected
898 echo >> $testroot/content.expected
899 echo "new" >> $testroot/content.expected
900 echo "=======" >> $testroot/content.expected
901 echo "also new" >> $testroot/content.expected
902 echo '>>>>>>>' >> $testroot/content.expected
904 cat $testroot/wt
/gamma
/new
> $testroot/content
906 cmp -s $testroot/content.expected
$testroot/content
908 if [ "$ret" != "0" ]; then
909 diff -u $testroot/content.expected
$testroot/content
910 test_done
"$testroot" "$ret"
914 # resolve the conflict
915 echo "new and also new" > $testroot/wt
/gamma
/new
916 echo 'M gamma/new' > $testroot/stdout.expected
917 (cd $testroot/wt
&& got status
> $testroot/stdout
)
918 cmp -s $testroot/stdout.expected
$testroot/stdout
920 if [ "$ret" != "0" ]; then
921 diff -u $testroot/stdout.expected
$testroot/stdout
923 test_done
"$testroot" "$ret"
926 test_update_conflict_wt_edit_vs_repo_rm
() {
927 local testroot
=`test_init update_conflict_wt_edit_vs_repo_rm`
929 got checkout
$testroot/repo
$testroot/wt
> /dev
/null
931 if [ "$ret" != "0" ]; then
932 test_done
"$testroot" "$ret"
936 (cd $testroot/repo
&& git
rm -q beta
)
937 git_commit
$testroot/repo
-m "removing a file"
939 echo "modified beta" > $testroot/wt
/beta
941 (cd $testroot/wt
&& got update
> $testroot/stdout
)
943 echo "G beta" > $testroot/stdout.expected
944 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
945 git_show_head
$testroot/repo
>> $testroot/stdout.expected
946 echo >> $testroot/stdout.expected
947 cmp -s $testroot/stdout.expected
$testroot/stdout
949 if [ "$ret" != "0" ]; then
950 diff -u $testroot/stdout.expected
$testroot/stdout
951 test_done
"$testroot" "$ret"
955 echo "modified beta" > $testroot/content.expected
957 cat $testroot/wt
/beta
> $testroot/content
959 cmp -s $testroot/content.expected
$testroot/content
961 if [ "$ret" != "0" ]; then
962 diff -u $testroot/content.expected
$testroot/content
963 test_done
"$testroot" "$ret"
967 # beta is now an added file... we don't flag tree conflicts yet
968 echo 'A beta' > $testroot/stdout.expected
969 (cd $testroot/wt
&& got status
> $testroot/stdout
)
970 cmp -s $testroot/stdout.expected
$testroot/stdout
972 if [ "$ret" != "0" ]; then
973 diff -u $testroot/stdout.expected
$testroot/stdout
975 test_done
"$testroot" "$ret"
978 test_update_conflict_wt_rm_vs_repo_edit
() {
979 local testroot
=`test_init update_conflict_wt_rm_vs_repo_edit`
981 got checkout
$testroot/repo
$testroot/wt
> /dev
/null
983 if [ "$ret" != "0" ]; then
984 test_done
"$testroot" "$ret"
988 echo "modified beta" > $testroot/repo
/beta
989 git_commit
$testroot/repo
-m "modified a file"
991 (cd $testroot/wt
&& got
rm beta
> /dev
/null
)
993 (cd $testroot/wt
&& got update
> $testroot/stdout
)
995 echo "G beta" > $testroot/stdout.expected
996 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
997 git_show_head
$testroot/repo
>> $testroot/stdout.expected
998 echo >> $testroot/stdout.expected
999 cmp -s $testroot/stdout.expected
$testroot/stdout
1001 if [ "$ret" != "0" ]; then
1002 diff -u $testroot/stdout.expected
$testroot/stdout
1003 test_done
"$testroot" "$ret"
1007 # beta remains a deleted file... we don't flag tree conflicts yet
1008 echo 'D beta' > $testroot/stdout.expected
1009 (cd $testroot/wt
&& got status
> $testroot/stdout
)
1010 cmp -s $testroot/stdout.expected
$testroot/stdout
1012 if [ "$ret" != "0" ]; then
1013 diff -u $testroot/stdout.expected
$testroot/stdout
1014 test_done
"$testroot" "$ret"
1018 # 'got diff' should show post-update contents of beta being deleted
1019 local head_rev
=`git_show_head $testroot/repo`
1020 echo "diff $head_rev $testroot/wt" > $testroot/stdout.expected
1021 echo -n 'blob - ' >> $testroot/stdout.expected
1022 got tree
-r $testroot/repo
-i |
grep 'beta$' | cut
-d' ' -f 1 \
1023 >> $testroot/stdout.expected
1024 echo 'file + /dev/null' >> $testroot/stdout.expected
1025 echo '--- beta' >> $testroot/stdout.expected
1026 echo '+++ /dev/null' >> $testroot/stdout.expected
1027 echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
1028 echo '-modified beta' >> $testroot/stdout.expected
1030 (cd $testroot/wt
&& got
diff > $testroot/stdout
)
1031 cmp -s $testroot/stdout.expected
$testroot/stdout
1033 if [ "$ret" != "0" ]; then
1034 diff -u $testroot/stdout.expected
$testroot/stdout
1036 test_done
"$testroot" "$ret"
1039 test_update_conflict_wt_rm_vs_repo_rm
() {
1040 local testroot
=`test_init update_conflict_wt_rm_vs_repo_rm`
1042 got checkout
$testroot/repo
$testroot/wt
> /dev
/null
1044 if [ "$ret" != "0" ]; then
1045 test_done
"$testroot" "$ret"
1049 (cd $testroot/repo
&& git
rm -q beta
)
1050 git_commit
$testroot/repo
-m "removing a file"
1052 (cd $testroot/wt
&& got
rm beta
> /dev
/null
)
1054 (cd $testroot/wt
&& got update
> $testroot/stdout
)
1056 echo "D beta" > $testroot/stdout.expected
1057 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
1058 git_show_head
$testroot/repo
>> $testroot/stdout.expected
1059 echo >> $testroot/stdout.expected
1060 cmp -s $testroot/stdout.expected
$testroot/stdout
1062 if [ "$ret" != "0" ]; then
1063 diff -u $testroot/stdout.expected
$testroot/stdout
1064 test_done
"$testroot" "$ret"
1068 # beta is now gone... we don't flag tree conflicts yet
1069 echo "N beta" > $testroot/stdout.expected
1070 echo -n > $testroot/stderr.expected
1071 (cd $testroot/wt
&& got status beta
> $testroot/stdout \
1072 2> $testroot/stderr
)
1073 cmp -s $testroot/stdout.expected
$testroot/stdout
1075 if [ "$ret" != "0" ]; then
1076 diff -u $testroot/stdout.expected
$testroot/stdout
1077 test_done
"$testroot" "$ret"
1080 cmp -s $testroot/stderr.expected
$testroot/stderr
1082 if [ "$ret" != "0" ]; then
1083 diff -u $testroot/stderr.expected
$testroot/stderr
1084 test_done
"$testroot" "$ret"
1088 if [ -e $testroot/wt
/beta
]; then
1089 echo "removed file beta still exists on disk" >&2
1090 test_done
"$testroot" "1"
1094 test_done
"$testroot" "0"
1097 test_update_partial
() {
1098 local testroot
=`test_init update_partial`
1100 got checkout
$testroot/repo
$testroot/wt
> /dev
/null
1102 if [ "$ret" != "0" ]; then
1103 test_done
"$testroot" "$ret"
1107 echo "modified alpha" > $testroot/repo
/alpha
1108 echo "modified beta" > $testroot/repo
/beta
1109 echo "modified epsilon/zeta" > $testroot/repo
/epsilon
/zeta
1110 git_commit
$testroot/repo
-m "modified two files"
1112 echo "U alpha" > $testroot/stdout.expected
1113 echo "U beta" >> $testroot/stdout.expected
1114 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
1115 git_show_head
$testroot/repo
>> $testroot/stdout.expected
1116 echo >> $testroot/stdout.expected
1118 (cd $testroot/wt
&& got update alpha beta
> $testroot/stdout
)
1120 cmp -s $testroot/stdout.expected
$testroot/stdout
1122 if [ "$ret" != "0" ]; then
1123 diff -u $testroot/stdout.expected
$testroot/stdout
1124 test_done
"$testroot" "$ret"
1128 echo "modified alpha" > $testroot/content.expected
1129 echo "modified beta" >> $testroot/content.expected
1131 cat $testroot/wt
/alpha
$testroot/wt
/beta
> $testroot/content
1132 cmp -s $testroot/content.expected
$testroot/content
1134 if [ "$ret" != "0" ]; then
1135 diff -u $testroot/content.expected
$testroot/content
1136 test_done
"$testroot" "$ret"
1140 echo "U epsilon/zeta" > $testroot/stdout.expected
1141 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
1142 git_show_head
$testroot/repo
>> $testroot/stdout.expected
1143 echo >> $testroot/stdout.expected
1145 (cd $testroot/wt
&& got update epsilon
> $testroot/stdout
)
1147 cmp -s $testroot/stdout.expected
$testroot/stdout
1149 if [ "$ret" != "0" ]; then
1150 diff -u $testroot/stdout.expected
$testroot/stdout
1151 test_done
"$testroot" "$ret"
1155 echo "modified epsilon/zeta" > $testroot/content.expected
1156 cat $testroot/wt
/epsilon
/zeta
> $testroot/content
1158 cmp -s $testroot/content.expected
$testroot/content
1160 if [ "$ret" != "0" ]; then
1161 diff -u $testroot/content.expected
$testroot/content
1162 test_done
"$testroot" "$ret"
1166 test_done
"$testroot" "$ret"
1169 test_update_partial_add
() {
1170 local testroot
=`test_init update_partial_add`
1172 got checkout
$testroot/repo
$testroot/wt
> /dev
/null
1174 if [ "$ret" != "0" ]; then
1175 test_done
"$testroot" "$ret"
1179 echo "new" > $testroot/repo
/new
1180 echo "epsilon/new2" > $testroot/repo
/epsilon
/new2
1181 (cd $testroot/repo
&& git add .
)
1182 git_commit
$testroot/repo
-m "added two files"
1184 echo "A epsilon/new2" > $testroot/stdout.expected
1185 echo "A new" >> $testroot/stdout.expected
1186 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
1187 git_show_head
$testroot/repo
>> $testroot/stdout.expected
1188 echo >> $testroot/stdout.expected
1190 (cd $testroot/wt
&& got update new epsilon
/new2
> $testroot/stdout
)
1192 cmp -s $testroot/stdout.expected
$testroot/stdout
1194 if [ "$ret" != "0" ]; then
1195 diff -u $testroot/stdout.expected
$testroot/stdout
1196 test_done
"$testroot" "$ret"
1200 echo "new" > $testroot/content.expected
1201 echo "epsilon/new2" >> $testroot/content.expected
1203 cat $testroot/wt
/new
$testroot/wt
/epsilon
/new2
> $testroot/content
1205 cmp -s $testroot/content.expected
$testroot/content
1207 if [ "$ret" != "0" ]; then
1208 diff -u $testroot/content.expected
$testroot/content
1210 test_done
"$testroot" "$ret"
1213 test_update_partial_rm
() {
1214 local testroot
=`test_init update_partial_rm`
1216 got checkout
$testroot/repo
$testroot/wt
> /dev
/null
1218 if [ "$ret" != "0" ]; then
1219 test_done
"$testroot" "$ret"
1223 (cd $testroot/repo
&& git
rm -q alpha epsilon
/zeta
)
1224 git_commit
$testroot/repo
-m "removed two files"
1226 echo "got: /alpha: no such entry found in tree" \
1227 > $testroot/stderr.expected
1229 (cd $testroot/wt
&& got update alpha epsilon
/zeta
2> $testroot/stderr
)
1231 if [ "$ret" = "0" ]; then
1232 echo "update succeeded unexpectedly" >&2
1233 test_done
"$testroot" "1"
1237 cmp -s $testroot/stderr.expected
$testroot/stderr
1239 if [ "$ret" != "0" ]; then
1240 diff -u $testroot/stderr.expected
$testroot/stderr
1241 test_done
"$testroot" "$ret"
1244 test_done
"$testroot" "$ret"
1247 test_update_partial_dir
() {
1248 local testroot
=`test_init update_partial_dir`
1250 got checkout
$testroot/repo
$testroot/wt
> /dev
/null
1252 if [ "$ret" != "0" ]; then
1253 test_done
"$testroot" "$ret"
1257 echo "modified alpha" > $testroot/repo
/alpha
1258 echo "modified beta" > $testroot/repo
/beta
1259 echo "modified epsilon/zeta" > $testroot/repo
/epsilon
/zeta
1260 git_commit
$testroot/repo
-m "modified two files"
1262 echo "U epsilon/zeta" > $testroot/stdout.expected
1263 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
1264 git_show_head
$testroot/repo
>> $testroot/stdout.expected
1265 echo >> $testroot/stdout.expected
1267 (cd $testroot/wt
&& got update epsilon
> $testroot/stdout
)
1269 cmp -s $testroot/stdout.expected
$testroot/stdout
1271 if [ "$ret" != "0" ]; then
1272 diff -u $testroot/stdout.expected
$testroot/stdout
1273 test_done
"$testroot" "$ret"
1277 echo "modified epsilon/zeta" > $testroot/content.expected
1278 cat $testroot/wt
/epsilon
/zeta
> $testroot/content
1280 cmp -s $testroot/content.expected
$testroot/content
1282 if [ "$ret" != "0" ]; then
1283 diff -u $testroot/content.expected
$testroot/content
1284 test_done
"$testroot" "$ret"
1287 test_done
"$testroot" "$ret"
1291 test_update_moved_branch_ref
() {
1292 local testroot
=`test_init update_moved_branch_ref`
1294 git clone
-q --mirror $testroot/repo
$testroot/repo2
1296 echo "modified alpha with git" > $testroot/repo
/alpha
1297 git_commit
$testroot/repo
-m "modified alpha with git"
1299 got checkout
$testroot/repo2
$testroot/wt
> /dev
/null
1301 if [ "$ret" != "0" ]; then
1302 test_done
"$testroot" "$ret"
1306 echo "modified alpha with got" > $testroot/wt
/alpha
1307 (cd $testroot/wt
&& got commit
-m "modified alpha with got" > /dev
/null
)
1309 # + xxxxxxx...yyyyyyy master -> master (forced update)
1310 (cd $testroot/repo2
&& git fetch
-q --all)
1312 echo -n > $testroot/stdout.expected
1313 echo -n "got: work tree's head reference now points to a different " \
1314 > $testroot/stderr.expected
1315 echo "branch; new head reference and/or update -b required" \
1316 >> $testroot/stderr.expected
1318 (cd $testroot/wt
&& got update
> $testroot/stdout
2> $testroot/stderr
)
1320 cmp -s $testroot/stdout.expected
$testroot/stdout
1322 if [ "$ret" != "0" ]; then
1323 diff -u $testroot/stdout.expected
$testroot/stdout
1324 test_done
"$testroot" "$ret"
1328 cmp -s $testroot/stderr.expected
$testroot/stderr
1330 if [ "$ret" != "0" ]; then
1331 diff -u $testroot/stderr.expected
$testroot/stderr
1333 test_done
"$testroot" "$ret"
1336 test_update_to_another_branch
() {
1337 local testroot
=`test_init update_to_another_branch`
1338 local base_commit
=`git_show_head $testroot/repo`
1340 got checkout
$testroot/repo
$testroot/wt
> /dev
/null
1342 if [ "$ret" != "0" ]; then
1343 test_done
"$testroot" "$ret"
1347 echo 'refs/heads/master'> $testroot/head-ref.expected
1348 cmp -s $testroot/head-ref.expected
$testroot/wt
/.got
/head-ref
1350 if [ "$ret" != "0" ]; then
1351 diff -u $testroot/head-ref.expected
$testroot/wt
/.got
/head-ref
1352 test_done
"$testroot" "$ret"
1356 (cd $testroot/repo
&& git checkout
-q -b newbranch
)
1357 echo "modified alpha on new branch" > $testroot/repo
/alpha
1358 git_commit
$testroot/repo
-m "modified alpha on new branch"
1360 echo "modified alpha in work tree" > $testroot/wt
/alpha
1362 echo "Switching work tree from refs/heads/master to refs/heads/newbranch" > $testroot/stdout.expected
1363 echo "C alpha" >> $testroot/stdout.expected
1364 echo -n "Updated to refs/heads/newbranch: " >> $testroot/stdout.expected
1365 git_show_head
$testroot/repo
>> $testroot/stdout.expected
1366 echo >> $testroot/stdout.expected
1367 echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
1369 (cd $testroot/wt
&& got update
-b newbranch
> $testroot/stdout
)
1371 cmp -s $testroot/stdout.expected
$testroot/stdout
1373 if [ "$ret" != "0" ]; then
1374 diff -u $testroot/stdout.expected
$testroot/stdout
1375 test_done
"$testroot" "$ret"
1379 echo -n "<<<<<<< merged change: commit " > $testroot/content.expected
1380 git_show_head
$testroot/repo
>> $testroot/content.expected
1381 echo >> $testroot/content.expected
1382 echo "modified alpha on new branch" >> $testroot/content.expected
1383 echo "||||||| 3-way merge base: commit $base_commit" \
1384 >> $testroot/content.expected
1385 echo "alpha" >> $testroot/content.expected
1386 echo "=======" >> $testroot/content.expected
1387 echo "modified alpha in work tree" >> $testroot/content.expected
1388 echo '>>>>>>>' >> $testroot/content.expected
1390 cat $testroot/wt
/alpha
> $testroot/content
1392 cmp -s $testroot/content.expected
$testroot/content
1394 if [ "$ret" != "0" ]; then
1395 diff -u $testroot/content.expected
$testroot/content
1396 test_done
"$testroot" "$ret"
1400 echo 'refs/heads/newbranch'> $testroot/head-ref.expected
1401 cmp -s $testroot/head-ref.expected
$testroot/wt
/.got
/head-ref
1403 if [ "$ret" != "0" ]; then
1404 diff -u $testroot/head-ref.expected
$testroot/wt
/.got
/head-ref
1405 test_done
"$testroot" "$ret"
1409 test_done
"$testroot" "$ret"
1412 test_update_to_commit_on_wrong_branch
() {
1413 local testroot
=`test_init update_to_commit_on_wrong_branch`
1415 got checkout
$testroot/repo
$testroot/wt
> /dev
/null
1417 if [ "$ret" != "0" ]; then
1418 test_done
"$testroot" "$ret"
1422 (cd $testroot/repo
&& git checkout
-q -b newbranch
)
1423 echo "modified alpha on new branch" > $testroot/repo
/alpha
1424 git_commit
$testroot/repo
-m "modified alpha on new branch"
1426 echo -n "" > $testroot/stdout.expected
1427 echo "got: target commit is on a different branch" \
1428 > $testroot/stderr.expected
1430 local head_rev
=`git_show_head $testroot/repo`
1431 (cd $testroot/wt
&& got update
-c $head_rev > $testroot/stdout \
1432 2> $testroot/stderr
)
1434 cmp -s $testroot/stdout.expected
$testroot/stdout
1436 if [ "$ret" != "0" ]; then
1437 diff -u $testroot/stdout.expected
$testroot/stdout
1438 test_done
"$testroot" "$ret"
1442 cmp -s $testroot/stderr.expected
$testroot/stderr
1444 if [ "$ret" != "0" ]; then
1445 diff -u $testroot/stderr.expected
$testroot/stderr
1446 test_done
"$testroot" "$ret"
1450 test_done
"$testroot" "$ret"
1453 test_update_bumps_base_commit_id
() {
1454 local testroot
=`test_init update_bumps_base_commit_id`
1456 echo "psi" > $testroot/repo
/epsilon
/psi
1457 (cd $testroot/repo
&& git add .
)
1458 git_commit
$testroot/repo
-m "adding another file"
1460 got checkout
$testroot/repo
$testroot/wt
> /dev
/null
1462 if [ "$ret" != "0" ]; then
1463 test_done
"$testroot" "$ret"
1467 echo "modified psi" > $testroot/wt
/epsilon
/psi
1468 (cd $testroot/wt
&& got commit
-m "changed psi" > $testroot/stdout
)
1470 local head_rev
=`git_show_head $testroot/repo`
1471 echo "M epsilon/psi" > $testroot/stdout.expected
1472 echo "Created commit $head_rev" >> $testroot/stdout.expected
1473 cmp -s $testroot/stdout.expected
$testroot/stdout
1475 if [ "$ret" != "0" ]; then
1476 diff -u $testroot/stdout.expected
$testroot/stdout
1477 test_done
"$testroot" "$ret"
1481 echo "changed zeta with git" > $testroot/repo
/epsilon
/zeta
1482 (cd $testroot/repo
&& git add .
)
1483 git_commit
$testroot/repo
-m "changing zeta with git"
1485 echo "modified zeta" > $testroot/wt
/epsilon
/zeta
1486 (cd $testroot/wt
&& got commit
-m "changed zeta" > $testroot/stdout \
1487 2> $testroot/stderr
)
1489 echo -n "" > $testroot/stdout.expected
1490 echo "got: work tree must be updated before these changes can be committed" > $testroot/stderr.expected
1491 cmp -s $testroot/stderr.expected
$testroot/stderr
1493 if [ "$ret" != "0" ]; then
1494 diff -u $testroot/stderr.expected
$testroot/stderr
1495 test_done
"$testroot" "$ret"
1499 (cd $testroot/wt
&& got update
> $testroot/stdout
)
1501 echo "U epsilon/psi" > $testroot/stdout.expected
1502 echo "C epsilon/zeta" >> $testroot/stdout.expected
1503 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
1504 git_show_head
$testroot/repo
>> $testroot/stdout.expected
1505 echo >> $testroot/stdout.expected
1506 echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
1508 cmp -s $testroot/stdout.expected
$testroot/stdout
1510 if [ "$ret" != "0" ]; then
1511 diff -u $testroot/stdout.expected
$testroot/stdout
1512 test_done
"$testroot" "$ret"
1517 echo "modified zeta with got and git" > $testroot/wt
/epsilon
/zeta
1519 (cd $testroot/wt
&& got commit
-m "changed zeta" > $testroot/stdout
)
1521 local head_rev
=`git_show_head $testroot/repo`
1522 echo "M epsilon/zeta" > $testroot/stdout.expected
1523 echo "Created commit $head_rev" >> $testroot/stdout.expected
1524 cmp -s $testroot/stdout.expected
$testroot/stdout
1526 if [ "$ret" != "0" ]; then
1527 diff -u $testroot/stdout.expected
$testroot/stdout
1528 test_done
"$testroot" "$ret"
1532 test_done
"$testroot" "$ret"
1536 local testroot
=`test_init update_tag`
1539 got checkout
$testroot/repo
$testroot/wt
> /dev
/null
1541 if [ "$ret" != "0" ]; then
1542 test_done
"$testroot" "$ret"
1546 echo "modified alpha" > $testroot/repo
/alpha
1547 git_commit
$testroot/repo
-m "modified alpha"
1548 (cd $testroot/repo
&& git tag
-m "test" -a $tag)
1550 echo "U alpha" > $testroot/stdout.expected
1551 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
1552 git_show_head
$testroot/repo
>> $testroot/stdout.expected
1553 echo >> $testroot/stdout.expected
1555 (cd $testroot/wt
&& got update
-c $tag > $testroot/stdout
)
1557 cmp -s $testroot/stdout.expected
$testroot/stdout
1559 if [ "$ret" != "0" ]; then
1560 diff -u $testroot/stdout.expected
$testroot/stdout
1561 test_done
"$testroot" "$ret"
1565 echo "modified alpha" > $testroot/content.expected
1566 cat $testroot/wt
/alpha
> $testroot/content
1568 cmp -s $testroot/content.expected
$testroot/content
1570 if [ "$ret" != "0" ]; then
1571 diff -u $testroot/content.expected
$testroot/content
1573 test_done
"$testroot" "$ret"
1576 test_update_toggles_xbit
() {
1577 local testroot
=`test_init update_toggles_xbit 1`
1579 touch $testroot/repo
/xfile
1580 chmod +x
$testroot/repo
/xfile
1581 (cd $testroot/repo
&& git add .
)
1582 git_commit
$testroot/repo
-m "adding executable file"
1583 local commit_id1
=`git_show_head $testroot/repo`
1585 got checkout
$testroot/repo
$testroot/wt
> $testroot/stdout
1587 if [ "$ret" != "0" ]; then
1588 test_done
"$testroot" "$ret"
1592 ls -l $testroot/wt
/xfile |
grep -q '^-rwx'
1594 if [ "$ret" != "0" ]; then
1595 echo "file is not executable" >&2
1596 ls -l $testroot/wt
/xfile
>&2
1597 test_done
"$testroot" "$ret"
1601 chmod -x $testroot/wt
/xfile
1602 (cd $testroot/wt
&& got commit
-m "clear x bit" >/dev
/null
)
1603 local commit_id2
=`git_show_head $testroot/repo`
1605 echo "U xfile" > $testroot/stdout.expected
1606 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
1607 git_show_head
$testroot/repo
>> $testroot/stdout.expected
1608 echo >> $testroot/stdout.expected
1610 (cd $testroot/wt
&& got update
-c $commit_id1 > $testroot/stdout
)
1612 if [ "$ret" != "0" ]; then
1613 test_done
"$testroot" "$ret"
1617 echo "U xfile" > $testroot/stdout.expected
1618 echo "Updated to refs/heads/master: $commit_id1" >> $testroot/stdout.expected
1619 cmp -s $testroot/stdout.expected
$testroot/stdout
1621 if [ "$ret" != "0" ]; then
1622 diff -u $testroot/stdout.expected
$testroot/stdout
1623 test_done
"$testroot" "$ret"
1628 ls -l $testroot/wt
/xfile |
grep -q '^-rwx'
1630 if [ "$ret" != "0" ]; then
1631 echo "file is not executable" >&2
1632 ls -l $testroot/wt
/xfile
>&2
1633 test_done
"$testroot" "$ret"
1637 (cd $testroot/wt
&& got update
> $testroot/stdout
)
1639 if [ "$ret" != "0" ]; then
1640 test_done
"$testroot" "$ret"
1644 echo "U xfile" > $testroot/stdout.expected
1645 echo "Updated to refs/heads/master: $commit_id2" \
1646 >> $testroot/stdout.expected
1647 cmp -s $testroot/stdout.expected
$testroot/stdout
1649 if [ "$ret" != "0" ]; then
1650 diff -u $testroot/stdout.expected
$testroot/stdout
1651 test_done
"$testroot" "$ret"
1655 ls -l $testroot/wt
/xfile |
grep -q '^-rw-'
1657 if [ "$ret" != "0" ]; then
1658 echo "file is unexpectedly executable" >&2
1659 ls -l $testroot/wt
/xfile
>&2
1661 test_done
"$testroot" "$ret"
1664 test_update_preserves_conflicted_file
() {
1665 local testroot
=`test_init update_preserves_conflicted_file`
1666 local commit_id0
=`git_show_head $testroot/repo`
1668 echo "modified alpha" > $testroot/repo
/alpha
1669 git_commit
$testroot/repo
-m "modified alpha"
1670 local commit_id1
=`git_show_head $testroot/repo`
1672 got checkout
-c $commit_id0 $testroot/repo
$testroot/wt
> /dev
/null
1674 if [ "$ret" != "0" ]; then
1675 test_done
"$testroot" "$ret"
1679 # fake a merge conflict
1680 echo '<<<<<<<' > $testroot/wt
/alpha
1681 echo 'alpha' >> $testroot/wt
/alpha
1682 echo '=======' >> $testroot/wt
/alpha
1683 echo 'alpha, too' >> $testroot/wt
/alpha
1684 echo '>>>>>>>' >> $testroot/wt
/alpha
1685 cp $testroot/wt
/alpha
$testroot/content.expected
1687 echo "C alpha" > $testroot/stdout.expected
1688 (cd $testroot/wt
&& got status
> $testroot/stdout
)
1689 cmp -s $testroot/stdout.expected
$testroot/stdout
1691 if [ "$ret" != "0" ]; then
1692 diff -u $testroot/stdout.expected
$testroot/stdout
1693 test_done
"$testroot" "$ret"
1697 echo "# alpha" > $testroot/stdout.expected
1698 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
1699 git_show_head
$testroot/repo
>> $testroot/stdout.expected
1700 echo >> $testroot/stdout.expected
1701 echo "Files not updated because of existing merge conflicts: 1" \
1702 >> $testroot/stdout.expected
1703 (cd $testroot/wt
&& got update
> $testroot/stdout
)
1705 cmp -s $testroot/stdout.expected
$testroot/stdout
1707 if [ "$ret" != "0" ]; then
1708 diff -u $testroot/stdout.expected
$testroot/stdout
1709 test_done
"$testroot" "$ret"
1713 cmp -s $testroot/content.expected
$testroot/wt
/alpha
1715 if [ "$ret" != "0" ]; then
1716 diff -u $testroot/content.expected
$testroot/wt
/alpha
1718 test_done
"$testroot" "$ret"
1721 test_update_modified_submodules
() {
1722 local testroot
=`test_init update_modified_submodules`
1724 make_single_file_repo
$testroot/repo2 foo
1726 (cd $testroot/repo
&& git submodule
-q add ..
/repo2
)
1727 (cd $testroot/repo
&& git commit
-q -m 'adding submodule')
1729 got checkout
$testroot/repo
$testroot/wt
> /dev
/null
1731 echo "modified foo" > $testroot/repo
2/foo
1732 (cd $testroot/repo2
&& git commit
-q -a -m 'modified a submodule')
1734 # Update the repo/repo2 submodule link
1735 (cd $testroot/repo
&& git
-C repo2 pull
-q)
1736 (cd $testroot/repo
&& git add repo2
)
1737 git_commit
$testroot/repo
-m "modified submodule link"
1739 # This update only records the new base commit. Otherwise it is a
1740 # no-op change because Got's file index does not track submodules.
1741 echo -n "Updated to refs/heads/master: " > $testroot/stdout.expected
1742 git_show_head
$testroot/repo
>> $testroot/stdout.expected
1743 echo >> $testroot/stdout.expected
1745 (cd $testroot/wt
&& got update
> $testroot/stdout
)
1747 cmp -s $testroot/stdout.expected
$testroot/stdout
1749 if [ "$ret" != "0" ]; then
1750 diff -u $testroot/stdout.expected
$testroot/stdout
1752 test_done
"$testroot" "$ret"
1755 test_update_adds_submodule
() {
1756 local testroot
=`test_init update_adds_submodule`
1758 got checkout
$testroot/repo
$testroot/wt
> /dev
/null
1760 make_single_file_repo
$testroot/repo2 foo
1762 echo "modified foo" > $testroot/repo
2/foo
1763 (cd $testroot/repo2
&& git commit
-q -a -m 'modified a submodule')
1765 (cd $testroot/repo
&& git submodule
-q add ..
/repo2
)
1766 (cd $testroot/repo
&& git commit
-q -m 'adding submodule')
1768 echo "A .gitmodules" > $testroot/stdout.expected
1769 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
1770 git_show_head
$testroot/repo
>> $testroot/stdout.expected
1771 echo >> $testroot/stdout.expected
1773 (cd $testroot/wt
&& got update
> $testroot/stdout
)
1775 cmp -s $testroot/stdout.expected
$testroot/stdout
1777 if [ "$ret" != "0" ]; then
1778 diff -u $testroot/stdout.expected
$testroot/stdout
1780 test_done
"$testroot" "$ret"
1783 test_update_conflict_wt_file_vs_repo_submodule
() {
1784 local testroot
=`test_init update_conflict_wt_file_vs_repo_submodule`
1786 got checkout
$testroot/repo
$testroot/wt
> /dev
/null
1788 make_single_file_repo
$testroot/repo2 foo
1790 # Add a file which will clash with the submodule
1791 echo "This is a file called repo2" > $testroot/wt
/repo2
1792 (cd $testroot/wt
&& got add repo2
> /dev
/null
)
1793 (cd $testroot/wt
&& got commit
-m 'add file repo2' > /dev
/null
)
1795 if [ "$ret" != "0" ]; then
1796 echo "commit failed unexpectedly" >&2
1797 test_done
"$testroot" "1"
1801 (cd $testroot/repo
&& git submodule
-q add ..
/repo2
)
1802 (cd $testroot/repo
&& git commit
-q -m 'adding submodule')
1804 # Modify the clashing file such that any modifications brought
1805 # in by 'got update' would require a merge.
1806 echo "This file was changed" > $testroot/wt
/repo2
1808 # No conflict occurs because 'got update' ignores the submodule
1809 # and leaves the clashing file as it was.
1810 echo "A .gitmodules" > $testroot/stdout.expected
1811 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
1812 git_show_head
$testroot/repo
>> $testroot/stdout.expected
1813 echo >> $testroot/stdout.expected
1815 (cd $testroot/wt
&& got update
> $testroot/stdout
)
1817 cmp -s $testroot/stdout.expected
$testroot/stdout
1819 if [ "$ret" != "0" ]; then
1820 diff -u $testroot/stdout.expected
$testroot/stdout
1821 test_done
"$testroot" "$ret"
1825 (cd $testroot/wt
&& got status
> $testroot/stdout
)
1827 echo "M repo2" > $testroot/stdout.expected
1828 cmp -s $testroot/stdout.expected
$testroot/stdout
1830 if [ "$ret" != "0" ]; then
1831 diff -u $testroot/stdout.expected
$testroot/stdout
1833 test_done
"$testroot" "$ret"
1836 test_update_adds_symlink
() {
1837 local testroot
=`test_init update_adds_symlink`
1839 got checkout
$testroot/repo
$testroot/wt
> /dev
/null
1841 if [ "$ret" != "0" ]; then
1842 echo "checkout failed unexpectedly" >&2
1843 test_done
"$testroot" "$ret"
1847 (cd $testroot/repo
&& ln -s alpha alpha.link
)
1848 (cd $testroot/repo
&& ln -s epsilon epsilon.link
)
1849 (cd $testroot/repo
&& ln -s /etc
/passwd passwd.link
)
1850 (cd $testroot/repo
&& ln -s ..
/beta epsilon
/beta.link
)
1851 (cd $testroot/repo
&& ln -s nonexistent nonexistent.link
)
1852 (cd $testroot/repo
&& git add .
)
1853 git_commit
$testroot/repo
-m "add symlinks"
1855 echo "A alpha.link" > $testroot/stdout.expected
1856 echo "A epsilon/beta.link" >> $testroot/stdout.expected
1857 echo "A epsilon.link" >> $testroot/stdout.expected
1858 echo "A nonexistent.link" >> $testroot/stdout.expected
1859 echo "A passwd.link" >> $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
1864 (cd $testroot/wt
&& got update
> $testroot/stdout
)
1866 cmp -s $testroot/stdout.expected
$testroot/stdout
1868 if [ "$ret" != "0" ]; then
1869 diff -u $testroot/stdout.expected
$testroot/stdout
1870 test_done
"$testroot" "$ret"
1874 if ! [ -h $testroot/wt
/alpha.link
]; then
1875 echo "alpha.link is not a symlink"
1876 test_done
"$testroot" "1"
1880 readlink
$testroot/wt
/alpha.link
> $testroot/stdout
1881 echo "alpha" > $testroot/stdout.expected
1882 cmp -s $testroot/stdout.expected
$testroot/stdout
1884 if [ "$ret" != "0" ]; then
1885 diff -u $testroot/stdout.expected
$testroot/stdout
1886 test_done
"$testroot" "$ret"
1890 if ! [ -h $testroot/wt
/epsilon.link
]; then
1891 echo "epsilon.link is not a symlink"
1892 test_done
"$testroot" "1"
1896 readlink
$testroot/wt
/epsilon.link
> $testroot/stdout
1897 echo "epsilon" > $testroot/stdout.expected
1898 cmp -s $testroot/stdout.expected
$testroot/stdout
1900 if [ "$ret" != "0" ]; then
1901 diff -u $testroot/stdout.expected
$testroot/stdout
1902 test_done
"$testroot" "$ret"
1906 if [ -h $testroot/wt
/passwd.link
]; then
1907 echo -n "passwd.link symlink points outside of work tree: " >&2
1908 readlink
$testroot/wt
/passwd.link
>&2
1909 test_done
"$testroot" "1"
1913 echo -n "/etc/passwd" > $testroot/content.expected
1914 cp $testroot/wt
/passwd.link
$testroot/content
1916 cmp -s $testroot/content.expected
$testroot/content
1918 if [ "$ret" != "0" ]; then
1919 diff -u $testroot/content.expected
$testroot/content
1920 test_done
"$testroot" "$ret"
1924 readlink
$testroot/wt
/epsilon
/beta.link
> $testroot/stdout
1925 echo "../beta" > $testroot/stdout.expected
1926 cmp -s $testroot/stdout.expected
$testroot/stdout
1928 if [ "$ret" != "0" ]; then
1929 diff -u $testroot/stdout.expected
$testroot/stdout
1930 test_done
"$testroot" "$ret"
1934 readlink
$testroot/wt
/nonexistent.link
> $testroot/stdout
1935 echo "nonexistent" > $testroot/stdout.expected
1936 cmp -s $testroot/stdout.expected
$testroot/stdout
1938 if [ "$ret" != "0" ]; then
1939 diff -u $testroot/stdout.expected
$testroot/stdout
1940 test_done
"$testroot" "$ret"
1944 # Updating an up-to-date symlink should be a no-op.
1945 echo 'Already up-to-date' > $testroot/stdout.expected
1946 (cd $testroot/wt
&& got update
> $testroot/stdout
)
1947 cmp -s $testroot/stdout.expected
$testroot/stdout
1949 if [ "$ret" != "0" ]; then
1950 diff -u $testroot/stdout.expected
$testroot/stdout
1952 test_done
"$testroot" "$ret"
1955 test_update_deletes_symlink
() {
1956 local testroot
=`test_init update_deletes_symlink`
1958 (cd $testroot/repo
&& ln -s alpha alpha.link
)
1959 (cd $testroot/repo
&& git add .
)
1960 git_commit
$testroot/repo
-m "add symlink"
1962 got checkout
$testroot/repo
$testroot/wt
> /dev
/null
1964 if [ "$ret" != "0" ]; then
1965 echo "checkout failed unexpectedly" >&2
1966 test_done
"$testroot" "$ret"
1970 (cd $testroot/repo
&& git
rm -q alpha.link
)
1971 git_commit
$testroot/repo
-m "delete symlink"
1973 echo "D alpha.link" > $testroot/stdout.expected
1974 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
1975 git_show_head
$testroot/repo
>> $testroot/stdout.expected
1976 echo >> $testroot/stdout.expected
1978 (cd $testroot/wt
&& got update
> $testroot/stdout
)
1980 cmp -s $testroot/stdout.expected
$testroot/stdout
1982 if [ "$ret" != "0" ]; then
1983 diff -u $testroot/stdout.expected
$testroot/stdout
1984 test_done
"$testroot" "$ret"
1988 if [ -e $testroot/wt
/alpha.link
]; then
1989 echo "alpha.link still exists on disk"
1990 test_done
"$testroot" "1"
1994 test_done
"$testroot" "0"
1997 test_update_symlink_conflicts
() {
1998 local testroot
=`test_init update_symlink_conflicts`
2000 (cd $testroot/repo
&& ln -s alpha alpha.link
)
2001 (cd $testroot/repo
&& ln -s epsilon epsilon.link
)
2002 (cd $testroot/repo
&& ln -s /etc
/passwd passwd.link
)
2003 (cd $testroot/repo
&& ln -s ..
/beta epsilon
/beta.link
)
2004 (cd $testroot/repo
&& ln -s nonexistent nonexistent.link
)
2005 (cd $testroot/repo
&& ln -sf epsilon
/zeta zeta.link
)
2006 (cd $testroot/repo
&& git add .
)
2007 git_commit
$testroot/repo
-m "add symlinks"
2008 local commit_id1
=`git_show_head $testroot/repo`
2010 got checkout
$testroot/repo
$testroot/wt
> /dev
/null
2012 if [ "$ret" != "0" ]; then
2013 echo "checkout failed unexpectedly" >&2
2014 test_done
"$testroot" "$ret"
2018 (cd $testroot/repo
&& ln -sf beta alpha.link
)
2019 (cd $testroot/repo
&& ln -sfT gamma epsilon.link
)
2020 (cd $testroot/repo
&& ln -sf ..
/gamma
/delta epsilon
/beta.link
)
2021 echo 'this is regular file foo' > $testroot/repo
/dotgotfoo.link
2022 (cd $testroot/repo
&& ln -sf .got
/bar dotgotbar.link
)
2023 (cd $testroot/repo
&& git
rm -q nonexistent.link
)
2024 (cd $testroot/repo
&& ln -sf gamma
/delta zeta.link
)
2025 (cd $testroot/repo
&& ln -sf alpha new.link
)
2026 (cd $testroot/repo
&& git add .
)
2027 git_commit
$testroot/repo
-m "change symlinks"
2028 local commit_id2
=`git_show_head $testroot/repo`
2030 # modified symlink to file A vs modified symlink to file B
2031 (cd $testroot/wt
&& ln -sf gamma
/delta alpha.link
)
2032 # modified symlink to dir A vs modified symlink to file B
2033 (cd $testroot/wt
&& ln -sfT beta epsilon.link
)
2034 # modeified symlink to file A vs modified symlink to dir B
2035 (cd $testroot/wt
&& ln -sfT ..
/gamma epsilon
/beta.link
)
2036 # added regular file A vs added bad symlink to file A
2037 (cd $testroot/wt
&& ln -sf .got
/bar dotgotfoo.link
)
2038 (cd $testroot/wt
&& got add dotgotfoo.link
> /dev
/null
)
2039 # added bad symlink to file A vs added regular file A
2040 echo 'this is regular file bar' > $testroot/wt
/dotgotbar.link
2041 (cd $testroot/wt
&& got add dotgotbar.link
> /dev
/null
)
2042 # removed symlink to non-existent file A vs modified symlink
2043 # to nonexistent file B
2044 (cd $testroot/wt
&& ln -sf nonexistent2 nonexistent.link
)
2045 # modified symlink to file A vs removed symlink to file A
2046 (cd $testroot/wt
&& got
rm zeta.link
> /dev
/null
)
2047 # added symlink to file A vs added symlink to file B
2048 (cd $testroot/wt
&& ln -sf beta new.link
)
2049 (cd $testroot/wt
&& got add new.link
> /dev
/null
)
2051 (cd $testroot/wt
&& got update
> $testroot/stdout
)
2053 echo "C alpha.link" >> $testroot/stdout.expected
2054 echo "C dotgotbar.link" >> $testroot/stdout.expected
2055 echo "C dotgotfoo.link" >> $testroot/stdout.expected
2056 echo "C epsilon/beta.link" >> $testroot/stdout.expected
2057 echo "C epsilon.link" >> $testroot/stdout.expected
2058 echo "C new.link" >> $testroot/stdout.expected
2059 echo "C nonexistent.link" >> $testroot/stdout.expected
2060 echo "G zeta.link" >> $testroot/stdout.expected
2061 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
2062 git_show_head
$testroot/repo
>> $testroot/stdout.expected
2063 echo >> $testroot/stdout.expected
2064 echo "Files with new merge conflicts: 7" >> $testroot/stdout.expected
2066 cmp -s $testroot/stdout.expected
$testroot/stdout
2068 if [ "$ret" != "0" ]; then
2069 diff -u $testroot/stdout.expected
$testroot/stdout
2070 test_done
"$testroot" "$ret"
2074 if [ -h $testroot/wt
/alpha.link
]; then
2075 echo "alpha.link is a symlink"
2076 test_done
"$testroot" "1"
2080 echo "<<<<<<< merged change: commit $commit_id2" \
2081 > $testroot/content.expected
2082 echo "beta" >> $testroot/content.expected
2083 echo "3-way merge base: commit $commit_id1" \
2084 >> $testroot/content.expected
2085 echo "alpha" >> $testroot/content.expected
2086 echo "=======" >> $testroot/content.expected
2087 echo "gamma/delta" >> $testroot/content.expected
2088 echo '>>>>>>>' >> $testroot/content.expected
2089 echo -n "" >> $testroot/content.expected
2091 cp $testroot/wt
/alpha.link
$testroot/content
2092 cmp -s $testroot/content.expected
$testroot/content
2094 if [ "$ret" != "0" ]; then
2095 diff -u $testroot/content.expected
$testroot/content
2096 test_done
"$testroot" "$ret"
2100 if [ -h $testroot/wt
/epsilon.link
]; then
2101 echo "epsilon.link is a symlink"
2102 test_done
"$testroot" "1"
2106 echo "<<<<<<< merged change: commit $commit_id2" \
2107 > $testroot/content.expected
2108 echo "gamma" >> $testroot/content.expected
2109 echo "3-way merge base: commit $commit_id1" \
2110 >> $testroot/content.expected
2111 echo "epsilon" >> $testroot/content.expected
2112 echo "=======" >> $testroot/content.expected
2113 echo "beta" >> $testroot/content.expected
2114 echo '>>>>>>>' >> $testroot/content.expected
2115 echo -n "" >> $testroot/content.expected
2117 cp $testroot/wt
/epsilon.link
$testroot/content
2118 cmp -s $testroot/content.expected
$testroot/content
2120 if [ "$ret" != "0" ]; then
2121 diff -u $testroot/content.expected
$testroot/content
2122 test_done
"$testroot" "$ret"
2126 if [ -h $testroot/wt
/passwd.link
]; then
2127 echo -n "passwd.link symlink points outside of work tree: " >&2
2128 readlink
$testroot/wt
/passwd.link
>&2
2129 test_done
"$testroot" "1"
2133 echo -n "/etc/passwd" > $testroot/content.expected
2134 cp $testroot/wt
/passwd.link
$testroot/content
2136 cmp -s $testroot/content.expected
$testroot/content
2138 if [ "$ret" != "0" ]; then
2139 diff -u $testroot/content.expected
$testroot/content
2140 test_done
"$testroot" "$ret"
2144 if [ -h $testroot/wt
/epsilon
/beta.link
]; then
2145 echo "epsilon/beta.link is a symlink"
2146 test_done
"$testroot" "1"
2150 echo "<<<<<<< merged change: commit $commit_id2" \
2151 > $testroot/content.expected
2152 echo "../gamma/delta" >> $testroot/content.expected
2153 echo "3-way merge base: commit $commit_id1" \
2154 >> $testroot/content.expected
2155 echo "../beta" >> $testroot/content.expected
2156 echo "=======" >> $testroot/content.expected
2157 echo "../gamma" >> $testroot/content.expected
2158 echo '>>>>>>>' >> $testroot/content.expected
2159 echo -n "" >> $testroot/content.expected
2161 cp $testroot/wt
/epsilon
/beta.link
$testroot/content
2162 cmp -s $testroot/content.expected
$testroot/content
2164 if [ "$ret" != "0" ]; then
2165 diff -u $testroot/content.expected
$testroot/content
2166 test_done
"$testroot" "$ret"
2170 if [ -h $testroot/wt
/nonexistent.link
]; then
2171 echo -n "nonexistent.link still exists on disk: " >&2
2172 readlink
$testroot/wt
/nonexistent.link
>&2
2173 test_done
"$testroot" "1"
2177 echo "<<<<<<< merged change: commit $commit_id2" \
2178 > $testroot/content.expected
2179 echo "(symlink was deleted)" >> $testroot/content.expected
2180 echo "=======" >> $testroot/content.expected
2181 echo "nonexistent2" >> $testroot/content.expected
2182 echo '>>>>>>>' >> $testroot/content.expected
2183 echo -n "" >> $testroot/content.expected
2185 cp $testroot/wt
/nonexistent.link
$testroot/content
2186 cmp -s $testroot/content.expected
$testroot/content
2188 if [ "$ret" != "0" ]; then
2189 diff -u $testroot/content.expected
$testroot/content
2190 test_done
"$testroot" "$ret"
2194 if [ -h $testroot/wt
/dotgotfoo.link
]; then
2195 echo "dotgotfoo.link is a symlink"
2196 test_done
"$testroot" "1"
2200 echo "<<<<<<< merged change: commit $commit_id2" \
2201 > $testroot/content.expected
2202 echo "this is regular file foo" >> $testroot/content.expected
2203 echo "=======" >> $testroot/content.expected
2204 echo -n ".got/bar" >> $testroot/content.expected
2205 echo '>>>>>>>' >> $testroot/content.expected
2206 echo -n "" >> $testroot/content.expected
2208 cp $testroot/wt
/dotgotfoo.link
$testroot/content
2209 cmp -s $testroot/content.expected
$testroot/content
2211 if [ "$ret" != "0" ]; then
2212 diff -u $testroot/content.expected
$testroot/content
2213 test_done
"$testroot" "$ret"
2217 if [ -h $testroot/wt
/dotgotbar.link
]; then
2218 echo "dotgotbar.link is a symlink"
2219 test_done
"$testroot" "1"
2222 echo "<<<<<<< merged change: commit $commit_id2" \
2223 > $testroot/content.expected
2224 echo -n ".got/bar" >> $testroot/content.expected
2225 echo "=======" >> $testroot/content.expected
2226 echo "this is regular file bar" >> $testroot/content.expected
2227 echo '>>>>>>>' >> $testroot/content.expected
2228 echo -n "" >> $testroot/content.expected
2230 cp $testroot/wt
/dotgotbar.link
$testroot/content
2231 cmp -s $testroot/content.expected
$testroot/content
2233 if [ "$ret" != "0" ]; then
2234 diff -u $testroot/content.expected
$testroot/content
2235 test_done
"$testroot" "$ret"
2239 if [ -h $testroot/wt
/new.link
]; then
2240 echo "new.link is a symlink"
2241 test_done
"$testroot" "1"
2245 echo "<<<<<<< merged change: commit $commit_id2" \
2246 > $testroot/content.expected
2247 echo "alpha" >> $testroot/content.expected
2248 echo "=======" >> $testroot/content.expected
2249 echo "beta" >> $testroot/content.expected
2250 echo '>>>>>>>' >> $testroot/content.expected
2251 echo -n "" >> $testroot/content.expected
2253 cp $testroot/wt
/new.link
$testroot/content
2254 cmp -s $testroot/content.expected
$testroot/content
2256 if [ "$ret" != "0" ]; then
2257 diff -u $testroot/content.expected
$testroot/content
2258 test_done
"$testroot" "$ret"
2262 echo "A dotgotfoo.link" > $testroot/stdout.expected
2263 echo "M new.link" >> $testroot/stdout.expected
2264 echo "D nonexistent.link" >> $testroot/stdout.expected
2265 (cd $testroot/wt
&& got status
> $testroot/stdout
)
2266 if [ "$ret" != "0" ]; then
2267 diff -u $testroot/stdout.expected
$testroot/stdout
2268 test_done
"$testroot" "$ret"
2272 test_done
"$testroot" "0"
2276 test_update_single_file
() {
2277 local testroot
=`test_init update_single_file 1`
2279 echo c1
> $testroot/repo
/c
2280 (cd $testroot/repo
&& git add .
)
2281 git_commit
$testroot/repo
-m "adding file c"
2282 local commit_id1
=`git_show_head $testroot/repo`
2284 echo a
> $testroot/repo
/a
2285 echo b
> $testroot/repo
/b
2286 echo c2
> $testroot/repo
/c
2287 (cd $testroot/repo
&& git add .
)
2288 git_commit
$testroot/repo
-m "add files a and b, change c"
2289 local commit_id2
=`git_show_head $testroot/repo`
2291 (cd $testroot/repo
&& git
rm -qf c
)
2292 git_commit
$testroot/repo
-m "remove file c"
2293 local commit_id3
=`git_show_head $testroot/repo`
2295 got checkout
-c $commit_id2 $testroot/repo
$testroot/wt
> /dev
/null
2297 if [ "$ret" != "0" ]; then
2298 test_done
"$testroot" "$ret"
2302 echo "U c" > $testroot/stdout.expected
2303 echo "Updated to refs/heads/master: $commit_id1" \
2304 >> $testroot/stdout.expected
2306 (cd $testroot/wt
&& got update
-c $commit_id1 c \
2309 cmp -s $testroot/stdout.expected
$testroot/stdout
2311 if [ "$ret" != "0" ]; then
2312 diff -u $testroot/stdout.expected
$testroot/stdout
2313 test_done
"$testroot" "$ret"
2317 echo c1
> $testroot/content.expected
2318 cat $testroot/wt
/c
> $testroot/content
2320 cmp -s $testroot/content.expected
$testroot/content
2322 if [ "$ret" != "0" ]; then
2323 diff -u $testroot/content.expected
$testroot/content
2324 test_done
"$testroot" "$ret"
2328 echo "U c" > $testroot/stdout.expected
2329 echo "Updated to refs/heads/master: $commit_id2" \
2330 >> $testroot/stdout.expected
2332 (cd $testroot/wt
&& got update
-c $commit_id2 c
> $testroot/stdout
)
2334 cmp -s $testroot/stdout.expected
$testroot/stdout
2336 if [ "$ret" != "0" ]; then
2337 diff -u $testroot/stdout.expected
$testroot/stdout
2338 test_done
"$testroot" "$ret"
2342 echo c2
> $testroot/content.expected
2343 cat $testroot/wt
/c
> $testroot/content
2345 cmp -s $testroot/content.expected
$testroot/content
2347 if [ "$ret" != "0" ]; then
2348 diff -u $testroot/content.expected
$testroot/content
2349 test_done
"$testroot" "$ret"
2353 echo "D c" > $testroot/stdout.expected
2354 echo "Updated to refs/heads/master: $commit_id3" \
2355 >> $testroot/stdout.expected
2357 (cd $testroot/wt
&& got update
-c $commit_id3 c \
2358 > $testroot/stdout
2> $testroot/stderr
)
2360 echo "got: /c: no such entry found in tree" > $testroot/stderr.expected
2361 cmp -s $testroot/stderr.expected
$testroot/stderr
2363 if [ "$ret" != "0" ]; then
2364 diff -u $testroot/stderr.expected
$testroot/stderr
2365 test_done
"$testroot" "$ret"
2369 echo -n > $testroot/stdout.expected
2370 cmp -s $testroot/stdout.expected
$testroot/stdout
2372 if [ "$ret" != "0" ]; then
2373 diff -u $testroot/stdout.expected
$testroot/stdout
2374 test_done
"$testroot" "$ret"
2378 echo "D c" > $testroot/stdout.expected
2379 echo "Updated to refs/heads/master: $commit_id3" \
2380 >> $testroot/stdout.expected
2382 (cd $testroot/wt
&& got update
-c $commit_id3 > $testroot/stdout
)
2383 cmp -s $testroot/stdout.expected
$testroot/stdout
2385 if [ "$ret" != "0" ]; then
2386 diff -u $testroot/stdout.expected
$testroot/stdout
2387 test_done
"$testroot" "$ret"
2391 if [ -e $testroot/wt
/c
]; then
2392 echo "removed file c still exists on disk" >&2
2393 test_done
"$testroot" "1"
2397 test_done
"$testroot" "0"
2401 test_update_file_skipped_due_to_conflict
() {
2402 local testroot
=`test_init update_file_skipped_due_to_conflict`
2403 local commit_id0
=`git_show_head $testroot/repo`
2404 blob_id0
=`get_blob_id $testroot/repo "" beta`
2406 echo "changed beta" > $testroot/repo
/beta
2407 git_commit
$testroot/repo
-m "changed beta"
2408 local commit_id1
=`git_show_head $testroot/repo`
2409 blob_id1
=`get_blob_id $testroot/repo "" beta`
2411 got checkout
$testroot/repo
$testroot/wt
> /dev
/null
2413 if [ "$ret" != "0" ]; then
2414 test_done
"$testroot" "$ret"
2418 blob_id
=`(cd $testroot/wt && got info beta | grep 'blob:' | \
2419 cut -d ':' -f 2 | tr -d ' ')`
2420 if [ "$blob_id" != "$blob_id1" ]; then
2421 echo "file beta has the wrong base blob ID" >&2
2422 test_done
"$testroot" "1"
2426 commit_id
=`(cd $testroot/wt && got info beta | \
2427 grep 'based on commit:' | cut -d ':' -f 2 | tr -d ' ')`
2428 if [ "$commit_id" != "$commit_id1" ]; then
2429 echo "file beta has the wrong base commit ID" >&2
2430 test_done
"$testroot" "1"
2434 echo "modified beta" > $testroot/wt
/beta
2436 (cd $testroot/wt
&& got update
-c $commit_id0 > $testroot/stdout
)
2438 echo "C beta" > $testroot/stdout.expected
2439 echo "Updated to refs/heads/master: $commit_id0" \
2440 >> $testroot/stdout.expected
2441 echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
2442 cmp -s $testroot/stdout.expected
$testroot/stdout
2444 if [ "$ret" != "0" ]; then
2445 diff -u $testroot/stdout.expected
$testroot/stdout
2446 test_done
"$testroot" "$ret"
2450 echo "<<<<<<< merged change: commit $commit_id0" \
2451 > $testroot/content.expected
2452 echo "beta" >> $testroot/content.expected
2453 echo "||||||| 3-way merge base: commit $commit_id1" \
2454 >> $testroot/content.expected
2455 echo "changed beta" >> $testroot/content.expected
2456 echo "=======" >> $testroot/content.expected
2457 echo "modified beta" >> $testroot/content.expected
2458 echo ">>>>>>>" >> $testroot/content.expected
2460 cat $testroot/wt
/beta
> $testroot/content
2462 cmp -s $testroot/content.expected
$testroot/content
2464 if [ "$ret" != "0" ]; then
2465 diff -u $testroot/content.expected
$testroot/content
2466 test_done
"$testroot" "$ret"
2470 blob_id
=`(cd $testroot/wt && got info beta | grep 'blob:' | \
2471 cut -d ':' -f 2 | tr -d ' ')`
2472 if [ "$blob_id" != "$blob_id0" ]; then
2473 echo "file beta has the wrong base blob ID" >&2
2474 test_done
"$testroot" "1"
2478 commit_id
=`(cd $testroot/wt && got info beta | \
2479 grep 'based on commit:' | cut -d ':' -f 2 | tr -d ' ')`
2480 if [ "$commit_id" != "$commit_id0" ]; then
2481 echo "file beta has the wrong base commit ID" >&2
2482 test_done
"$testroot" "1"
2486 # update to the latest commit again; this skips beta
2487 (cd $testroot/wt
&& got update
> $testroot/stdout
)
2488 echo "# beta" > $testroot/stdout.expected
2489 echo "Updated to refs/heads/master: $commit_id1" \
2490 >> $testroot/stdout.expected
2491 echo "Files not updated because of existing merge conflicts: 1" \
2492 >> $testroot/stdout.expected
2493 cmp -s $testroot/stdout.expected
$testroot/stdout
2495 if [ "$ret" != "0" ]; then
2496 diff -u $testroot/stdout.expected
$testroot/stdout
2497 test_done
"$testroot" "$ret"
2501 # blob ID of beta should not have changed
2502 blob_id
=`(cd $testroot/wt && got info beta | grep 'blob:' | \
2503 cut -d ':' -f 2 | tr -d ' ')`
2504 if [ "$blob_id" != "$blob_id0" ]; then
2505 echo "file beta has the wrong base blob ID" >&2
2506 test_done
"$testroot" "1"
2510 # commit ID of beta should not have changed; There was a bug
2511 # here where the commit ID had been changed even though the
2512 # file was not updated.
2513 commit_id
=`(cd $testroot/wt && got info beta | \
2514 grep 'based on commit:' | cut -d ':' -f 2 | tr -d ' ')`
2515 if [ "$commit_id" != "$commit_id0" ]; then
2516 echo "file beta has the wrong base commit ID: $commit_id" >&2
2517 test_done
"$testroot" "1"
2521 # beta is still conflicted and based on commit 0
2522 echo 'C beta' > $testroot/stdout.expected
2523 (cd $testroot/wt
&& got status
> $testroot/stdout
)
2524 cmp -s $testroot/stdout.expected
$testroot/stdout
2526 if [ "$ret" != "0" ]; then
2527 diff -u $testroot/stdout.expected
$testroot/stdout
2528 test_done
"$testroot" "$ret"
2532 # resolve the conflict via revert
2533 (cd $testroot/wt
&& got revert beta
>/dev
/null
)
2535 # beta now matches its base blob which is still from commit 0
2536 echo "beta" > $testroot/content.expected
2537 cat $testroot/wt
/beta
> $testroot/content
2538 cmp -s $testroot/content.expected
$testroot/content
2540 if [ "$ret" != "0" ]; then
2541 diff -u $testroot/content.expected
$testroot/content
2542 test_done
"$testroot" "$ret"
2546 # updating to the latest commit should now update beta
2547 (cd $testroot/wt
&& got update
> $testroot/stdout
)
2548 echo "U beta" > $testroot/stdout.expected
2549 echo "Updated to refs/heads/master: $commit_id1" \
2550 >> $testroot/stdout.expected
2551 cmp -s $testroot/stdout.expected
$testroot/stdout
2553 if [ "$ret" != "0" ]; then
2554 diff -u $testroot/stdout.expected
$testroot/stdout
2555 test_done
"$testroot" "$ret"
2559 blob_id
=`(cd $testroot/wt && got info beta | grep 'blob:' | \
2560 cut -d ':' -f 2 | tr -d ' ')`
2561 if [ "$blob_id" != "$blob_id1" ]; then
2562 echo "file beta has the wrong base blob ID" >&2
2563 test_done
"$testroot" "1"
2567 commit_id
=`(cd $testroot/wt && got info beta | \
2568 grep 'based on commit:' | cut -d ':' -f 2 | tr -d ' ')`
2569 if [ "$commit_id" != "$commit_id1" ]; then
2570 echo "file beta has the wrong base commit ID: $commit_id" >&2
2571 test_done
"$testroot" "1"
2575 echo "changed beta" > $testroot/content.expected
2576 cat $testroot/wt
/beta
> $testroot/content
2577 cmp -s $testroot/content.expected
$testroot/content
2579 if [ "$ret" != "0" ]; then
2580 diff -u $testroot/content.expected
$testroot/content
2582 test_done
"$testroot" "$ret"
2585 test_update_file_skipped_due_to_obstruction
() {
2586 local testroot
=`test_init update_file_skipped_due_to_obstruction`
2587 local commit_id0
=`git_show_head $testroot/repo`
2588 blob_id0
=`get_blob_id $testroot/repo "" beta`
2590 echo "changed beta" > $testroot/repo
/beta
2591 echo "new file" > $testroot/repo
/new
2592 (cd $testroot/repo
&& git add new
)
2593 git_commit
$testroot/repo
-m "changed beta"
2594 local commit_id1
=`git_show_head $testroot/repo`
2595 blob_id1
=`get_blob_id $testroot/repo "" beta`
2597 got checkout
-c $commit_id0 $testroot/repo
$testroot/wt
> /dev
/null
2599 if [ "$ret" != "0" ]; then
2600 test_done
"$testroot" "$ret"
2604 blob_id
=`(cd $testroot/wt && got info beta | grep 'blob:' | \
2605 cut -d ':' -f 2 | tr -d ' ')`
2606 if [ "$blob_id" != "$blob_id0" ]; then
2607 echo "file beta has the wrong base blob ID" >&2
2608 test_done
"$testroot" "1"
2612 commit_id
=`(cd $testroot/wt && got info beta | \
2613 grep 'based on commit:' | cut -d ':' -f 2 | tr -d ' ')`
2614 if [ "$commit_id" != "$commit_id0" ]; then
2615 echo "file beta has the wrong base commit ID" >&2
2616 test_done
"$testroot" "1"
2620 rm $testroot/wt
/beta
2621 mkdir
-p $testroot/wt
/beta
/psi
2622 mkdir
-p $testroot/wt
/new
2624 # update to the latest commit; this skips beta and the new file
2625 (cd $testroot/wt
&& got update
> $testroot/stdout
)
2627 if [ "$ret" != "0" ]; then
2628 echo "update failed unexpectedly" >&2
2629 test_done
"$testroot" "1"
2633 echo "~ beta" > $testroot/stdout.expected
2634 echo "~ new" >> $testroot/stdout.expected
2635 echo "Updated to refs/heads/master: $commit_id1" \
2636 >> $testroot/stdout.expected
2637 echo "File paths obstructed by a non-regular file: 2" \
2638 >> $testroot/stdout.expected
2639 cmp -s $testroot/stdout.expected
$testroot/stdout
2641 if [ "$ret" != "0" ]; then
2642 diff -u $testroot/stdout.expected
$testroot/stdout
2643 test_done
"$testroot" "$ret"
2647 blob_id
=`(cd $testroot/wt && got info beta | grep 'blob:' | \
2648 cut -d ':' -f 2 | tr -d ' ')`
2649 if [ "$blob_id" != "$blob_id0" ]; then
2650 echo "file beta has the wrong base blob ID" >&2
2651 test_done
"$testroot" "1"
2655 commit_id
=`(cd $testroot/wt && got info beta | \
2656 grep 'based on commit:' | cut -d ':' -f 2 | tr -d ' ')`
2657 if [ "$commit_id" != "$commit_id0" ]; then
2658 echo "file beta has the wrong base commit ID" >&2
2659 test_done
"$testroot" "1"
2663 # remove the directory which obstructs file beta
2664 rm -r $testroot/wt
/beta
2666 # updating to the latest commit should now update beta
2667 (cd $testroot/wt
&& got update
> $testroot/stdout
)
2668 echo "! beta" > $testroot/stdout.expected
2669 echo "~ new" >> $testroot/stdout.expected
2670 echo "Updated to refs/heads/master: $commit_id1" \
2671 >> $testroot/stdout.expected
2672 echo "File paths obstructed by a non-regular file: 1" \
2673 >> $testroot/stdout.expected
2674 cmp -s $testroot/stdout.expected
$testroot/stdout
2676 if [ "$ret" != "0" ]; then
2677 diff -u $testroot/stdout.expected
$testroot/stdout
2678 test_done
"$testroot" "$ret"
2682 blob_id
=`(cd $testroot/wt && got info beta | grep 'blob:' | \
2683 cut -d ':' -f 2 | tr -d ' ')`
2684 if [ "$blob_id" != "$blob_id1" ]; then
2685 echo "file beta has the wrong base blob ID" >&2
2686 test_done
"$testroot" "1"
2690 commit_id
=`(cd $testroot/wt && got info beta | \
2691 grep 'based on commit:' | cut -d ':' -f 2 | tr -d ' ')`
2692 if [ "$commit_id" != "$commit_id1" ]; then
2693 echo "file beta has the wrong base commit ID: $commit_id" >&2
2694 test_done
"$testroot" "1"
2698 echo "changed beta" > $testroot/content.expected
2699 cat $testroot/wt
/beta
> $testroot/content
2700 cmp -s $testroot/content.expected
$testroot/content
2702 if [ "$ret" != "0" ]; then
2703 diff -u $testroot/content.expected
$testroot/content
2705 test_done
"$testroot" "$ret"
2708 test_update_quiet
() {
2709 local testroot
=`test_init update_quiet`
2711 got checkout
$testroot/repo
$testroot/wt
> /dev
/null
2713 if [ "$ret" != "0" ]; then
2714 test_done
"$testroot" "$ret"
2718 echo "modified alpha" > $testroot/repo
/alpha
2719 git_commit
$testroot/repo
-m "modified alpha"
2721 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
2722 git_show_head
$testroot/repo
>> $testroot/stdout.expected
2723 echo >> $testroot/stdout.expected
2725 (cd $testroot/wt
&& got update
-q > $testroot/stdout
)
2727 cmp -s $testroot/stdout.expected
$testroot/stdout
2729 if [ "$ret" != "0" ]; then
2730 diff -u $testroot/stdout.expected
$testroot/stdout
2731 test_done
"$testroot" "$ret"
2735 echo "modified alpha" > $testroot/content.expected
2736 cat $testroot/wt
/alpha
> $testroot/content
2738 cmp -s $testroot/content.expected
$testroot/content
2740 if [ "$ret" != "0" ]; then
2741 diff -u $testroot/content.expected
$testroot/content
2743 test_done
"$testroot" "$ret"
2747 run_test test_update_basic
2748 run_test test_update_adds_file
2749 run_test test_update_deletes_file
2750 run_test test_update_deletes_dir
2751 run_test test_update_deletes_dir_with_path_prefix
2752 run_test test_update_deletes_dir_recursively
2753 run_test test_update_sibling_dirs_with_common_prefix
2754 run_test test_update_dir_with_dot_sibling
2755 run_test test_update_moves_files_upwards
2756 run_test test_update_moves_files_to_new_dir
2757 run_test test_update_creates_missing_parent
2758 run_test test_update_creates_missing_parent_with_subdir
2759 run_test test_update_file_in_subsubdir
2760 run_test test_update_merges_file_edits
2761 run_test test_update_keeps_xbit
2762 run_test test_update_clears_xbit
2763 run_test test_update_restores_missing_file
2764 run_test test_update_conflict_wt_add_vs_repo_add
2765 run_test test_update_conflict_wt_edit_vs_repo_rm
2766 run_test test_update_conflict_wt_rm_vs_repo_edit
2767 run_test test_update_conflict_wt_rm_vs_repo_rm
2768 run_test test_update_partial
2769 run_test test_update_partial_add
2770 run_test test_update_partial_rm
2771 run_test test_update_partial_dir
2772 run_test test_update_moved_branch_ref
2773 run_test test_update_to_another_branch
2774 run_test test_update_to_commit_on_wrong_branch
2775 run_test test_update_bumps_base_commit_id
2776 run_test test_update_tag
2777 run_test test_update_toggles_xbit
2778 run_test test_update_preserves_conflicted_file
2779 run_test test_update_modified_submodules
2780 run_test test_update_adds_submodule
2781 run_test test_update_conflict_wt_file_vs_repo_submodule
2782 run_test test_update_adds_symlink
2783 run_test test_update_deletes_symlink
2784 run_test test_update_symlink_conflicts
2785 run_test test_update_single_file
2786 run_test test_update_file_skipped_due_to_conflict
2787 run_test test_update_file_skipped_due_to_obstruction
2788 run_test test_update_quiet