do not skip ignored directories in 'got status' if they contain tracked files
[got-portable.git] / regress / cmdline / status.sh
blob8482b39abaec22fd45cad69589613c1baeb685ce
1 #!/bin/sh
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.
17 . ./common.sh
19 test_status_basic() {
20 local testroot=`test_init status_basic`
22 got checkout $testroot/repo $testroot/wt > /dev/null
23 ret="$?"
24 if [ "$ret" != "0" ]; then
25 test_done "$testroot" "$ret"
26 return 1
29 echo "modified alpha" > $testroot/wt/alpha
30 (cd $testroot/wt && got rm beta >/dev/null)
31 echo "unversioned file" > $testroot/wt/foo
32 rm $testroot/wt/epsilon/zeta
33 touch $testroot/wt/beta
34 echo "new file" > $testroot/wt/new
35 (cd $testroot/wt && got add new >/dev/null)
36 mkdir -m 0000 $testroot/wt/bar
38 echo 'M alpha' > $testroot/stdout.expected
39 echo 'D beta' >> $testroot/stdout.expected
40 echo '! epsilon/zeta' >> $testroot/stdout.expected
41 echo '? foo' >> $testroot/stdout.expected
42 echo 'A new' >> $testroot/stdout.expected
44 (cd $testroot/wt && got status > $testroot/stdout)
46 cmp -s $testroot/stdout.expected $testroot/stdout
47 ret="$?"
48 if [ "$ret" != "0" ]; then
49 diff -u $testroot/stdout.expected $testroot/stdout
51 chmod 700 $testroot/wt/bar
52 rmdir $testroot/wt/bar
53 test_done "$testroot" "$ret"
56 test_status_subdir_no_mods() {
57 local testroot=`test_init status_subdir_no_mods 1`
59 mkdir $testroot/repo/Basic/
60 mkdir $testroot/repo/Basic/Targets/
61 touch $testroot/repo/Basic/Targets/AArch64.cpp
62 touch $testroot/repo/Basic/Targets.cpp
63 touch $testroot/repo/Basic/Targets.h
64 (cd $testroot/repo && git add .)
65 git_commit $testroot/repo -m "add subdir with files"
67 got checkout $testroot/repo $testroot/wt > /dev/null
68 ret="$?"
69 if [ "$ret" != "0" ]; then
70 test_done "$testroot" "$ret"
71 return 1
74 touch $testroot/stdout.expected
76 # This used to erroneously print:
78 # ! Basic/Targets.cpp
79 # ? Basic/Targets.cpp
80 (cd $testroot/wt && got status > $testroot/stdout)
82 cmp -s $testroot/stdout.expected $testroot/stdout
83 ret="$?"
84 if [ "$ret" != "0" ]; then
85 diff -u $testroot/stdout.expected $testroot/stdout
87 test_done "$testroot" "$ret"
90 test_status_subdir_no_mods2() {
91 local testroot=`test_init status_subdir_no_mods2 1`
93 mkdir $testroot/repo/AST
94 touch $testroot/repo/AST/APValue.cpp
95 mkdir $testroot/repo/ASTMatchers
96 touch $testroot/repo/ASTMatchers/ASTMatchFinder.cpp
97 mkdir $testroot/repo/Frontend
98 touch $testroot/repo/Frontend/ASTConsumers.cpp
99 mkdir $testroot/repo/Frontend/Rewrite
100 touch $testroot/repo/Frontend/Rewrite/CMakeLists.txt
101 mkdir $testroot/repo/FrontendTool
102 touch $testroot/repo/FrontendTool/CMakeLists.txt
103 touch $testroot/repo/FrontendTool/ExecuteCompilerInvocation.cpp
104 (cd $testroot/repo && git add .)
105 git_commit $testroot/repo -m "add subdir with files"
107 got checkout $testroot/repo $testroot/wt > /dev/null
108 ret="$?"
109 if [ "$ret" != "0" ]; then
110 test_done "$testroot" "$ret"
111 return 1
114 touch $testroot/stdout.expected
116 # This used to erroneously print:
118 # ! AST/APValue.cpp
119 # ? AST/APValue.cpp
120 # ! Frontend/ASTConsumers.cpp
121 # ! Frontend/Rewrite/CMakeLists.txt
122 # ? Frontend/ASTConsumers.cpp
123 # ? Frontend/Rewrite/CMakeLists.txt
124 (cd $testroot/wt && got status > $testroot/stdout)
126 cmp -s $testroot/stdout.expected $testroot/stdout
127 ret="$?"
128 if [ "$ret" != "0" ]; then
129 diff -u $testroot/stdout.expected $testroot/stdout
131 test_done "$testroot" "$ret"
134 test_status_obstructed() {
135 local testroot=`test_init status_obstructed`
137 got checkout $testroot/repo $testroot/wt > /dev/null
138 ret="$?"
139 if [ "$ret" != "0" ]; then
140 test_done "$testroot" "$ret"
141 return 1
144 rm $testroot/wt/epsilon/zeta
145 mkdir $testroot/wt/epsilon/zeta
147 echo '~ epsilon/zeta' > $testroot/stdout.expected
149 (cd $testroot/wt && got status > $testroot/stdout)
151 cmp -s $testroot/stdout.expected $testroot/stdout
152 ret="$?"
153 if [ "$ret" != "0" ]; then
154 diff -u $testroot/stdout.expected $testroot/stdout
156 test_done "$testroot" "$ret"
159 test_status_shows_local_mods_after_update() {
160 local testroot=`test_init status_shows_local_mods_after_update 1`
162 echo "1" > $testroot/repo/numbers
163 echo "2" >> $testroot/repo/numbers
164 echo "3" >> $testroot/repo/numbers
165 echo "4" >> $testroot/repo/numbers
166 echo "5" >> $testroot/repo/numbers
167 echo "6" >> $testroot/repo/numbers
168 echo "7" >> $testroot/repo/numbers
169 echo "8" >> $testroot/repo/numbers
170 (cd $testroot/repo && git add numbers)
171 git_commit $testroot/repo -m "added numbers file"
173 got checkout $testroot/repo $testroot/wt > /dev/null
174 ret="$?"
175 if [ "$ret" != "0" ]; then
176 test_done "$testroot" "$ret"
177 return 1
180 sed -i '' -e 's/2/22/' $testroot/repo/numbers
181 git_commit $testroot/repo -m "modified line 2"
183 # modify line 7; both changes should merge cleanly
184 sed -i '' -e 's/7/77/' $testroot/wt/numbers
186 echo "G numbers" > $testroot/stdout.expected
187 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
188 git_show_head $testroot/repo >> $testroot/stdout.expected
189 echo >> $testroot/stdout.expected
191 (cd $testroot/wt && got update > $testroot/stdout)
193 cmp -s $testroot/stdout.expected $testroot/stdout
194 ret="$?"
195 if [ "$ret" != "0" ]; then
196 diff -u $testroot/stdout.expected $testroot/stdout
197 test_done "$testroot" "$ret"
198 return 1
201 echo 'M numbers' > $testroot/stdout.expected
203 (cd $testroot/wt && got status > $testroot/stdout)
205 cmp -s $testroot/stdout.expected $testroot/stdout
206 ret="$?"
207 if [ "$ret" != "0" ]; then
208 diff -u $testroot/stdout.expected $testroot/stdout
210 test_done "$testroot" "$ret"
213 test_status_unversioned_subdirs() {
214 local testroot=`test_init status_unversioned_subdirs 1`
216 mkdir $testroot/repo/cdfs/
217 touch $testroot/repo/cdfs/Makefile
218 mkdir $testroot/repo/common/
219 touch $testroot/repo/common/Makefile
220 mkdir $testroot/repo/iso/
221 touch $testroot/repo/iso/Makefile
222 mkdir $testroot/repo/ramdisk/
223 touch $testroot/repo/ramdisk/Makefile
224 touch $testroot/repo/ramdisk/list.local
225 mkdir $testroot/repo/ramdisk_cd/
226 touch $testroot/repo/ramdisk_cd/Makefile
227 touch $testroot/repo/ramdisk_cd/list.local
228 (cd $testroot/repo && git add .)
229 git_commit $testroot/repo -m "first commit"
231 got checkout $testroot/repo $testroot/wt > /dev/null
232 ret="$?"
233 if [ "$ret" != "0" ]; then
234 test_done "$testroot" "$ret"
235 return 1
238 mkdir $testroot/wt/cdfs/obj
239 mkdir $testroot/wt/ramdisk/obj
240 mkdir $testroot/wt/ramdisk_cd/obj
241 mkdir $testroot/wt/iso/obj
243 echo -n > $testroot/stdout.expected
245 # This used to erroneously print:
247 # ! ramdisk_cd/Makefile
248 # ! ramdisk_cd/list.local
249 # ? ramdisk_cd/Makefile
250 # ? ramdisk_cd/list.local
251 (cd $testroot/wt && got status > $testroot/stdout)
253 cmp -s $testroot/stdout.expected $testroot/stdout
254 ret="$?"
255 if [ "$ret" != "0" ]; then
256 diff -u $testroot/stdout.expected $testroot/stdout
258 test_done "$testroot" "$ret"
261 test_status_symlink() {
262 local testroot=`test_init status_symlink`
264 mkdir $testroot/repo/ramdisk/
265 touch $testroot/repo/ramdisk/Makefile
266 (cd $testroot/repo && ln -s alpha alpha.link)
267 (cd $testroot/repo && ln -s epsilon epsilon.link)
268 (cd $testroot/repo && ln -s nonexistent nonexistent.link)
269 (cd $testroot/repo && git add .)
270 git_commit $testroot/repo -m "first commit"
272 got checkout $testroot/repo $testroot/wt > /dev/null
273 ret="$?"
274 if [ "$ret" != "0" ]; then
275 test_done "$testroot" "$ret"
276 return 1
279 ln -s /usr/obj/distrib/i386/ramdisk $testroot/wt/ramdisk/obj
281 echo "? ramdisk/obj" > $testroot/stdout.expected
283 (cd $testroot/wt && got status > $testroot/stdout)
285 cmp -s $testroot/stdout.expected $testroot/stdout
286 ret="$?"
287 if [ "$ret" != "0" ]; then
288 diff -u $testroot/stdout.expected $testroot/stdout
289 test_done "$testroot" "$ret"
290 return 1
293 (cd $testroot/wt && ln -sf beta alpha.link)
294 (cd $testroot/wt && ln -sfT gamma epsilon.link)
296 (cd $testroot/wt && ln -s /etc/passwd passwd.link)
297 (cd $testroot/wt && ln -s ../beta epsilon/beta.link)
298 (cd $testroot/wt && got add passwd.link epsilon/beta.link > /dev/null)
300 (cd $testroot/wt && got rm nonexistent.link > /dev/null)
302 echo 'M alpha.link' > $testroot/stdout.expected
303 echo 'A epsilon/beta.link' >> $testroot/stdout.expected
304 echo 'M epsilon.link' >> $testroot/stdout.expected
305 echo 'D nonexistent.link' >> $testroot/stdout.expected
306 echo 'A passwd.link' >> $testroot/stdout.expected
307 echo "? ramdisk/obj" >> $testroot/stdout.expected
309 (cd $testroot/wt && got status > $testroot/stdout)
311 cmp -s $testroot/stdout.expected $testroot/stdout
312 ret="$?"
313 if [ "$ret" != "0" ]; then
314 diff -u $testroot/stdout.expected $testroot/stdout
316 test_done "$testroot" "$ret"
319 test_status_shows_no_mods_after_complete_merge() {
320 local testroot=`test_init status_shows_no_mods_after_complete_merge 1`
322 # make this file larger than the usual blob buffer size of 8192
323 echo -n > $testroot/repo/numbers
324 for i in `jot 16384`; do
325 echo "$i" >> $testroot/repo/numbers
326 done
328 (cd $testroot/repo && git add numbers)
329 git_commit $testroot/repo -m "added numbers file"
331 got checkout $testroot/repo $testroot/wt > /dev/null
332 ret="$?"
333 if [ "$ret" != "0" ]; then
334 test_done "$testroot" "$ret"
335 return 1
338 sed -i '' -e 's/2/22/' $testroot/repo/numbers
339 git_commit $testroot/repo -m "modified line 2"
341 sleep 1
342 # modify line 2 again; no local changes are left after merge
343 sed -i '' -e 's/2/22/' $testroot/wt/numbers
345 echo "G numbers" > $testroot/stdout.expected
346 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
347 git_show_head $testroot/repo >> $testroot/stdout.expected
348 echo >> $testroot/stdout.expected
350 (cd $testroot/wt && got update > $testroot/stdout)
352 cmp -s $testroot/stdout.expected $testroot/stdout
353 ret="$?"
354 if [ "$ret" != "0" ]; then
355 diff -u $testroot/stdout.expected $testroot/stdout
356 test_done "$testroot" "$ret"
357 return 1
360 echo -n > $testroot/stdout.expected
362 (cd $testroot/wt && got status > $testroot/stdout)
364 cmp -s $testroot/stdout.expected $testroot/stdout
365 ret="$?"
366 if [ "$ret" != "0" ]; then
367 diff -u $testroot/stdout.expected $testroot/stdout
369 test_done "$testroot" "$ret"
372 test_status_shows_conflict() {
373 local testroot=`test_init status_shows_conflict 1`
375 echo "1" > $testroot/repo/numbers
376 echo "2" >> $testroot/repo/numbers
377 echo "3" >> $testroot/repo/numbers
378 echo "4" >> $testroot/repo/numbers
379 echo "5" >> $testroot/repo/numbers
380 echo "6" >> $testroot/repo/numbers
381 echo "7" >> $testroot/repo/numbers
382 echo "8" >> $testroot/repo/numbers
383 (cd $testroot/repo && git add numbers)
384 git_commit $testroot/repo -m "added numbers file"
386 got checkout $testroot/repo $testroot/wt > /dev/null
387 ret="$?"
388 if [ "$ret" != "0" ]; then
389 test_done "$testroot" "$ret"
390 return 1
393 sed -i '' -e 's/2/22/' $testroot/repo/numbers
394 git_commit $testroot/repo -m "modified line 2"
396 # modify line 2 in a conflicting way
397 sed -i '' -e 's/2/77/' $testroot/wt/numbers
399 echo "C numbers" > $testroot/stdout.expected
400 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
401 git_show_head $testroot/repo >> $testroot/stdout.expected
402 echo >> $testroot/stdout.expected
403 echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
405 (cd $testroot/wt && got update > $testroot/stdout)
407 cmp -s $testroot/stdout.expected $testroot/stdout
408 ret="$?"
409 if [ "$ret" != "0" ]; then
410 diff -u $testroot/stdout.expected $testroot/stdout
411 test_done "$testroot" "$ret"
412 return 1
415 echo 'C numbers' > $testroot/stdout.expected
417 (cd $testroot/wt && got status > $testroot/stdout)
419 cmp -s $testroot/stdout.expected $testroot/stdout
420 ret="$?"
421 if [ "$ret" != "0" ]; then
422 diff -u $testroot/stdout.expected $testroot/stdout
424 test_done "$testroot" "$ret"
427 test_status_empty_dir() {
428 local testroot=`test_init status_empty_dir`
430 got checkout $testroot/repo $testroot/wt > /dev/null
431 ret="$?"
432 if [ "$ret" != "0" ]; then
433 test_done "$testroot" "$ret"
434 return 1
437 rm $testroot/wt/epsilon/zeta
439 echo '! epsilon/zeta' > $testroot/stdout.expected
441 (cd $testroot/wt && got status epsilon > $testroot/stdout)
443 cmp -s $testroot/stdout.expected $testroot/stdout
444 ret="$?"
445 if [ "$ret" != "0" ]; then
446 diff -u $testroot/stdout.expected $testroot/stdout
448 test_done "$testroot" "$ret"
451 test_status_empty_dir_unversioned_file() {
452 local testroot=`test_init status_empty_dir_unversioned_file`
454 got checkout $testroot/repo $testroot/wt > /dev/null
455 ret="$?"
456 if [ "$ret" != "0" ]; then
457 test_done "$testroot" "$ret"
458 return 1
461 rm $testroot/wt/epsilon/zeta
462 touch $testroot/wt/epsilon/unversioned
464 echo '? epsilon/unversioned' > $testroot/stdout.expected
465 echo '! epsilon/zeta' >> $testroot/stdout.expected
467 (cd $testroot/wt && got status epsilon > $testroot/stdout)
469 cmp -s $testroot/stdout.expected $testroot/stdout
470 ret="$?"
471 if [ "$ret" != "0" ]; then
472 diff -u $testroot/stdout.expected $testroot/stdout
474 test_done "$testroot" "$ret"
477 test_status_many_paths() {
478 local testroot=`test_init status_many_paths`
480 got checkout $testroot/repo $testroot/wt > /dev/null
481 ret="$?"
482 if [ "$ret" != "0" ]; then
483 test_done "$testroot" "$ret"
484 return 1
487 echo "modified alpha" > $testroot/wt/alpha
488 (cd $testroot/wt && got rm beta >/dev/null)
489 echo "unversioned file" > $testroot/wt/foo
490 rm $testroot/wt/epsilon/zeta
491 touch $testroot/wt/beta
492 echo "new file" > $testroot/wt/new
493 mkdir $testroot/wt/newdir
494 (cd $testroot/wt && got add new >/dev/null)
496 (cd $testroot/wt && got status alpha > $testroot/stdout.expected)
497 (cd $testroot/wt && got status beta >> $testroot/stdout.expected)
498 (cd $testroot/wt && got status epsilon >> $testroot/stdout.expected)
499 (cd $testroot/wt && got status foo >> $testroot/stdout.expected)
500 (cd $testroot/wt && got status new >> $testroot/stdout.expected)
501 (cd $testroot/wt && got status newdir >> $testroot/stdout.expected)
502 (cd $testroot/wt && got status . >> $testroot/stdout.expected)
504 (cd $testroot/wt && got status newdir alpha epsilon foo new beta . \
505 > $testroot/stdout)
507 cmp -s $testroot/stdout.expected $testroot/stdout
508 ret="$?"
509 if [ "$ret" != "0" ]; then
510 diff -u $testroot/stdout.expected $testroot/stdout
512 test_done "$testroot" "$ret"
515 test_status_cvsignore() {
516 local testroot=`test_init status_cvsignore`
518 got checkout $testroot/repo $testroot/wt > /dev/null
519 ret="$?"
520 if [ "$ret" != "0" ]; then
521 test_done "$testroot" "$ret"
522 return 1
525 echo "unversioned file" > $testroot/wt/foo
526 echo "unversioned file" > $testroot/wt/foop
527 echo "unversioned file" > $testroot/wt/epsilon/foo
528 echo "unversioned file" > $testroot/wt/epsilon/bar
529 echo "unversioned file" > $testroot/wt/epsilon/boo
530 echo "unversioned file" > $testroot/wt/epsilon/moo
531 mkdir -p $testroot/wt/epsilon/new/
532 echo "unversioned file" > $testroot/wt/epsilon/new/foo
533 echo "**/foo" > $testroot/wt/.cvsignore
534 echo "**/gamma" >> $testroot/wt/.cvsignore
535 echo "bar" > $testroot/wt/epsilon/.cvsignore
536 echo "moo" >> $testroot/wt/epsilon/.cvsignore
538 echo '? .cvsignore' > $testroot/stdout.expected
539 echo '? epsilon/.cvsignore' >> $testroot/stdout.expected
540 echo '? epsilon/boo' >> $testroot/stdout.expected
541 echo '? foop' >> $testroot/stdout.expected
542 (cd $testroot/wt && got status > $testroot/stdout)
544 cmp -s $testroot/stdout.expected $testroot/stdout
545 ret="$?"
546 if [ "$ret" != "0" ]; then
547 diff -u $testroot/stdout.expected $testroot/stdout
548 test_done "$testroot" "$ret"
549 return 1
552 echo '? epsilon/.cvsignore' > $testroot/stdout.expected
553 echo '? epsilon/boo' >> $testroot/stdout.expected
554 (cd $testroot/wt && got status epsilon > $testroot/stdout)
556 cmp -s $testroot/stdout.expected $testroot/stdout
557 ret="$?"
558 if [ "$ret" != "0" ]; then
559 diff -u $testroot/stdout.expected $testroot/stdout
560 test_done "$testroot" "$ret"
561 return 1
564 echo -n '' > $testroot/stdout.expected
565 (cd $testroot/wt && got status epsilon/new > $testroot/stdout)
567 cmp -s $testroot/stdout.expected $testroot/stdout
568 ret="$?"
569 if [ "$ret" != "0" ]; then
570 diff -u $testroot/stdout.expected $testroot/stdout
571 test_done "$testroot" "$ret"
572 return 1
575 echo '? .cvsignore' > $testroot/stdout.expected
576 echo '? epsilon/.cvsignore' >> $testroot/stdout.expected
577 echo '? epsilon/boo' >> $testroot/stdout.expected
578 echo '? foop' >> $testroot/stdout.expected
579 (cd $testroot/wt/gamma && got status > $testroot/stdout)
581 cmp -s $testroot/stdout.expected $testroot/stdout
582 ret="$?"
583 if [ "$ret" != "0" ]; then
584 diff -u $testroot/stdout.expected $testroot/stdout
585 test_done "$testroot" "$ret"
586 return 1
589 cat > $testroot/stdout.expected <<EOF
590 ? .cvsignore
591 ? epsilon/.cvsignore
592 ? epsilon/bar
593 ? epsilon/boo
594 ? epsilon/foo
595 ? epsilon/moo
596 ? epsilon/new/foo
597 ? foo
598 ? foop
600 (cd $testroot/wt && got status -I > $testroot/stdout)
601 ret="$?"
602 if [ "$ret" != "0" ]; then
603 echo "got status failed unexpectedly" >&2
604 test_done "$testroot" "1"
605 return 1
608 cmp -s $testroot/stdout.expected $testroot/stdout
609 ret="$?"
610 if [ "$ret" != "0" ]; then
611 diff -u $testroot/stdout.expected $testroot/stdout
613 test_done "$testroot" "$ret"
616 test_status_gitignore() {
617 local testroot=`test_init status_gitignore`
619 got checkout $testroot/repo $testroot/wt > /dev/null
620 ret="$?"
621 if [ "$ret" != "0" ]; then
622 test_done "$testroot" "$ret"
623 return 1
626 echo "unversioned file" > $testroot/wt/foo
627 echo "unversioned file" > $testroot/wt/foop
628 echo "unversioned file" > $testroot/wt/barp
629 echo "unversioned file" > $testroot/wt/epsilon/bar
630 echo "unversioned file" > $testroot/wt/epsilon/boo
631 echo "unversioned file" > $testroot/wt/epsilon/moo
632 mkdir -p $testroot/wt/a/b/c/
633 echo "unversioned file" > $testroot/wt/a/b/c/foo
634 echo "unversioned file" > $testroot/wt/a/b/c/zoo
635 echo "foo" > $testroot/wt/.gitignore
636 echo "bar*" >> $testroot/wt/.gitignore
637 echo "epsilon/**" >> $testroot/wt/.gitignore
638 echo "a/**/foo" >> $testroot/wt/.gitignore
639 echo "**/zoo" >> $testroot/wt/.gitignore
641 echo '? .gitignore' > $testroot/stdout.expected
642 echo '? foop' >> $testroot/stdout.expected
643 (cd $testroot/wt && got status > $testroot/stdout)
645 cmp -s $testroot/stdout.expected $testroot/stdout
646 ret="$?"
647 if [ "$ret" != "0" ]; then
648 diff -u $testroot/stdout.expected $testroot/stdout
649 test_done "$testroot" "$ret"
650 return 1
653 echo '? .gitignore' > $testroot/stdout.expected
654 echo '? foop' >> $testroot/stdout.expected
655 (cd $testroot/wt/gamma && got status > $testroot/stdout)
657 cmp -s $testroot/stdout.expected $testroot/stdout
658 ret="$?"
659 if [ "$ret" != "0" ]; then
660 diff -u $testroot/stdout.expected $testroot/stdout
661 test_done "$testroot" "$ret"
662 return 1
665 cat > $testroot/stdout.expected <<EOF
666 ? .gitignore
667 ? a/b/c/foo
668 ? a/b/c/zoo
669 ? barp
670 ? epsilon/bar
671 ? epsilon/boo
672 ? epsilon/moo
673 ? foo
674 ? foop
676 (cd $testroot/wt && got status -I > $testroot/stdout)
677 ret="$?"
678 if [ "$ret" != "0" ]; then
679 echo "got status failed unexpectedly" >&2
680 test_done "$testroot" "1"
681 return 1
684 cmp -s $testroot/stdout.expected $testroot/stdout
685 ret="$?"
686 if [ "$ret" != "0" ]; then
687 diff -u $testroot/stdout.expected $testroot/stdout
689 test_done "$testroot" "$ret"
692 test_status_status_code() {
693 local testroot=`test_init status_status_code`
695 got checkout $testroot/repo $testroot/wt > /dev/null
696 ret="$?"
697 if [ "$ret" != "0" ]; then
698 test_done "$testroot" "$ret"
699 return 1
702 echo "modified alpha" > $testroot/wt/alpha
703 (cd $testroot/wt && got rm beta >/dev/null)
704 echo "unversioned file" > $testroot/wt/foo
705 rm $testroot/wt/epsilon/zeta
706 touch $testroot/wt/beta
707 echo "new file" > $testroot/wt/new
708 (cd $testroot/wt && got add new >/dev/null)
710 (cd $testroot/wt && got status -s xDM \
711 > $testroot/stdout 2> $testroot/stderr)
712 ret="$?"
713 if [ "$ret" = "0" ]; then
714 echo "status succeeded unexpectedly" >&2
715 test_done "$testroot" "1"
716 return 1
719 echo "got: invalid status code 'x'" > $testroot/stderr.expected
720 cmp -s $testroot/stderr.expected $testroot/stderr
721 ret="$?"
722 if [ "$ret" != "0" ]; then
723 diff -u $testroot/stderr.expected $testroot/stderr
724 test_done "$testroot" "$ret"
725 return 1
728 echo 'M alpha' > $testroot/stdout.expected
729 (cd $testroot/wt && got status -s M > $testroot/stdout)
730 cmp -s $testroot/stdout.expected $testroot/stdout
731 ret="$?"
732 if [ "$ret" != "0" ]; then
733 diff -u $testroot/stdout.expected $testroot/stdout
734 test_done "$testroot" "$ret"
735 return 1
738 echo 'D beta' > $testroot/stdout.expected
739 (cd $testroot/wt && got status -s D > $testroot/stdout)
740 cmp -s $testroot/stdout.expected $testroot/stdout
741 ret="$?"
742 if [ "$ret" != "0" ]; then
743 diff -u $testroot/stdout.expected $testroot/stdout
744 test_done "$testroot" "$ret"
745 return 1
748 echo '! epsilon/zeta' > $testroot/stdout.expected
749 echo '? foo' >> $testroot/stdout.expected
750 (cd $testroot/wt && got status -s !\? > $testroot/stdout)
751 cmp -s $testroot/stdout.expected $testroot/stdout
752 ret="$?"
753 if [ "$ret" != "0" ]; then
754 diff -u $testroot/stdout.expected $testroot/stdout
755 test_done "$testroot" "$ret"
756 return 1
759 echo 'A new' > $testroot/stdout.expected
760 (cd $testroot/wt && got status -s A > $testroot/stdout)
761 cmp -s $testroot/stdout.expected $testroot/stdout
762 ret="$?"
763 if [ "$ret" != "0" ]; then
764 diff -u $testroot/stdout.expected $testroot/stdout
765 test_done "$testroot" "$ret"
766 return 1
769 (cd $testroot/wt && got stage new > $testroot/stdout)
771 echo ' A new' > $testroot/stdout.expected
772 (cd $testroot/wt && got status -s A > $testroot/stdout)
773 cmp -s $testroot/stdout.expected $testroot/stdout
774 ret="$?"
775 if [ "$ret" != "0" ]; then
776 diff -u $testroot/stdout.expected $testroot/stdout
777 test_done "$testroot" "$ret"
778 return 1
781 echo 'changed file new' > $testroot/wt/new
783 echo 'MA new' > $testroot/stdout.expected
784 (cd $testroot/wt && got status -s A > $testroot/stdout)
785 cmp -s $testroot/stdout.expected $testroot/stdout
786 ret="$?"
787 if [ "$ret" != "0" ]; then
788 diff -u $testroot/stdout.expected $testroot/stdout
789 test_done "$testroot" "$ret"
790 return 1
793 echo 'M alpha' > $testroot/stdout.expected
794 echo 'MA new' >> $testroot/stdout.expected
795 (cd $testroot/wt && got status -s M > $testroot/stdout)
796 cmp -s $testroot/stdout.expected $testroot/stdout
797 ret="$?"
798 if [ "$ret" != "0" ]; then
799 diff -u $testroot/stdout.expected $testroot/stdout
800 test_done "$testroot" "$ret"
801 return 1
804 test_done "$testroot" "$ret"
807 test_status_suppress() {
808 local testroot=`test_init status_suppress`
810 got checkout $testroot/repo $testroot/wt > /dev/null
811 ret="$?"
812 if [ "$ret" != "0" ]; then
813 test_done "$testroot" "$ret"
814 return 1
817 echo "modified alpha" > $testroot/wt/alpha
818 (cd $testroot/wt && got rm beta >/dev/null)
819 echo "unversioned file" > $testroot/wt/foo
820 rm $testroot/wt/epsilon/zeta
821 touch $testroot/wt/beta
822 echo "new file" > $testroot/wt/new
823 (cd $testroot/wt && got add new >/dev/null)
825 (cd $testroot/wt && got status -S A -s M \
826 > $testroot/stdout 2> $testroot/stderr)
827 ret="$?"
828 if [ "$ret" = "0" ]; then
829 echo "status succeeded unexpectedly" >&2
830 test_done "$testroot" "1"
831 return 1
834 echo "got: -s and -S options are mutually exclusive" \
835 > $testroot/stderr.expected
836 cmp -s $testroot/stderr.expected $testroot/stderr
837 ret="$?"
838 if [ "$ret" != "0" ]; then
839 diff -u $testroot/stderr.expected $testroot/stderr
840 test_done "$testroot" "$ret"
841 return 1
844 (cd $testroot/wt && got status -s A -S M \
845 > $testroot/stdout 2> $testroot/stderr)
846 ret="$?"
847 if [ "$ret" = "0" ]; then
848 echo "status succeeded unexpectedly" >&2
849 test_done "$testroot" "1"
850 return 1
853 echo "got: -S and -s options are mutually exclusive" \
854 > $testroot/stderr.expected
855 cmp -s $testroot/stderr.expected $testroot/stderr
856 ret="$?"
857 if [ "$ret" != "0" ]; then
858 diff -u $testroot/stderr.expected $testroot/stderr
859 test_done "$testroot" "$ret"
860 return 1
863 (cd $testroot/wt && got status -S xDM \
864 > $testroot/stdout 2> $testroot/stderr)
865 ret="$?"
866 if [ "$ret" = "0" ]; then
867 echo "status succeeded unexpectedly" >&2
868 test_done "$testroot" "1"
869 return 1
872 echo "got: invalid status code 'x'" > $testroot/stderr.expected
873 cmp -s $testroot/stderr.expected $testroot/stderr
874 ret="$?"
875 if [ "$ret" != "0" ]; then
876 diff -u $testroot/stderr.expected $testroot/stderr
877 test_done "$testroot" "$ret"
878 return 1
881 echo 'M alpha' > $testroot/stdout.expected
882 (cd $testroot/wt && got status -S D\?A! > $testroot/stdout)
883 cmp -s $testroot/stdout.expected $testroot/stdout
884 ret="$?"
885 if [ "$ret" != "0" ]; then
886 diff -u $testroot/stdout.expected $testroot/stdout
887 test_done "$testroot" "$ret"
888 return 1
891 echo 'D beta' > $testroot/stdout.expected
892 (cd $testroot/wt && got status -S M\?A! > $testroot/stdout)
893 cmp -s $testroot/stdout.expected $testroot/stdout
894 ret="$?"
895 if [ "$ret" != "0" ]; then
896 diff -u $testroot/stdout.expected $testroot/stdout
897 test_done "$testroot" "$ret"
898 return 1
901 echo '! epsilon/zeta' > $testroot/stdout.expected
902 echo '? foo' >> $testroot/stdout.expected
903 (cd $testroot/wt && got status -S MDA > $testroot/stdout)
904 cmp -s $testroot/stdout.expected $testroot/stdout
905 ret="$?"
906 if [ "$ret" != "0" ]; then
907 diff -u $testroot/stdout.expected $testroot/stdout
908 test_done "$testroot" "$ret"
909 return 1
912 echo 'A new' > $testroot/stdout.expected
913 (cd $testroot/wt && got status -S MD\?! > $testroot/stdout)
914 cmp -s $testroot/stdout.expected $testroot/stdout
915 ret="$?"
916 if [ "$ret" != "0" ]; then
917 diff -u $testroot/stdout.expected $testroot/stdout
918 test_done "$testroot" "$ret"
919 return 1
922 (cd $testroot/wt && got stage new > $testroot/stdout)
924 echo ' A new' > $testroot/stdout.expected
925 (cd $testroot/wt && got status -S MD\?! > $testroot/stdout)
926 cmp -s $testroot/stdout.expected $testroot/stdout
927 ret="$?"
928 if [ "$ret" != "0" ]; then
929 diff -u $testroot/stdout.expected $testroot/stdout
930 test_done "$testroot" "$ret"
931 return 1
934 echo 'changed file new' > $testroot/wt/new
936 echo 'M alpha' > $testroot/stdout.expected
937 echo 'MA new' >> $testroot/stdout.expected
938 (cd $testroot/wt && got status -S D\?! > $testroot/stdout)
939 cmp -s $testroot/stdout.expected $testroot/stdout
940 ret="$?"
941 if [ "$ret" != "0" ]; then
942 diff -u $testroot/stdout.expected $testroot/stdout
943 test_done "$testroot" "$ret"
944 return 1
947 echo 'M alpha' > $testroot/stdout.expected
948 (cd $testroot/wt && got status -S AD\?! > $testroot/stdout)
949 cmp -s $testroot/stdout.expected $testroot/stdout
950 ret="$?"
951 if [ "$ret" != "0" ]; then
952 diff -u $testroot/stdout.expected $testroot/stdout
953 test_done "$testroot" "$ret"
954 return 1
957 rm $testroot/stdout.expected
958 touch $testroot/stdout.expected
960 (cd $testroot/wt && got status -S MD\?! > $testroot/stdout)
961 cmp -s $testroot/stdout.expected $testroot/stdout
962 ret="$?"
963 if [ "$ret" != "0" ]; then
964 diff -u $testroot/stdout.expected $testroot/stdout
965 test_done "$testroot" "$ret"
966 return 1
969 test_done "$testroot" "$ret"
972 test_status_empty_file() {
973 local testroot=`test_init status_empty_file`
975 got checkout $testroot/repo $testroot/wt > /dev/null
976 ret="$?"
977 if [ "$ret" != "0" ]; then
978 test_done "$testroot" "$ret"
979 return 1
982 echo -n "" > $testroot/wt/empty
983 (cd $testroot/wt && got add empty >/dev/null)
985 echo 'A empty' > $testroot/stdout.expected
987 (cd $testroot/wt && got status > $testroot/stdout)
989 cmp -s $testroot/stdout.expected $testroot/stdout
990 ret="$?"
991 if [ "$ret" != "0" ]; then
992 diff -u $testroot/stdout.expected $testroot/stdout
993 test_done "$testroot" "$ret"
994 return 1
997 (cd $testroot/wt && got commit -m "empty file" >/dev/null)
999 (cd $testroot/wt && got status > $testroot/stdout)
1001 echo -n > $testroot/stdout.expected
1002 cmp -s $testroot/stdout.expected $testroot/stdout
1003 ret="$?"
1004 if [ "$ret" != "0" ]; then
1005 diff -u $testroot/stdout.expected $testroot/stdout
1006 test_done "$testroot" "$ret"
1007 return 1
1010 # update the timestamp; this used to make the file show up as:
1011 # M empty
1012 # which should not happen
1013 touch $testroot/wt/empty
1015 (cd $testroot/wt && got status > $testroot/stdout)
1017 echo -n > $testroot/stdout.expected
1018 cmp -s $testroot/stdout.expected $testroot/stdout
1019 ret="$?"
1020 if [ "$ret" != "0" ]; then
1021 diff -u $testroot/stdout.expected $testroot/stdout
1023 test_done "$testroot" "$ret"
1026 test_parseargs "$@"
1027 run_test test_status_basic
1028 run_test test_status_subdir_no_mods
1029 run_test test_status_subdir_no_mods2
1030 run_test test_status_obstructed
1031 run_test test_status_shows_local_mods_after_update
1032 run_test test_status_unversioned_subdirs
1033 run_test test_status_symlink
1034 run_test test_status_shows_no_mods_after_complete_merge
1035 run_test test_status_shows_conflict
1036 run_test test_status_empty_dir
1037 run_test test_status_empty_dir_unversioned_file
1038 run_test test_status_many_paths
1039 run_test test_status_cvsignore
1040 run_test test_status_gitignore
1041 run_test test_status_status_code
1042 run_test test_status_suppress
1043 run_test test_status_empty_file