3 # Copyright (c) 2019 Stefan Sperling <stsp@openbsd.org>
5 # Permission to use, copy, modify, and distribute this software for any
6 # purpose with or without fee is hereby granted, provided that the above
7 # copyright notice and this permission notice appear in all copies.
9 # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 test_checkout_basic() {
20 local testroot=`test_init checkout_basic`
22 echo "A $testroot/wt/alpha" > $testroot/stdout.expected
23 echo "A $testroot/wt/beta" >> $testroot/stdout.expected
24 echo "A $testroot/wt/epsilon/zeta" >> $testroot/stdout.expected
25 echo "A $testroot/wt/gamma/delta" >> $testroot/stdout.expected
26 echo "Now shut up and hack" >> $testroot/stdout.expected
28 got checkout $testroot/repo $testroot/wt > $testroot/stdout
30 if [ "$ret" != "0" ]; then
31 test_done "$testroot" "$ret"
35 cmp -s $testroot/stdout.expected $testroot/stdout
37 if [ "$ret" != "0" ]; then
38 diff -u $testroot/stdout.expected $testroot/stdout
39 test_done "$testroot" "$ret"
43 echo "alpha" > $testroot/content.expected
44 echo "beta" >> $testroot/content.expected
45 echo "zeta" >> $testroot/content.expected
46 echo "delta" >> $testroot/content.expected
47 cat $testroot/wt/alpha $testroot/wt/beta $testroot/wt/epsilon/zeta \
48 $testroot/wt/gamma/delta > $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_checkout_dir_exists() {
59 local testroot=`test_init checkout_dir_exists`
61 echo "A $testroot/wt/alpha" > $testroot/stdout.expected
62 echo "A $testroot/wt/beta" >> $testroot/stdout.expected
63 echo "A $testroot/wt/epsilon/zeta" >> $testroot/stdout.expected
64 echo "A $testroot/wt/gamma/delta" >> $testroot/stdout.expected
65 echo "Now shut up and hack" >> $testroot/stdout.expected
69 got checkout $testroot/repo $testroot/wt > $testroot/stdout
71 if [ "$ret" != "0" ]; then
72 test_done "$testroot" "$ret"
76 cmp -s $testroot/stdout.expected $testroot/stdout
78 if [ "$ret" != "0" ]; then
79 diff -u $testroot/stdout.expected $testroot/stdout
80 test_done "$testroot" "$ret"
84 echo "alpha" > $testroot/content.expected
85 echo "beta" >> $testroot/content.expected
86 echo "zeta" >> $testroot/content.expected
87 echo "delta" >> $testroot/content.expected
88 cat $testroot/wt/alpha $testroot/wt/beta $testroot/wt/epsilon/zeta \
89 $testroot/wt/gamma/delta > $testroot/content
91 cmp -s $testroot/content.expected $testroot/content
93 if [ "$ret" != "0" ]; then
94 diff -u $testroot/content.expected $testroot/content
96 test_done "$testroot" "$ret"
99 test_checkout_dir_not_empty() {
100 local testroot=`test_init checkout_dir_not_empty`
102 echo "A $testroot/wt/alpha" > $testroot/stdout.expected
103 echo "A $testroot/wt/beta" >> $testroot/stdout.expected
104 echo "A $testroot/wt/epsilon/zeta" >> $testroot/stdout.expected
105 echo "A $testroot/wt/gamma/delta" >> $testroot/stdout.expected
106 echo "Now shut up and hack" >> $testroot/stdout.expected
109 touch $testroot/wt/foo
111 got checkout $testroot/repo $testroot/wt > $testroot/stdout \
114 if [ "$ret" = "0" ]; then
115 echo "checkout succeeded unexpectedly" >&2
116 test_done "$testroot" "1"
120 echo "got: $testroot/wt: directory exists and is not empty" \
121 > $testroot/stderr.expected
122 cmp -s $testroot/stderr.expected $testroot/stderr
124 if [ "$ret" != "0" ]; then
125 diff -u $testroot/stderr.expected $testroot/stderr
126 test_done "$testroot" "$ret"
130 echo -n > $testroot/stdout.expected
131 cmp -s $testroot/stdout.expected $testroot/stdout
133 if [ "$ret" != "0" ]; then
134 diff -u $testroot/stdout.expected $testroot/stdout
136 test_done "$testroot" "$ret"
140 test_checkout_sets_xbit() {
141 local testroot=`test_init checkout_sets_xbit 1`
143 touch $testroot/repo/xfile
144 chmod +x $testroot/repo/xfile
145 (cd $testroot/repo && git add .)
146 git_commit $testroot/repo -m "adding executable file"
148 echo "A $testroot/wt/xfile" > $testroot/stdout.expected
149 echo "Now shut up and hack" >> $testroot/stdout.expected
151 got checkout $testroot/repo $testroot/wt > $testroot/stdout
153 if [ "$ret" != "0" ]; then
154 test_done "$testroot" "$ret"
158 cmp -s $testroot/stdout.expected $testroot/stdout
160 if [ "$ret" != "0" ]; then
161 diff -u $testroot/stdout.expected $testroot/stdout
162 test_done "$testroot" "$ret"
166 ls -l $testroot/wt/xfile | grep -q '^-rwx'
168 if [ "$ret" != "0" ]; then
169 echo "file is not executable" >&2
170 ls -l $testroot/wt/xfile >&2
172 test_done "$testroot" "$ret"
175 test_checkout_commit_from_wrong_branch() {
176 local testroot=`test_init checkout_commit_from_wrong_branch`
178 (cd $testroot/repo && git checkout -q -b newbranch)
179 echo "modified alpha on new branch" > $testroot/repo/alpha
180 git_commit $testroot/repo -m "modified alpha on new branch"
182 local head_rev=`git_show_head $testroot/repo`
183 got checkout -b master -c $head_rev $testroot/repo $testroot/wt \
184 > $testroot/stdout 2> $testroot/stderr
186 if [ "$ret" = "0" ]; then
187 test_done "$testroot" "1"
191 echo -n "" > $testroot/stdout.expected
192 cmp -s $testroot/stdout.expected $testroot/stdout
194 if [ "$ret" != "0" ]; then
195 diff -u $testroot/stdout.expected $testroot/stdout
196 test_done "$testroot" "$ret"
200 echo -n "got: target commit is not contained in branch 'master'; " \
201 > $testroot/stderr.expected
202 echo -n "the branch to use must be specified with -b; if necessary " \
203 >> $testroot/stderr.expected
204 echo -n "a new branch can be created for this commit with "\
205 >> $testroot/stderr.expected
206 echo "'got branch -c $head_rev BRANCH_NAME'" \
207 >> $testroot/stderr.expected
208 cmp -s $testroot/stderr.expected $testroot/stderr
210 if [ "$ret" != "0" ]; then
211 diff -u $testroot/stderr.expected $testroot/stderr
212 test_done "$testroot" "$ret"
216 test_done "$testroot" "$ret"
219 test_checkout_tag() {
220 local testroot=`test_init checkout_tag`
223 (cd $testroot/repo && git tag -a -m "test" $tag)
225 echo "A $testroot/wt/alpha" > $testroot/stdout.expected
226 echo "A $testroot/wt/beta" >> $testroot/stdout.expected
227 echo "A $testroot/wt/epsilon/zeta" >> $testroot/stdout.expected
228 echo "A $testroot/wt/gamma/delta" >> $testroot/stdout.expected
229 echo "Now shut up and hack" >> $testroot/stdout.expected
231 got checkout -c $tag $testroot/repo $testroot/wt > $testroot/stdout
233 if [ "$ret" != "0" ]; then
234 test_done "$testroot" "$ret"
238 cmp -s $testroot/stdout.expected $testroot/stdout
240 if [ "$ret" != "0" ]; then
241 diff -u $testroot/stdout.expected $testroot/stdout
242 test_done "$testroot" "$ret"
246 echo "alpha" > $testroot/content.expected
247 echo "beta" >> $testroot/content.expected
248 echo "zeta" >> $testroot/content.expected
249 echo "delta" >> $testroot/content.expected
250 cat $testroot/wt/alpha $testroot/wt/beta $testroot/wt/epsilon/zeta \
251 $testroot/wt/gamma/delta > $testroot/content
253 cmp -s $testroot/content.expected $testroot/content
255 if [ "$ret" != "0" ]; then
256 diff -u $testroot/content.expected $testroot/content
258 test_done "$testroot" "$ret"
261 test_checkout_ignores_submodules() {
262 local testroot=`test_init checkout_ignores_submodules`
264 make_single_file_repo $testroot/repo2 foo
266 (cd $testroot/repo && git submodule -q add ../repo2)
267 (cd $testroot/repo && git commit -q -m 'adding submodule')
269 echo "A $testroot/wt/.gitmodules" > $testroot/stdout.expected
270 echo "A $testroot/wt/alpha" >> $testroot/stdout.expected
271 echo "A $testroot/wt/beta" >> $testroot/stdout.expected
272 echo "A $testroot/wt/epsilon/zeta" >> $testroot/stdout.expected
273 echo "A $testroot/wt/gamma/delta" >> $testroot/stdout.expected
274 echo "Now shut up and hack" >> $testroot/stdout.expected
276 got checkout $testroot/repo $testroot/wt > $testroot/stdout
278 if [ "$ret" != "0" ]; then
279 test_done "$testroot" "$ret"
283 cmp -s $testroot/stdout.expected $testroot/stdout
285 if [ "$ret" != "0" ]; then
286 diff -u $testroot/stdout.expected $testroot/stdout
287 test_done "$testroot" "$ret"
291 echo "alpha" > $testroot/content.expected
292 echo "beta" >> $testroot/content.expected
293 echo "zeta" >> $testroot/content.expected
294 echo "delta" >> $testroot/content.expected
295 cat $testroot/wt/alpha $testroot/wt/beta $testroot/wt/epsilon/zeta \
296 $testroot/wt/gamma/delta > $testroot/content
298 cmp -s $testroot/content.expected $testroot/content
300 if [ "$ret" != "0" ]; then
301 diff -u $testroot/content.expected $testroot/content
303 test_done "$testroot" "$ret"
306 test_checkout_read_only() {
307 local testroot=`test_init checkout_read_only`
309 # Make the repostiory read-only
310 chmod -R a-w $testroot/repo
312 echo "A $testroot/wt/alpha" > $testroot/stdout.expected
313 echo "A $testroot/wt/beta" >> $testroot/stdout.expected
314 echo "A $testroot/wt/epsilon/zeta" >> $testroot/stdout.expected
315 echo "A $testroot/wt/gamma/delta" >> $testroot/stdout.expected
316 echo "Now shut up and hack" >> $testroot/stdout.expected
318 got checkout $testroot/repo $testroot/wt \
319 > $testroot/stdout 2> $testroot/stderr
321 if [ "$ret" != "0" ]; then
322 test_done "$testroot" "$ret"
326 cmp -s $testroot/stdout.expected $testroot/stdout
328 if [ "$ret" != "0" ]; then
329 diff -u $testroot/stdout.expected $testroot/stdout
330 test_done "$testroot" "$ret"
334 echo -n "got: warning: could not create a reference " \
335 > $testroot/stderr.expected
336 echo -n "to the work tree's base commit; the commit could " \
337 >> $testroot/stderr.expected
338 echo -n "be garbage-collected by Git or 'gotadmin cleanup'; " \
339 >> $testroot/stderr.expected
340 echo -n "making the repository " >> $testroot/stderr.expected
341 echo "writable and running 'got update' will prevent this" \
342 >> $testroot/stderr.expected
343 cmp -s $testroot/stderr.expected $testroot/stderr
345 if [ "$ret" != "0" ]; then
346 diff -u $testroot/stderr.expected $testroot/stderr
347 test_done "$testroot" "$ret"
351 echo "alpha" > $testroot/content.expected
352 echo "beta" >> $testroot/content.expected
353 echo "zeta" >> $testroot/content.expected
354 echo "delta" >> $testroot/content.expected
355 cat $testroot/wt/alpha $testroot/wt/beta $testroot/wt/epsilon/zeta \
356 $testroot/wt/gamma/delta > $testroot/content
358 cmp -s $testroot/content.expected $testroot/content
360 if [ "$ret" != "0" ]; then
361 diff -u $testroot/content.expected $testroot/content
363 chmod -R u+w $testroot/repo # make repo cleanup work
364 test_done "$testroot" "$ret"
367 test_checkout_into_nonempty_dir() {
368 local testroot=`test_init checkout_into_nonempty_dir`
370 mkdir -p $testroot/wt
371 make_test_tree $testroot/wt
373 got checkout $testroot/repo $testroot/wt > $testroot/stdout \
376 if [ "$ret" = "0" ]; then
377 echo "checkout succeeded unexpectedly" >&2
378 test_done "$testroot" "1"
382 echo -n > $testroot/stdout.expected
383 cmp -s $testroot/stdout.expected $testroot/stdout
385 if [ "$ret" != "0" ]; then
386 diff -u $testroot/stdout.expected $testroot/stdout
387 test_done "$testroot" "$ret"
391 echo "got: $testroot/wt: directory exists and is not empty" \
392 > $testroot/stderr.expected
393 cmp -s $testroot/stderr.expected $testroot/stderr
395 if [ "$ret" != "0" ]; then
396 diff -u $testroot/stderr.expected $testroot/stderr
397 test_done "$testroot" "$ret"
401 echo "? $testroot/wt/alpha" > $testroot/stdout.expected
402 echo "? $testroot/wt/beta" >> $testroot/stdout.expected
403 echo "? $testroot/wt/epsilon/zeta" >> $testroot/stdout.expected
404 echo "? $testroot/wt/gamma/delta" >> $testroot/stdout.expected
405 echo "Now shut up and hack" >> $testroot/stdout.expected
407 got checkout -E $testroot/repo $testroot/wt > $testroot/stdout
409 if [ "$ret" != "0" ]; then
410 test_done "$testroot" "$ret"
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 echo "E $testroot/wt/alpha" > $testroot/stdout.expected
423 echo "E $testroot/wt/beta" >> $testroot/stdout.expected
424 echo "E $testroot/wt/epsilon/zeta" >> $testroot/stdout.expected
425 echo "E $testroot/wt/gamma/delta" >> $testroot/stdout.expected
426 echo "Now shut up and hack" >> $testroot/stdout.expected
428 got checkout -E $testroot/repo $testroot/wt > $testroot/stdout
430 if [ "$ret" != "0" ]; then
431 test_done "$testroot" "$ret"
435 cmp -s $testroot/stdout.expected $testroot/stdout
437 if [ "$ret" != "0" ]; then
438 diff -u $testroot/stdout.expected $testroot/stdout
439 test_done "$testroot" "$ret"
443 echo "alpha" > $testroot/content.expected
444 echo "beta" >> $testroot/content.expected
445 echo "zeta" >> $testroot/content.expected
446 echo "delta" >> $testroot/content.expected
447 cat $testroot/wt/alpha $testroot/wt/beta $testroot/wt/epsilon/zeta \
448 $testroot/wt/gamma/delta > $testroot/content
450 cmp -s $testroot/content.expected $testroot/content
452 if [ "$ret" != "0" ]; then
453 diff -u $testroot/content.expected $testroot/content
454 test_done "$testroot" "$ret"
458 echo "modified alpha" > $testroot/wt/alpha
460 echo "E $testroot/wt/alpha" > $testroot/stdout.expected
461 echo "E $testroot/wt/beta" >> $testroot/stdout.expected
462 echo "E $testroot/wt/epsilon/zeta" >> $testroot/stdout.expected
463 echo "E $testroot/wt/gamma/delta" >> $testroot/stdout.expected
464 echo "Now shut up and hack" >> $testroot/stdout.expected
466 got checkout -E $testroot/repo $testroot/wt > $testroot/stdout
468 if [ "$ret" != "0" ]; then
469 test_done "$testroot" "$ret"
473 cmp -s $testroot/stdout.expected $testroot/stdout
475 if [ "$ret" != "0" ]; then
476 diff -u $testroot/stdout.expected $testroot/stdout
477 test_done "$testroot" "$ret"
481 echo "modified alpha" > $testroot/content.expected
482 echo "beta" >> $testroot/content.expected
483 echo "zeta" >> $testroot/content.expected
484 echo "delta" >> $testroot/content.expected
485 cat $testroot/wt/alpha $testroot/wt/beta $testroot/wt/epsilon/zeta \
486 $testroot/wt/gamma/delta > $testroot/content
488 cmp -s $testroot/content.expected $testroot/content
490 if [ "$ret" != "0" ]; then
491 diff -u $testroot/content.expected $testroot/content
492 test_done "$testroot" "$ret"
496 echo 'M alpha' > $testroot/stdout.expected
497 (cd $testroot/wt && got status > $testroot/stdout)
499 cmp -s $testroot/stdout.expected $testroot/stdout
501 if [ "$ret" != "0" ]; then
502 diff -u $testroot/stdout.expected $testroot/stdout
504 test_done "$testroot" "$ret"
507 test_checkout_symlink() {
508 local testroot=`test_init checkout_symlink`
510 (cd $testroot/repo && ln -s alpha alpha.link)
511 (cd $testroot/repo && ln -s epsilon epsilon.link)
512 (cd $testroot/repo && ln -s /etc/passwd passwd.link)
513 (cd $testroot/repo && ln -s passwd.link passwd2.link)
514 (cd $testroot/repo && ln -s ../beta epsilon/beta.link)
515 (cd $testroot/repo && ln -s nonexistent nonexistent.link)
516 (cd $testroot/repo && ln -s .got/foo dotgotfoo.link)
517 (cd $testroot/repo && git add .)
518 git_commit $testroot/repo -m "add symlinks"
520 got checkout $testroot/repo $testroot/wt > $testroot/stdout
522 if [ "$ret" != "0" ]; then
523 echo "got checkout failed unexpectedly" >&2
524 test_done "$testroot" "$ret"
528 echo "A $testroot/wt/alpha" > $testroot/stdout.expected
529 echo "A $testroot/wt/alpha.link" >> $testroot/stdout.expected
530 echo "A $testroot/wt/beta" >> $testroot/stdout.expected
531 echo "A $testroot/wt/dotgotfoo.link" >> $testroot/stdout.expected
532 echo "A $testroot/wt/epsilon/beta.link" >> $testroot/stdout.expected
533 echo "A $testroot/wt/epsilon/zeta" >> $testroot/stdout.expected
534 echo "A $testroot/wt/epsilon.link" >> $testroot/stdout.expected
535 echo "A $testroot/wt/gamma/delta" >> $testroot/stdout.expected
536 echo "A $testroot/wt/nonexistent.link" >> $testroot/stdout.expected
537 echo "A $testroot/wt/passwd.link" >> $testroot/stdout.expected
538 echo "A $testroot/wt/passwd2.link" >> $testroot/stdout.expected
539 echo "Now shut up and hack" >> $testroot/stdout.expected
541 cmp -s $testroot/stdout.expected $testroot/stdout
543 if [ "$ret" != "0" ]; then
544 diff -u $testroot/stdout.expected $testroot/stdout
545 test_done "$testroot" "$ret"
549 if ! [ -h $testroot/wt/alpha.link ]; then
550 echo "alpha.link is not a symlink"
551 test_done "$testroot" "1"
555 readlink $testroot/wt/alpha.link > $testroot/stdout
556 echo "alpha" > $testroot/stdout.expected
557 cmp -s $testroot/stdout.expected $testroot/stdout
559 if [ "$ret" != "0" ]; then
560 diff -u $testroot/stdout.expected $testroot/stdout
561 test_done "$testroot" "$ret"
565 if ! [ -h $testroot/wt/epsilon.link ]; then
566 echo "epsilon.link is not a symlink"
567 test_done "$testroot" "1"
571 readlink $testroot/wt/epsilon.link > $testroot/stdout
572 echo "epsilon" > $testroot/stdout.expected
573 cmp -s $testroot/stdout.expected $testroot/stdout
575 if [ "$ret" != "0" ]; then
576 diff -u $testroot/stdout.expected $testroot/stdout
577 test_done "$testroot" "$ret"
581 if [ -h $testroot/wt/passwd.link ]; then
582 echo -n "passwd.link symlink points outside of work tree: " >&2
583 readlink $testroot/wt/passwd.link >&2
584 test_done "$testroot" "1"
588 echo -n "/etc/passwd" > $testroot/content.expected
589 cp $testroot/wt/passwd.link $testroot/content
591 cmp -s $testroot/content.expected $testroot/content
593 if [ "$ret" != "0" ]; then
594 diff -u $testroot/content.expected $testroot/content
595 test_done "$testroot" "$ret"
599 if ! [ -h $testroot/wt/passwd2.link ]; then
600 echo "passwd2.link is not a symlink"
601 test_done "$testroot" "1"
605 readlink $testroot/wt/passwd2.link > $testroot/stdout
606 echo "passwd.link" > $testroot/stdout.expected
607 cmp -s $testroot/stdout.expected $testroot/stdout
609 if [ "$ret" != "0" ]; then
610 diff -u $testroot/stdout.expected $testroot/stdout
611 test_done "$testroot" "$ret"
615 readlink $testroot/wt/epsilon/beta.link > $testroot/stdout
616 echo "../beta" > $testroot/stdout.expected
617 cmp -s $testroot/stdout.expected $testroot/stdout
619 if [ "$ret" != "0" ]; then
620 diff -u $testroot/stdout.expected $testroot/stdout
621 test_done "$testroot" "$ret"
625 readlink $testroot/wt/nonexistent.link > $testroot/stdout
626 echo "nonexistent" > $testroot/stdout.expected
627 cmp -s $testroot/stdout.expected $testroot/stdout
629 if [ "$ret" != "0" ]; then
630 diff -u $testroot/stdout.expected $testroot/stdout
631 test_done "$testroot" "$ret"
635 if [ -h $testroot/wt/dotgotfoo.link ]; then
636 echo -n "dotgotfoo.link symlink points into .got dir: " >&2
637 readlink $testroot/wt/dotgotfoo.link >&2
638 test_done "$testroot" "1"
642 echo -n ".got/foo" > $testroot/content.expected
643 cp $testroot/wt/dotgotfoo.link $testroot/content
645 cmp -s $testroot/content.expected $testroot/content
647 if [ "$ret" != "0" ]; then
648 diff -u $testroot/content.expected $testroot/content
650 test_done "$testroot" "$ret"
653 test_checkout_symlink_relative_wtpath() {
654 local testroot=`test_init checkout_symlink_with_wtpath`
656 (cd $testroot/repo && ln -s alpha alpha.link)
657 (cd $testroot/repo && ln -s epsilon epsilon.link)
658 (cd $testroot/repo && ln -s /etc/passwd passwd.link)
659 (cd $testroot/repo && ln -s ../beta epsilon/beta.link)
660 (cd $testroot/repo && ln -s nonexistent nonexistent.link)
661 (cd $testroot/repo && ln -s .got/foo dotgotfoo.link)
662 (cd $testroot/repo && git add .)
663 git_commit $testroot/repo -m "add symlinks"
665 (cd $testroot && got checkout $testroot/repo wt > /dev/null)
667 if [ "$ret" != "0" ]; then
668 test_done "$testroot" "$ret"
672 if ! [ -h $testroot/wt/alpha.link ]; then
673 echo "alpha.link is not a symlink"
674 test_done "$testroot" "1"
678 readlink $testroot/wt/alpha.link > $testroot/stdout
679 echo "alpha" > $testroot/stdout.expected
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 if ! [ -h $testroot/wt/epsilon.link ]; then
689 echo "epsilon.link is not a symlink"
690 test_done "$testroot" "1"
694 readlink $testroot/wt/epsilon.link > $testroot/stdout
695 echo "epsilon" > $testroot/stdout.expected
696 cmp -s $testroot/stdout.expected $testroot/stdout
698 if [ "$ret" != "0" ]; then
699 diff -u $testroot/stdout.expected $testroot/stdout
700 test_done "$testroot" "$ret"
704 if [ -h $testroot/wt/passwd.link ]; then
705 echo -n "passwd.link symlink points outside of work tree: " >&2
706 readlink $testroot/wt/passwd.link >&2
707 test_done "$testroot" "1"
711 echo -n "/etc/passwd" > $testroot/content.expected
712 cp $testroot/wt/passwd.link $testroot/content
714 cmp -s $testroot/content.expected $testroot/content
716 if [ "$ret" != "0" ]; then
717 diff -u $testroot/content.expected $testroot/content
718 test_done "$testroot" "$ret"
722 readlink $testroot/wt/epsilon/beta.link > $testroot/stdout
723 echo "../beta" > $testroot/stdout.expected
724 cmp -s $testroot/stdout.expected $testroot/stdout
726 if [ "$ret" != "0" ]; then
727 diff -u $testroot/stdout.expected $testroot/stdout
728 test_done "$testroot" "$ret"
732 readlink $testroot/wt/nonexistent.link > $testroot/stdout
733 echo "nonexistent" > $testroot/stdout.expected
734 cmp -s $testroot/stdout.expected $testroot/stdout
736 if [ "$ret" != "0" ]; then
737 diff -u $testroot/stdout.expected $testroot/stdout
738 test_done "$testroot" "$ret"
742 if [ -h $testroot/wt/dotgotfoo.link ]; then
743 echo -n "dotgotfoo.link symlink points into .got dir: " >&2
744 readlink $testroot/wt/dotgotfoo.link >&2
745 test_done "$testroot" "1"
749 echo -n ".got/foo" > $testroot/content.expected
750 cp $testroot/wt/dotgotfoo.link $testroot/content
752 cmp -s $testroot/content.expected $testroot/content
754 if [ "$ret" != "0" ]; then
755 diff -u $testroot/content.expected $testroot/content
757 test_done "$testroot" "$ret"
760 test_checkout_repo_with_unknown_extension() {
761 local testroot=`test_init checkout_repo_with_unknown_extension`
763 (cd $testroot/repo &&
764 git config --add extensions.badExtension true)
765 (cd $testroot/repo &&
766 git config --add extensions.otherBadExtension 0)
768 echo "got: badExtension: unsupported repository format extension" \
769 > $testroot/stderr.expected
770 got checkout $testroot/repo $testroot/wt \
771 > $testroot/stdout 2> $testroot/stderr
774 if [ "$ret" = "0" ]; then
775 echo "got checkout command succeeded unexpectedly" >&2
776 test_done "$testroot" "1"
780 cmp -s $testroot/stderr.expected $testroot/stderr
782 if [ "$ret" != "0" ]; then
783 diff -u $testroot/stderr.expected $testroot/stderr
785 test_done "$testroot" "$ret"
789 run_test test_checkout_basic
790 run_test test_checkout_dir_exists
791 run_test test_checkout_dir_not_empty
792 run_test test_checkout_sets_xbit
793 run_test test_checkout_commit_from_wrong_branch
794 run_test test_checkout_tag
795 run_test test_checkout_ignores_submodules
796 run_test test_checkout_read_only
797 run_test test_checkout_into_nonempty_dir
798 run_test test_checkout_symlink
799 run_test test_checkout_symlink_relative_wtpath
800 run_test test_checkout_repo_with_unknown_extension