3 test_description
='test untracked cache'
5 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
=main
6 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
10 # On some filesystems (e.g. FreeBSD's ext2 and ufs) directory mtime
11 # is updated lazily after contents in the directory changes, which
12 # forces the untracked cache code to take the slow path. A test
13 # that wants to make sure that the fast path works correctly should
14 # call this helper to make mtime of the containing directory in sync
15 # with the reality before checking the fast path behaviour.
17 # See <20160803174522.5571-1-pclouds@gmail.com> if you want to know
20 GIT_FORCE_UNTRACKED_CACHE
=true
21 export GIT_FORCE_UNTRACKED_CACHE
24 find .
-type d
-exec ls -ld {} + >/dev
/null
32 git status
--porcelain >..
/status.actual
&&
33 test_must_be_empty ..
/status.actual
36 # Ignore_Untracked_Cache, abbreviated to 3 letters because then people can
37 # compare commands side-by-side, e.g.
38 # iuc status --porcelain >expect &&
39 # git status --porcelain >actual &&
40 # test_cmp expect actual
42 git ls-files
-s >..
/current-index-entries
43 git ls-files
-t |
sed -ne s
/^S.
//p
>..
/current-sparse-entries
45 GIT_INDEX_FILE
=.git
/tmp_index
47 git update-index
--index-info <..
/current-index-entries
48 git update-index
--skip-worktree $
(cat ..
/current-sparse-entries
)
50 git
-c core.untrackedCache
=false
"$@"
53 rm ..
/current-index-entries
60 get_relevant_traces
() {
61 # From the GIT_TRACE2_PERF data of the form
62 # $TIME $FILE:$LINE | d0 | main | data | r1 | ? | ? | read_directo | $RELEVANT_STAT
63 # extract the $RELEVANT_STAT fields. We don't care about region_enter
64 # or region_leave, or stats for things outside read_directory.
67 grep data.
*read_directo
$INPUT_FILE |
74 test_lazy_prereq UNTRACKED_CACHE
'
75 { git update-index --test-untracked-cache; ret=$?; } &&
79 if ! test_have_prereq UNTRACKED_CACHE
; then
80 skip_all
='This system does not support untracked cache'
84 test_expect_success
'core.untrackedCache is unset' '
85 test_must_fail git config --get core.untrackedCache
88 test_expect_success
'setup' '
89 git init --template= worktree &&
91 mkdir done dtwo dthree &&
92 touch one two three done/one dtwo/two dthree/three &&
93 test-tool chmtime =-300 one two three done/one dtwo/two dthree/three &&
94 test-tool chmtime =-300 done dtwo dthree &&
95 test-tool chmtime =-300 . &&
96 git add one two done/one &&
98 : >.git/info/exclude &&
99 git update-index --untracked-cache &&
100 test_oid_cache <<-EOF
101 root sha1:e6fcc8f2ee31bae321d66afd183fcb7237afae6e
102 root sha256:b90c672088c015b9c83876e919da311bad4cd39639fb139f988af6a11493b974
104 exclude sha1:13263c0978fb9fad16b2d580fb800b6d811c3ff0
105 exclude sha256:fe4aaa1bbbbce4cb8f73426748a14c5ad6026b26f90505a0bf2494b165a5b76c
107 done sha1:1946f0437f90c5005533cbe1736a6451ca301714
108 done sha256:7f079501d79f665b3acc50f5e0e9e94509084d5032ac20113a37dd5029b757cc
112 test_expect_success
'untracked cache is empty' '
113 test-tool dump-untracked-cache >../actual &&
114 cat >../expect-empty <<EOF &&
115 info/exclude $ZERO_OID
116 core.excludesfile $ZERO_OID
117 exclude_per_dir .gitignore
120 test_cmp ../expect-empty ../actual
123 cat >..
/status.expect
<<EOF &&
132 cat >..
/dump.expect
<<EOF &&
133 info/exclude $EMPTY_BLOB
134 core.excludesfile $ZERO_OID
135 exclude_per_dir .gitignore
137 / $ZERO_OID recurse valid
141 /done/ $ZERO_OID recurse valid
142 /dthree/ $ZERO_OID recurse check_only valid
144 /dtwo/ $ZERO_OID recurse check_only valid
148 test_expect_success
'status first time (empty cache)' '
149 : >../trace.output &&
150 GIT_TRACE2_PERF="$TRASH_DIRECTORY/trace.output" \
151 git status --porcelain >../actual &&
152 iuc status --porcelain >../status.iuc &&
153 test_cmp ../status.expect ../status.iuc &&
154 test_cmp ../status.expect ../actual &&
155 get_relevant_traces ../trace.output ../trace.relevant &&
156 cat >../trace.expect <<EOF &&
159 ....gitignore-invalidation:1
160 ....directory-invalidation:0
163 test_cmp ../trace.expect ../trace.relevant
166 test_expect_success
'untracked cache after first status' '
167 test-tool dump-untracked-cache >../actual &&
168 test_cmp ../dump.expect ../actual
171 test_expect_success
'status second time (fully populated cache)' '
172 : >../trace.output &&
173 GIT_TRACE2_PERF="$TRASH_DIRECTORY/trace.output" \
174 git status --porcelain >../actual &&
175 iuc status --porcelain >../status.iuc &&
176 test_cmp ../status.expect ../status.iuc &&
177 test_cmp ../status.expect ../actual &&
178 get_relevant_traces ../trace.output ../trace.relevant &&
179 cat >../trace.expect <<EOF &&
182 ....gitignore-invalidation:0
183 ....directory-invalidation:0
186 test_cmp ../trace.expect ../trace.relevant
189 test_expect_success
'untracked cache after second status' '
190 test-tool dump-untracked-cache >../actual &&
191 test_cmp ../dump.expect ../actual
194 cat >..
/status_uall.expect
<<EOF &&
203 # Bypassing the untracked cache here is not desirable from an
204 # end-user perspective, but is expected in the current design.
205 # The untracked cache data stored for a -unormal run cannot be
206 # correctly used in a -uall run - it would yield incorrect output.
207 test_expect_success
'untracked cache is bypassed with -uall' '
208 : >../trace.output &&
209 GIT_TRACE2_PERF="$TRASH_DIRECTORY/trace.output" \
210 git status -uall --porcelain >../actual &&
211 iuc status -uall --porcelain >../status.iuc &&
212 test_cmp ../status_uall.expect ../status.iuc &&
213 test_cmp ../status_uall.expect ../actual &&
214 get_relevant_traces ../trace.output ../trace.relevant &&
215 cat >../trace.expect <<EOF &&
218 test_cmp ../trace.expect ../trace.relevant
221 test_expect_success
'untracked cache remains after bypass' '
222 test-tool dump-untracked-cache >../actual &&
223 test_cmp ../dump.expect ../actual
226 test_expect_success
'if -uall is configured, untracked cache gets populated by default' '
227 test_config status.showuntrackedfiles all &&
228 : >../trace.output &&
229 GIT_TRACE2_PERF="$TRASH_DIRECTORY/trace.output" \
230 git status --porcelain >../actual &&
231 iuc status --porcelain >../status.iuc &&
232 test_cmp ../status_uall.expect ../status.iuc &&
233 test_cmp ../status_uall.expect ../actual &&
234 get_relevant_traces ../trace.output ../trace.relevant &&
235 cat >../trace.expect <<EOF &&
238 ....gitignore-invalidation:1
239 ....directory-invalidation:0
242 test_cmp ../trace.expect ../trace.relevant
245 cat >..
/dump_uall.expect
<<EOF &&
246 info/exclude $EMPTY_BLOB
247 core.excludesfile $ZERO_OID
248 exclude_per_dir .gitignore
250 / $ZERO_OID recurse valid
252 /done/ $ZERO_OID recurse valid
253 /dthree/ $ZERO_OID recurse valid
255 /dtwo/ $ZERO_OID recurse valid
259 test_expect_success
'if -uall was configured, untracked cache is populated' '
260 test-tool dump-untracked-cache >../actual &&
261 test_cmp ../dump_uall.expect ../actual
264 test_expect_success
'if -uall is configured, untracked cache is used by default' '
265 test_config status.showuntrackedfiles all &&
266 : >../trace.output &&
267 GIT_TRACE2_PERF="$TRASH_DIRECTORY/trace.output" \
268 git status --porcelain >../actual &&
269 iuc status --porcelain >../status.iuc &&
270 test_cmp ../status_uall.expect ../status.iuc &&
271 test_cmp ../status_uall.expect ../actual &&
272 get_relevant_traces ../trace.output ../trace.relevant &&
273 cat >../trace.expect <<EOF &&
276 ....gitignore-invalidation:0
277 ....directory-invalidation:0
280 test_cmp ../trace.expect ../trace.relevant
283 # Bypassing the untracked cache here is not desirable from an
284 # end-user perspective, but is expected in the current design.
285 # The untracked cache data stored for a -all run cannot be
286 # correctly used in a -unormal run - it would yield incorrect
288 test_expect_success
'if -uall is configured, untracked cache is bypassed with -unormal' '
289 test_config status.showuntrackedfiles all &&
290 : >../trace.output &&
291 GIT_TRACE2_PERF="$TRASH_DIRECTORY/trace.output" \
292 git status -unormal --porcelain >../actual &&
293 iuc status -unormal --porcelain >../status.iuc &&
294 test_cmp ../status.expect ../status.iuc &&
295 test_cmp ../status.expect ../actual &&
296 get_relevant_traces ../trace.output ../trace.relevant &&
297 cat >../trace.expect <<EOF &&
300 test_cmp ../trace.expect ../trace.relevant
303 test_expect_success
'repopulate untracked cache for -unormal' '
304 git status --porcelain
307 test_expect_success
'modify in root directory, one dir invalidation' '
309 test-tool chmtime =-240 four &&
310 : >../trace.output &&
311 GIT_TRACE2_PERF="$TRASH_DIRECTORY/trace.output" \
312 git status --porcelain >../actual &&
313 iuc status --porcelain >../status.iuc &&
314 cat >../status.expect <<EOF &&
323 test_cmp ../status.expect ../status.iuc &&
324 test_cmp ../status.expect ../actual &&
325 get_relevant_traces ../trace.output ../trace.relevant &&
326 cat >../trace.expect <<EOF &&
329 ....gitignore-invalidation:0
330 ....directory-invalidation:1
333 test_cmp ../trace.expect ../trace.relevant
337 test_expect_success
'verify untracked cache dump' '
338 test-tool dump-untracked-cache >../actual &&
339 cat >../expect <<EOF &&
340 info/exclude $EMPTY_BLOB
341 core.excludesfile $ZERO_OID
342 exclude_per_dir .gitignore
344 / $ZERO_OID recurse valid
349 /done/ $ZERO_OID recurse valid
350 /dthree/ $ZERO_OID recurse check_only valid
352 /dtwo/ $ZERO_OID recurse check_only valid
355 test_cmp ../expect ../actual
358 test_expect_success
'new .gitignore invalidates recursively' '
359 echo four >.gitignore &&
360 : >../trace.output &&
361 GIT_TRACE2_PERF="$TRASH_DIRECTORY/trace.output" \
362 git status --porcelain >../actual &&
363 iuc status --porcelain >../status.iuc &&
364 cat >../status.expect <<EOF &&
373 test_cmp ../status.expect ../status.iuc &&
374 test_cmp ../status.expect ../actual &&
375 get_relevant_traces ../trace.output ../trace.relevant &&
376 cat >../trace.expect <<EOF &&
379 ....gitignore-invalidation:1
380 ....directory-invalidation:1
383 test_cmp ../trace.expect ../trace.relevant
387 test_expect_success
'verify untracked cache dump' '
388 test-tool dump-untracked-cache >../actual &&
389 cat >../expect <<EOF &&
390 info/exclude $EMPTY_BLOB
391 core.excludesfile $ZERO_OID
392 exclude_per_dir .gitignore
394 / $(test_oid root) recurse valid
399 /done/ $ZERO_OID recurse valid
400 /dthree/ $ZERO_OID recurse check_only valid
402 /dtwo/ $ZERO_OID recurse check_only valid
405 test_cmp ../expect ../actual
408 test_expect_success
'new info/exclude invalidates everything' '
409 echo three >>.git/info/exclude &&
410 : >../trace.output &&
411 GIT_TRACE2_PERF="$TRASH_DIRECTORY/trace.output" \
412 git status --porcelain >../actual &&
413 iuc status --porcelain >../status.iuc &&
414 cat >../status.expect <<EOF &&
421 test_cmp ../status.expect ../status.iuc &&
422 test_cmp ../status.expect ../actual &&
423 get_relevant_traces ../trace.output ../trace.relevant &&
424 cat >../trace.expect <<EOF &&
427 ....gitignore-invalidation:1
428 ....directory-invalidation:0
431 test_cmp ../trace.expect ../trace.relevant
434 test_expect_success
'verify untracked cache dump' '
435 test-tool dump-untracked-cache >../actual &&
436 cat >../expect <<EOF &&
437 info/exclude $(test_oid exclude)
438 core.excludesfile $ZERO_OID
439 exclude_per_dir .gitignore
441 / $(test_oid root) recurse valid
444 /done/ $ZERO_OID recurse valid
445 /dthree/ $ZERO_OID recurse check_only valid
446 /dtwo/ $ZERO_OID recurse check_only valid
449 test_cmp ../expect ../actual
452 test_expect_success
'move two from tracked to untracked' '
453 git rm --cached two &&
454 test-tool dump-untracked-cache >../actual &&
455 cat >../expect <<EOF &&
456 info/exclude $(test_oid exclude)
457 core.excludesfile $ZERO_OID
458 exclude_per_dir .gitignore
460 / $(test_oid root) recurse
461 /done/ $ZERO_OID recurse valid
462 /dthree/ $ZERO_OID recurse check_only valid
463 /dtwo/ $ZERO_OID recurse check_only valid
466 test_cmp ../expect ../actual
469 test_expect_success
'status after the move' '
470 : >../trace.output &&
471 GIT_TRACE2_PERF="$TRASH_DIRECTORY/trace.output" \
472 git status --porcelain >../actual &&
473 iuc status --porcelain >../status.iuc &&
474 cat >../status.expect <<EOF &&
481 test_cmp ../status.expect ../status.iuc &&
482 test_cmp ../status.expect ../actual &&
483 get_relevant_traces ../trace.output ../trace.relevant &&
484 cat >../trace.expect <<EOF &&
487 ....gitignore-invalidation:0
488 ....directory-invalidation:0
491 test_cmp ../trace.expect ../trace.relevant
494 test_expect_success
'verify untracked cache dump' '
495 test-tool dump-untracked-cache >../actual &&
496 cat >../expect <<EOF &&
497 info/exclude $(test_oid exclude)
498 core.excludesfile $ZERO_OID
499 exclude_per_dir .gitignore
501 / $(test_oid root) recurse valid
505 /done/ $ZERO_OID recurse valid
506 /dthree/ $ZERO_OID recurse check_only valid
507 /dtwo/ $ZERO_OID recurse check_only valid
510 test_cmp ../expect ../actual
513 test_expect_success
'move two from untracked to tracked' '
515 test-tool dump-untracked-cache >../actual &&
516 cat >../expect <<EOF &&
517 info/exclude $(test_oid exclude)
518 core.excludesfile $ZERO_OID
519 exclude_per_dir .gitignore
521 / $(test_oid root) recurse
522 /done/ $ZERO_OID recurse valid
523 /dthree/ $ZERO_OID recurse check_only valid
524 /dtwo/ $ZERO_OID recurse check_only valid
527 test_cmp ../expect ../actual
530 test_expect_success
'status after the move' '
531 : >../trace.output &&
532 GIT_TRACE2_PERF="$TRASH_DIRECTORY/trace.output" \
533 git status --porcelain >../actual &&
534 iuc status --porcelain >../status.iuc &&
535 cat >../status.expect <<EOF &&
542 test_cmp ../status.expect ../status.iuc &&
543 test_cmp ../status.expect ../actual &&
544 get_relevant_traces ../trace.output ../trace.relevant &&
545 cat >../trace.expect <<EOF &&
548 ....gitignore-invalidation:0
549 ....directory-invalidation:0
552 test_cmp ../trace.expect ../trace.relevant
555 test_expect_success
'verify untracked cache dump' '
556 test-tool dump-untracked-cache >../actual &&
557 cat >../expect <<EOF &&
558 info/exclude $(test_oid exclude)
559 core.excludesfile $ZERO_OID
560 exclude_per_dir .gitignore
562 / $(test_oid root) recurse valid
565 /done/ $ZERO_OID recurse valid
566 /dthree/ $ZERO_OID recurse check_only valid
567 /dtwo/ $ZERO_OID recurse check_only valid
570 test_cmp ../expect ../actual
573 test_expect_success
'set up for sparse checkout testing' '
574 echo two >done/.gitignore &&
575 echo three >>done/.gitignore &&
576 echo two >done/two &&
577 git add -f done/two done/.gitignore &&
578 git commit -m "first commit"
581 test_expect_success
'status after commit' '
582 : >../trace.output &&
583 GIT_TRACE2_PERF="$TRASH_DIRECTORY/trace.output" \
584 git status --porcelain >../actual &&
585 iuc status --porcelain >../status.iuc &&
586 cat >../status.expect <<EOF &&
590 test_cmp ../status.expect ../status.iuc &&
591 test_cmp ../status.expect ../actual &&
592 get_relevant_traces ../trace.output ../trace.relevant &&
593 cat >../trace.expect <<EOF &&
596 ....gitignore-invalidation:0
597 ....directory-invalidation:0
600 test_cmp ../trace.expect ../trace.relevant
603 test_expect_success
'untracked cache correct after commit' '
604 test-tool dump-untracked-cache >../actual &&
605 cat >../expect <<EOF &&
606 info/exclude $(test_oid exclude)
607 core.excludesfile $ZERO_OID
608 exclude_per_dir .gitignore
610 / $(test_oid root) recurse valid
613 /done/ $ZERO_OID recurse valid
614 /dthree/ $ZERO_OID recurse check_only valid
615 /dtwo/ $ZERO_OID recurse check_only valid
618 test_cmp ../expect ../actual
621 test_expect_success
'set up sparse checkout' '
622 echo "done/[a-z]*" >.git/info/sparse-checkout &&
623 test_config core.sparsecheckout true &&
625 git update-index --force-untracked-cache &&
626 git status --porcelain >/dev/null && # prime the cache
627 test_path_is_missing done/.gitignore &&
628 test_path_is_file done/one
631 test_expect_success
'create/modify files, some of which are gitignored' '
632 echo two bis >done/two &&
633 echo three >done/three && # three is gitignored
634 echo four >done/four && # four is gitignored at a higher level
635 echo five >done/five && # five is not gitignored
636 test-tool chmtime =-180 done/two done/three done/four done/five done &&
637 # we need to ensure that the root dir is touched (in the past);
638 test-tool chmtime =-180 . &&
642 test_expect_success
'test sparse status with untracked cache' '
643 : >../trace.output &&
644 GIT_TRACE2_PERF="$TRASH_DIRECTORY/trace.output" \
645 git status --porcelain >../status.actual &&
646 iuc status --porcelain >../status.iuc &&
647 cat >../status.expect <<EOF &&
653 test_cmp ../status.expect ../status.iuc &&
654 test_cmp ../status.expect ../status.actual &&
655 get_relevant_traces ../trace.output ../trace.relevant &&
656 cat >../trace.expect <<EOF &&
659 ....gitignore-invalidation:1
660 ....directory-invalidation:2
663 test_cmp ../trace.expect ../trace.relevant
666 test_expect_success
'untracked cache correct after status' '
667 test-tool dump-untracked-cache >../actual &&
668 cat >../expect <<EOF &&
669 info/exclude $(test_oid exclude)
670 core.excludesfile $ZERO_OID
671 exclude_per_dir .gitignore
673 / $(test_oid root) recurse valid
676 /done/ $(test_oid done) recurse valid
678 /dthree/ $ZERO_OID recurse check_only valid
679 /dtwo/ $ZERO_OID recurse check_only valid
682 test_cmp ../expect ../actual
685 test_expect_success
'test sparse status again with untracked cache' '
686 : >../trace.output &&
687 GIT_TRACE2_PERF="$TRASH_DIRECTORY/trace.output" \
688 git status --porcelain >../status.actual &&
689 iuc status --porcelain >../status.iuc &&
690 cat >../status.expect <<EOF &&
696 test_cmp ../status.expect ../status.iuc &&
697 test_cmp ../status.expect ../status.actual &&
698 get_relevant_traces ../trace.output ../trace.relevant &&
699 cat >../trace.expect <<EOF &&
702 ....gitignore-invalidation:0
703 ....directory-invalidation:0
706 test_cmp ../trace.expect ../trace.relevant
709 test_expect_success
'set up for test of subdir and sparse checkouts' '
711 mkdir done/sub/sub &&
712 echo "sub" > done/sub/sub/file &&
713 test-tool chmtime =-120 done/sub/sub/file done/sub/sub done/sub done
716 test_expect_success
'test sparse status with untracked cache and subdir' '
717 : >../trace.output &&
718 GIT_TRACE2_PERF="$TRASH_DIRECTORY/trace.output" \
719 git status --porcelain >../status.actual &&
720 iuc status --porcelain >../status.iuc &&
721 cat >../status.expect <<EOF &&
728 test_cmp ../status.expect ../status.iuc &&
729 test_cmp ../status.expect ../status.actual &&
730 get_relevant_traces ../trace.output ../trace.relevant &&
731 cat >../trace.expect <<EOF &&
734 ....gitignore-invalidation:0
735 ....directory-invalidation:1
738 test_cmp ../trace.expect ../trace.relevant
741 test_expect_success
'verify untracked cache dump (sparse/subdirs)' '
742 test-tool dump-untracked-cache >../actual &&
743 cat >../expect-from-test-dump <<EOF &&
744 info/exclude $(test_oid exclude)
745 core.excludesfile $ZERO_OID
746 exclude_per_dir .gitignore
748 / $(test_oid root) recurse valid
751 /done/ $(test_oid done) recurse valid
754 /done/sub/ $ZERO_OID recurse check_only valid
756 /done/sub/sub/ $ZERO_OID recurse check_only valid
758 /dthree/ $ZERO_OID recurse check_only valid
759 /dtwo/ $ZERO_OID recurse check_only valid
762 test_cmp ../expect-from-test-dump ../actual
765 test_expect_success
'test sparse status again with untracked cache and subdir' '
766 : >../trace.output &&
767 GIT_TRACE2_PERF="$TRASH_DIRECTORY/trace.output" \
768 git status --porcelain >../status.actual &&
769 iuc status --porcelain >../status.iuc &&
770 test_cmp ../status.expect ../status.iuc &&
771 test_cmp ../status.expect ../status.actual &&
772 get_relevant_traces ../trace.output ../trace.relevant &&
773 cat >../trace.expect <<EOF &&
776 ....gitignore-invalidation:0
777 ....directory-invalidation:0
780 test_cmp ../trace.expect ../trace.relevant
783 test_expect_success
'move entry in subdir from untracked to cached' '
785 git status --porcelain >../status.actual &&
786 iuc status --porcelain >../status.iuc &&
787 cat >../status.expect <<EOF &&
794 test_cmp ../status.expect ../status.iuc &&
795 test_cmp ../status.expect ../status.actual
798 test_expect_success
'move entry in subdir from cached to untracked' '
799 git rm --cached dtwo/two &&
800 git status --porcelain >../status.actual &&
801 iuc status --porcelain >../status.iuc &&
802 cat >../status.expect <<EOF &&
809 test_cmp ../status.expect ../status.iuc &&
810 test_cmp ../status.expect ../status.actual
813 test_expect_success
'--no-untracked-cache removes the cache' '
814 git update-index --no-untracked-cache &&
815 test-tool dump-untracked-cache >../actual &&
816 echo "no untracked cache" >../expect-no-uc &&
817 test_cmp ../expect-no-uc ../actual
820 test_expect_success
'git status does not change anything' '
822 test-tool dump-untracked-cache >../actual &&
823 test_cmp ../expect-no-uc ../actual
826 test_expect_success
'setting core.untrackedCache to true and using git status creates the cache' '
827 git config core.untrackedCache true &&
828 test-tool dump-untracked-cache >../actual &&
829 test_cmp ../expect-no-uc ../actual &&
831 test-tool dump-untracked-cache >../actual &&
832 test_cmp ../expect-from-test-dump ../actual
835 test_expect_success
'using --no-untracked-cache does not fail when core.untrackedCache is true' '
836 git update-index --no-untracked-cache &&
837 test-tool dump-untracked-cache >../actual &&
838 test_cmp ../expect-no-uc ../actual &&
839 git update-index --untracked-cache &&
840 test-tool dump-untracked-cache >../actual &&
841 test_cmp ../expect-empty ../actual
844 test_expect_success
'setting core.untrackedCache to false and using git status removes the cache' '
845 git config core.untrackedCache false &&
846 test-tool dump-untracked-cache >../actual &&
847 test_cmp ../expect-empty ../actual &&
849 test-tool dump-untracked-cache >../actual &&
850 test_cmp ../expect-no-uc ../actual
853 test_expect_success
'using --untracked-cache does not fail when core.untrackedCache is false' '
854 git update-index --untracked-cache &&
855 test-tool dump-untracked-cache >../actual &&
856 test_cmp ../expect-empty ../actual
859 test_expect_success
'setting core.untrackedCache to keep' '
860 git config core.untrackedCache keep &&
861 git update-index --untracked-cache &&
862 test-tool dump-untracked-cache >../actual &&
863 test_cmp ../expect-empty ../actual &&
865 test-tool dump-untracked-cache >../actual &&
866 test_cmp ../expect-from-test-dump ../actual &&
867 git update-index --no-untracked-cache &&
868 test-tool dump-untracked-cache >../actual &&
869 test_cmp ../expect-no-uc ../actual &&
870 git update-index --force-untracked-cache &&
871 test-tool dump-untracked-cache >../actual &&
872 test_cmp ../expect-empty ../actual &&
874 test-tool dump-untracked-cache >../actual &&
875 test_cmp ../expect-from-test-dump ../actual
878 test_expect_success
'test ident field is working' '
879 mkdir ../other_worktree &&
880 cp -R done dthree dtwo four three ../other_worktree &&
881 GIT_WORK_TREE=../other_worktree git status 2>../err &&
882 echo "warning: untracked cache is disabled on this system or location" >../expect &&
883 test_cmp ../expect ../err
886 test_expect_success
'untracked cache survives a checkout' '
887 git commit --allow-empty -m empty &&
888 test-tool dump-untracked-cache >../before &&
889 test_when_finished "git checkout main" &&
890 git checkout -b other_branch &&
891 test-tool dump-untracked-cache >../after &&
892 test_cmp ../before ../after &&
894 test-tool dump-untracked-cache >../before &&
896 test-tool dump-untracked-cache >../after &&
897 test_cmp ../before ../after
900 test_expect_success
'untracked cache survives a commit' '
901 test-tool dump-untracked-cache >../before &&
903 git commit -m commit &&
904 test-tool dump-untracked-cache >../after &&
905 test_cmp ../before ../after
908 test_expect_success
'teardown worktree' '
912 test_expect_success SYMLINKS
'setup worktree for symlink test' '
913 git init worktree-symlink &&
914 cd worktree-symlink &&
915 git config core.untrackedCache true &&
917 touch one/file two/file &&
918 git add one/file two/file &&
919 git commit -m"first commit" &&
923 git commit -m"second commit"
926 test_expect_success SYMLINKS
'"status" after symlink replacement should be clean with UC=true' '
927 git checkout HEAD~ &&
936 test_expect_success SYMLINKS
'"status" after symlink replacement should be clean with UC=false' '
937 git config core.untrackedCache false &&
938 git checkout HEAD~ &&
947 test_expect_success
'setup worktree for non-symlink test' '
948 git init worktree-non-symlink &&
949 cd worktree-non-symlink &&
950 git config core.untrackedCache true &&
952 touch one/file two/file &&
953 git add one/file two/file &&
954 git commit -m"first commit" &&
958 git commit -m"second commit"
961 test_expect_success
'"status" after file replacement should be clean with UC=true' '
962 git checkout HEAD~ &&
968 test-tool dump-untracked-cache >../actual &&
969 grep -F "recurse valid" ../actual >../actual.grep &&
970 cat >../expect.grep <<EOF &&
971 / $ZERO_OID recurse valid
972 /two/ $ZERO_OID recurse valid
975 test_cmp ../expect.grep ../actual.grep
978 test_expect_success
'"status" after file replacement should be clean with UC=false' '
979 git config core.untrackedCache false &&
980 git checkout HEAD~ &&
989 test_expect_success
'empty repo (no index) and core.untrackedCache' '
990 git init emptyrepo &&
991 git -C emptyrepo -c core.untrackedCache=true write-tree