t7063: mtime-mangling instead of delays in untracked cache testing
[git/debian.git] / t / t7063-status-untracked-cache.sh
blobca90ee805e7b3411c6e7c8c5868c3aa2063dba05
1 #!/bin/sh
3 test_description='test untracked cache'
5 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
6 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
8 . ./test-lib.sh
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
18 # more.
20 GIT_FORCE_UNTRACKED_CACHE=true
21 export GIT_FORCE_UNTRACKED_CACHE
23 sync_mtime () {
24 find . -type d -exec ls -ld {} + >/dev/null
27 avoid_racy() {
28 sleep 1
31 status_is_clean() {
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
41 iuc () {
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
46 export GIT_INDEX_FILE
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 "$@"
51 ret=$?
53 rm ../current-index-entries
54 rm $GIT_INDEX_FILE
55 unset GIT_INDEX_FILE
57 return $ret
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.
65 INPUT_FILE=$1
66 OUTPUT_FILE=$2
67 grep data.*read_directo $INPUT_FILE |
68 cut -d "|" -f 9 |
69 grep -v visited \
70 >"$OUTPUT_FILE"
74 test_lazy_prereq UNTRACKED_CACHE '
75 { git update-index --test-untracked-cache; ret=$?; } &&
76 test $ret -ne 1
79 if ! test_have_prereq UNTRACKED_CACHE; then
80 skip_all='This system does not support untracked cache'
81 test_done
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 worktree &&
90 cd 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 &&
97 : >.git/info/exclude &&
98 git update-index --untracked-cache &&
99 test_oid_cache <<-EOF
100 root sha1:e6fcc8f2ee31bae321d66afd183fcb7237afae6e
101 root sha256:b90c672088c015b9c83876e919da311bad4cd39639fb139f988af6a11493b974
103 exclude sha1:13263c0978fb9fad16b2d580fb800b6d811c3ff0
104 exclude sha256:fe4aaa1bbbbce4cb8f73426748a14c5ad6026b26f90505a0bf2494b165a5b76c
106 done sha1:1946f0437f90c5005533cbe1736a6451ca301714
107 done sha256:7f079501d79f665b3acc50f5e0e9e94509084d5032ac20113a37dd5029b757cc
111 test_expect_success 'untracked cache is empty' '
112 test-tool dump-untracked-cache >../actual &&
113 cat >../expect-empty <<EOF &&
114 info/exclude $ZERO_OID
115 core.excludesfile $ZERO_OID
116 exclude_per_dir .gitignore
117 flags 00000006
119 test_cmp ../expect-empty ../actual
122 cat >../status.expect <<EOF &&
123 A done/one
124 A one
125 A two
126 ?? dthree/
127 ?? dtwo/
128 ?? three
131 cat >../dump.expect <<EOF &&
132 info/exclude $EMPTY_BLOB
133 core.excludesfile $ZERO_OID
134 exclude_per_dir .gitignore
135 flags 00000006
136 / $ZERO_OID recurse valid
137 dthree/
138 dtwo/
139 three
140 /done/ $ZERO_OID recurse valid
141 /dthree/ $ZERO_OID recurse check_only valid
142 three
143 /dtwo/ $ZERO_OID recurse check_only valid
147 test_expect_success 'status first time (empty cache)' '
148 : >../trace.output &&
149 GIT_TRACE2_PERF="$TRASH_DIRECTORY/trace.output" \
150 git status --porcelain >../actual &&
151 iuc status --porcelain >../status.iuc &&
152 test_cmp ../status.expect ../status.iuc &&
153 test_cmp ../status.expect ../actual &&
154 get_relevant_traces ../trace.output ../trace.relevant &&
155 cat >../trace.expect <<EOF &&
156 ....path:
157 ....node-creation:3
158 ....gitignore-invalidation:1
159 ....directory-invalidation:0
160 ....opendir:4
162 test_cmp ../trace.expect ../trace.relevant
165 test_expect_success 'untracked cache after first status' '
166 test-tool dump-untracked-cache >../actual &&
167 test_cmp ../dump.expect ../actual
170 test_expect_success 'status second time (fully populated cache)' '
171 : >../trace.output &&
172 GIT_TRACE2_PERF="$TRASH_DIRECTORY/trace.output" \
173 git status --porcelain >../actual &&
174 iuc status --porcelain >../status.iuc &&
175 test_cmp ../status.expect ../status.iuc &&
176 test_cmp ../status.expect ../actual &&
177 get_relevant_traces ../trace.output ../trace.relevant &&
178 cat >../trace.expect <<EOF &&
179 ....path:
180 ....node-creation:0
181 ....gitignore-invalidation:0
182 ....directory-invalidation:0
183 ....opendir:0
185 test_cmp ../trace.expect ../trace.relevant
188 test_expect_success 'untracked cache after second status' '
189 test-tool dump-untracked-cache >../actual &&
190 test_cmp ../dump.expect ../actual
193 test_expect_success 'modify in root directory, one dir invalidation' '
194 : >four &&
195 test-tool chmtime =-240 four &&
196 : >../trace.output &&
197 GIT_TRACE2_PERF="$TRASH_DIRECTORY/trace.output" \
198 git status --porcelain >../actual &&
199 iuc status --porcelain >../status.iuc &&
200 cat >../status.expect <<EOF &&
201 A done/one
202 A one
203 A two
204 ?? dthree/
205 ?? dtwo/
206 ?? four
207 ?? three
209 test_cmp ../status.expect ../status.iuc &&
210 test_cmp ../status.expect ../actual &&
211 get_relevant_traces ../trace.output ../trace.relevant &&
212 cat >../trace.expect <<EOF &&
213 ....path:
214 ....node-creation:0
215 ....gitignore-invalidation:0
216 ....directory-invalidation:1
217 ....opendir:1
219 test_cmp ../trace.expect ../trace.relevant
223 test_expect_success 'verify untracked cache dump' '
224 test-tool dump-untracked-cache >../actual &&
225 cat >../expect <<EOF &&
226 info/exclude $EMPTY_BLOB
227 core.excludesfile $ZERO_OID
228 exclude_per_dir .gitignore
229 flags 00000006
230 / $ZERO_OID recurse valid
231 dthree/
232 dtwo/
233 four
234 three
235 /done/ $ZERO_OID recurse valid
236 /dthree/ $ZERO_OID recurse check_only valid
237 three
238 /dtwo/ $ZERO_OID recurse check_only valid
241 test_cmp ../expect ../actual
244 test_expect_success 'new .gitignore invalidates recursively' '
245 echo four >.gitignore &&
246 : >../trace.output &&
247 GIT_TRACE2_PERF="$TRASH_DIRECTORY/trace.output" \
248 git status --porcelain >../actual &&
249 iuc status --porcelain >../status.iuc &&
250 cat >../status.expect <<EOF &&
251 A done/one
252 A one
253 A two
254 ?? .gitignore
255 ?? dthree/
256 ?? dtwo/
257 ?? three
259 test_cmp ../status.expect ../status.iuc &&
260 test_cmp ../status.expect ../actual &&
261 get_relevant_traces ../trace.output ../trace.relevant &&
262 cat >../trace.expect <<EOF &&
263 ....path:
264 ....node-creation:0
265 ....gitignore-invalidation:1
266 ....directory-invalidation:1
267 ....opendir:4
269 test_cmp ../trace.expect ../trace.relevant
273 test_expect_success 'verify untracked cache dump' '
274 test-tool dump-untracked-cache >../actual &&
275 cat >../expect <<EOF &&
276 info/exclude $EMPTY_BLOB
277 core.excludesfile $ZERO_OID
278 exclude_per_dir .gitignore
279 flags 00000006
280 / $(test_oid root) recurse valid
281 .gitignore
282 dthree/
283 dtwo/
284 three
285 /done/ $ZERO_OID recurse valid
286 /dthree/ $ZERO_OID recurse check_only valid
287 three
288 /dtwo/ $ZERO_OID recurse check_only valid
291 test_cmp ../expect ../actual
294 test_expect_success 'new info/exclude invalidates everything' '
295 echo three >>.git/info/exclude &&
296 : >../trace.output &&
297 GIT_TRACE2_PERF="$TRASH_DIRECTORY/trace.output" \
298 git status --porcelain >../actual &&
299 iuc status --porcelain >../status.iuc &&
300 cat >../status.expect <<EOF &&
301 A done/one
302 A one
303 A two
304 ?? .gitignore
305 ?? dtwo/
307 test_cmp ../status.expect ../status.iuc &&
308 test_cmp ../status.expect ../actual &&
309 get_relevant_traces ../trace.output ../trace.relevant &&
310 cat >../trace.expect <<EOF &&
311 ....path:
312 ....node-creation:0
313 ....gitignore-invalidation:1
314 ....directory-invalidation:0
315 ....opendir:4
317 test_cmp ../trace.expect ../trace.relevant
320 test_expect_success 'verify untracked cache dump' '
321 test-tool dump-untracked-cache >../actual &&
322 cat >../expect <<EOF &&
323 info/exclude $(test_oid exclude)
324 core.excludesfile $ZERO_OID
325 exclude_per_dir .gitignore
326 flags 00000006
327 / $(test_oid root) recurse valid
328 .gitignore
329 dtwo/
330 /done/ $ZERO_OID recurse valid
331 /dthree/ $ZERO_OID recurse check_only valid
332 /dtwo/ $ZERO_OID recurse check_only valid
335 test_cmp ../expect ../actual
338 test_expect_success 'move two from tracked to untracked' '
339 git rm --cached two &&
340 test-tool dump-untracked-cache >../actual &&
341 cat >../expect <<EOF &&
342 info/exclude $(test_oid exclude)
343 core.excludesfile $ZERO_OID
344 exclude_per_dir .gitignore
345 flags 00000006
346 / $(test_oid root) recurse
347 /done/ $ZERO_OID recurse valid
348 /dthree/ $ZERO_OID recurse check_only valid
349 /dtwo/ $ZERO_OID recurse check_only valid
352 test_cmp ../expect ../actual
355 test_expect_success 'status after the move' '
356 : >../trace.output &&
357 GIT_TRACE2_PERF="$TRASH_DIRECTORY/trace.output" \
358 git status --porcelain >../actual &&
359 iuc status --porcelain >../status.iuc &&
360 cat >../status.expect <<EOF &&
361 A done/one
362 A one
363 ?? .gitignore
364 ?? dtwo/
365 ?? two
367 test_cmp ../status.expect ../status.iuc &&
368 test_cmp ../status.expect ../actual &&
369 get_relevant_traces ../trace.output ../trace.relevant &&
370 cat >../trace.expect <<EOF &&
371 ....path:
372 ....node-creation:0
373 ....gitignore-invalidation:0
374 ....directory-invalidation:0
375 ....opendir:1
377 test_cmp ../trace.expect ../trace.relevant
380 test_expect_success 'verify untracked cache dump' '
381 test-tool dump-untracked-cache >../actual &&
382 cat >../expect <<EOF &&
383 info/exclude $(test_oid exclude)
384 core.excludesfile $ZERO_OID
385 exclude_per_dir .gitignore
386 flags 00000006
387 / $(test_oid root) recurse valid
388 .gitignore
389 dtwo/
391 /done/ $ZERO_OID recurse valid
392 /dthree/ $ZERO_OID recurse check_only valid
393 /dtwo/ $ZERO_OID recurse check_only valid
396 test_cmp ../expect ../actual
399 test_expect_success 'move two from untracked to tracked' '
400 git add two &&
401 test-tool dump-untracked-cache >../actual &&
402 cat >../expect <<EOF &&
403 info/exclude $(test_oid exclude)
404 core.excludesfile $ZERO_OID
405 exclude_per_dir .gitignore
406 flags 00000006
407 / $(test_oid root) recurse
408 /done/ $ZERO_OID recurse valid
409 /dthree/ $ZERO_OID recurse check_only valid
410 /dtwo/ $ZERO_OID recurse check_only valid
413 test_cmp ../expect ../actual
416 test_expect_success 'status after the move' '
417 : >../trace.output &&
418 GIT_TRACE2_PERF="$TRASH_DIRECTORY/trace.output" \
419 git status --porcelain >../actual &&
420 iuc status --porcelain >../status.iuc &&
421 cat >../status.expect <<EOF &&
422 A done/one
423 A one
424 A two
425 ?? .gitignore
426 ?? dtwo/
428 test_cmp ../status.expect ../status.iuc &&
429 test_cmp ../status.expect ../actual &&
430 get_relevant_traces ../trace.output ../trace.relevant &&
431 cat >../trace.expect <<EOF &&
432 ....path:
433 ....node-creation:0
434 ....gitignore-invalidation:0
435 ....directory-invalidation:0
436 ....opendir:1
438 test_cmp ../trace.expect ../trace.relevant
441 test_expect_success 'verify untracked cache dump' '
442 test-tool dump-untracked-cache >../actual &&
443 cat >../expect <<EOF &&
444 info/exclude $(test_oid exclude)
445 core.excludesfile $ZERO_OID
446 exclude_per_dir .gitignore
447 flags 00000006
448 / $(test_oid root) recurse valid
449 .gitignore
450 dtwo/
451 /done/ $ZERO_OID recurse valid
452 /dthree/ $ZERO_OID recurse check_only valid
453 /dtwo/ $ZERO_OID recurse check_only valid
456 test_cmp ../expect ../actual
459 test_expect_success 'set up for sparse checkout testing' '
460 echo two >done/.gitignore &&
461 echo three >>done/.gitignore &&
462 echo two >done/two &&
463 git add -f done/two done/.gitignore &&
464 git commit -m "first commit"
467 test_expect_success 'status after commit' '
468 : >../trace.output &&
469 GIT_TRACE2_PERF="$TRASH_DIRECTORY/trace.output" \
470 git status --porcelain >../actual &&
471 iuc status --porcelain >../status.iuc &&
472 cat >../status.expect <<EOF &&
473 ?? .gitignore
474 ?? dtwo/
476 test_cmp ../status.expect ../status.iuc &&
477 test_cmp ../status.expect ../actual &&
478 get_relevant_traces ../trace.output ../trace.relevant &&
479 cat >../trace.expect <<EOF &&
480 ....path:
481 ....node-creation:0
482 ....gitignore-invalidation:0
483 ....directory-invalidation:0
484 ....opendir:2
486 test_cmp ../trace.expect ../trace.relevant
489 test_expect_success 'untracked cache correct after commit' '
490 test-tool dump-untracked-cache >../actual &&
491 cat >../expect <<EOF &&
492 info/exclude $(test_oid exclude)
493 core.excludesfile $ZERO_OID
494 exclude_per_dir .gitignore
495 flags 00000006
496 / $(test_oid root) recurse valid
497 .gitignore
498 dtwo/
499 /done/ $ZERO_OID recurse valid
500 /dthree/ $ZERO_OID recurse check_only valid
501 /dtwo/ $ZERO_OID recurse check_only valid
504 test_cmp ../expect ../actual
507 test_expect_success 'set up sparse checkout' '
508 echo "done/[a-z]*" >.git/info/sparse-checkout &&
509 test_config core.sparsecheckout true &&
510 git checkout main &&
511 git update-index --force-untracked-cache &&
512 git status --porcelain >/dev/null && # prime the cache
513 test_path_is_missing done/.gitignore &&
514 test_path_is_file done/one
517 test_expect_success 'create/modify files, some of which are gitignored' '
518 echo two bis >done/two &&
519 echo three >done/three && # three is gitignored
520 echo four >done/four && # four is gitignored at a higher level
521 echo five >done/five && # five is not gitignored
522 test-tool chmtime =-180 done/two done/three done/four done/five done &&
523 # we need to ensure that the root dir is touched (in the past);
524 test-tool chmtime =-180 . &&
525 sync_mtime
528 test_expect_success 'test sparse status with untracked cache' '
529 : >../trace.output &&
530 GIT_TRACE2_PERF="$TRASH_DIRECTORY/trace.output" \
531 git status --porcelain >../status.actual &&
532 iuc status --porcelain >../status.iuc &&
533 cat >../status.expect <<EOF &&
534 M done/two
535 ?? .gitignore
536 ?? done/five
537 ?? dtwo/
539 test_cmp ../status.expect ../status.iuc &&
540 test_cmp ../status.expect ../status.actual &&
541 get_relevant_traces ../trace.output ../trace.relevant &&
542 cat >../trace.expect <<EOF &&
543 ....path:
544 ....node-creation:0
545 ....gitignore-invalidation:1
546 ....directory-invalidation:2
547 ....opendir:2
549 test_cmp ../trace.expect ../trace.relevant
552 test_expect_success 'untracked cache correct after status' '
553 test-tool dump-untracked-cache >../actual &&
554 cat >../expect <<EOF &&
555 info/exclude $(test_oid exclude)
556 core.excludesfile $ZERO_OID
557 exclude_per_dir .gitignore
558 flags 00000006
559 / $(test_oid root) recurse valid
560 .gitignore
561 dtwo/
562 /done/ $(test_oid done) recurse valid
563 five
564 /dthree/ $ZERO_OID recurse check_only valid
565 /dtwo/ $ZERO_OID recurse check_only valid
568 test_cmp ../expect ../actual
571 test_expect_success 'test sparse status again with untracked cache' '
572 : >../trace.output &&
573 GIT_TRACE2_PERF="$TRASH_DIRECTORY/trace.output" \
574 git status --porcelain >../status.actual &&
575 iuc status --porcelain >../status.iuc &&
576 cat >../status.expect <<EOF &&
577 M done/two
578 ?? .gitignore
579 ?? done/five
580 ?? dtwo/
582 test_cmp ../status.expect ../status.iuc &&
583 test_cmp ../status.expect ../status.actual &&
584 get_relevant_traces ../trace.output ../trace.relevant &&
585 cat >../trace.expect <<EOF &&
586 ....path:
587 ....node-creation:0
588 ....gitignore-invalidation:0
589 ....directory-invalidation:0
590 ....opendir:0
592 test_cmp ../trace.expect ../trace.relevant
595 test_expect_success 'set up for test of subdir and sparse checkouts' '
596 mkdir done/sub &&
597 mkdir done/sub/sub &&
598 echo "sub" > done/sub/sub/file &&
599 test-tool chmtime =-120 done/sub/sub/file done/sub/sub done/sub done
602 test_expect_success 'test sparse status with untracked cache and subdir' '
603 : >../trace.output &&
604 GIT_TRACE2_PERF="$TRASH_DIRECTORY/trace.output" \
605 git status --porcelain >../status.actual &&
606 iuc status --porcelain >../status.iuc &&
607 cat >../status.expect <<EOF &&
608 M done/two
609 ?? .gitignore
610 ?? done/five
611 ?? done/sub/
612 ?? dtwo/
614 test_cmp ../status.expect ../status.iuc &&
615 test_cmp ../status.expect ../status.actual &&
616 get_relevant_traces ../trace.output ../trace.relevant &&
617 cat >../trace.expect <<EOF &&
618 ....path:
619 ....node-creation:2
620 ....gitignore-invalidation:0
621 ....directory-invalidation:1
622 ....opendir:3
624 test_cmp ../trace.expect ../trace.relevant
627 test_expect_success 'verify untracked cache dump (sparse/subdirs)' '
628 test-tool dump-untracked-cache >../actual &&
629 cat >../expect-from-test-dump <<EOF &&
630 info/exclude $(test_oid exclude)
631 core.excludesfile $ZERO_OID
632 exclude_per_dir .gitignore
633 flags 00000006
634 / $(test_oid root) recurse valid
635 .gitignore
636 dtwo/
637 /done/ $(test_oid done) recurse valid
638 five
639 sub/
640 /done/sub/ $ZERO_OID recurse check_only valid
641 sub/
642 /done/sub/sub/ $ZERO_OID recurse check_only valid
643 file
644 /dthree/ $ZERO_OID recurse check_only valid
645 /dtwo/ $ZERO_OID recurse check_only valid
648 test_cmp ../expect-from-test-dump ../actual
651 test_expect_success 'test sparse status again with untracked cache and subdir' '
652 : >../trace.output &&
653 GIT_TRACE2_PERF="$TRASH_DIRECTORY/trace.output" \
654 git status --porcelain >../status.actual &&
655 iuc status --porcelain >../status.iuc &&
656 test_cmp ../status.expect ../status.iuc &&
657 test_cmp ../status.expect ../status.actual &&
658 get_relevant_traces ../trace.output ../trace.relevant &&
659 cat >../trace.expect <<EOF &&
660 ....path:
661 ....node-creation:0
662 ....gitignore-invalidation:0
663 ....directory-invalidation:0
664 ....opendir:0
666 test_cmp ../trace.expect ../trace.relevant
669 test_expect_success 'move entry in subdir from untracked to cached' '
670 git add dtwo/two &&
671 git status --porcelain >../status.actual &&
672 iuc status --porcelain >../status.iuc &&
673 cat >../status.expect <<EOF &&
674 M done/two
675 A dtwo/two
676 ?? .gitignore
677 ?? done/five
678 ?? done/sub/
680 test_cmp ../status.expect ../status.iuc &&
681 test_cmp ../status.expect ../status.actual
684 test_expect_success 'move entry in subdir from cached to untracked' '
685 git rm --cached dtwo/two &&
686 git status --porcelain >../status.actual &&
687 iuc status --porcelain >../status.iuc &&
688 cat >../status.expect <<EOF &&
689 M done/two
690 ?? .gitignore
691 ?? done/five
692 ?? done/sub/
693 ?? dtwo/
695 test_cmp ../status.expect ../status.iuc &&
696 test_cmp ../status.expect ../status.actual
699 test_expect_success '--no-untracked-cache removes the cache' '
700 git update-index --no-untracked-cache &&
701 test-tool dump-untracked-cache >../actual &&
702 echo "no untracked cache" >../expect-no-uc &&
703 test_cmp ../expect-no-uc ../actual
706 test_expect_success 'git status does not change anything' '
707 git status &&
708 test-tool dump-untracked-cache >../actual &&
709 test_cmp ../expect-no-uc ../actual
712 test_expect_success 'setting core.untrackedCache to true and using git status creates the cache' '
713 git config core.untrackedCache true &&
714 test-tool dump-untracked-cache >../actual &&
715 test_cmp ../expect-no-uc ../actual &&
716 git status &&
717 test-tool dump-untracked-cache >../actual &&
718 test_cmp ../expect-from-test-dump ../actual
721 test_expect_success 'using --no-untracked-cache does not fail when core.untrackedCache is true' '
722 git update-index --no-untracked-cache &&
723 test-tool dump-untracked-cache >../actual &&
724 test_cmp ../expect-no-uc ../actual &&
725 git update-index --untracked-cache &&
726 test-tool dump-untracked-cache >../actual &&
727 test_cmp ../expect-empty ../actual
730 test_expect_success 'setting core.untrackedCache to false and using git status removes the cache' '
731 git config core.untrackedCache false &&
732 test-tool dump-untracked-cache >../actual &&
733 test_cmp ../expect-empty ../actual &&
734 git status &&
735 test-tool dump-untracked-cache >../actual &&
736 test_cmp ../expect-no-uc ../actual
739 test_expect_success 'using --untracked-cache does not fail when core.untrackedCache is false' '
740 git update-index --untracked-cache &&
741 test-tool dump-untracked-cache >../actual &&
742 test_cmp ../expect-empty ../actual
745 test_expect_success 'setting core.untrackedCache to keep' '
746 git config core.untrackedCache keep &&
747 git update-index --untracked-cache &&
748 test-tool dump-untracked-cache >../actual &&
749 test_cmp ../expect-empty ../actual &&
750 git status &&
751 test-tool dump-untracked-cache >../actual &&
752 test_cmp ../expect-from-test-dump ../actual &&
753 git update-index --no-untracked-cache &&
754 test-tool dump-untracked-cache >../actual &&
755 test_cmp ../expect-no-uc ../actual &&
756 git update-index --force-untracked-cache &&
757 test-tool dump-untracked-cache >../actual &&
758 test_cmp ../expect-empty ../actual &&
759 git status &&
760 test-tool dump-untracked-cache >../actual &&
761 test_cmp ../expect-from-test-dump ../actual
764 test_expect_success 'test ident field is working' '
765 mkdir ../other_worktree &&
766 cp -R done dthree dtwo four three ../other_worktree &&
767 GIT_WORK_TREE=../other_worktree git status 2>../err &&
768 echo "warning: untracked cache is disabled on this system or location" >../expect &&
769 test_cmp ../expect ../err
772 test_expect_success 'untracked cache survives a checkout' '
773 git commit --allow-empty -m empty &&
774 test-tool dump-untracked-cache >../before &&
775 test_when_finished "git checkout main" &&
776 git checkout -b other_branch &&
777 test-tool dump-untracked-cache >../after &&
778 test_cmp ../before ../after &&
779 test_commit test &&
780 test-tool dump-untracked-cache >../before &&
781 git checkout main &&
782 test-tool dump-untracked-cache >../after &&
783 test_cmp ../before ../after
786 test_expect_success 'untracked cache survives a commit' '
787 test-tool dump-untracked-cache >../before &&
788 git add done/two &&
789 git commit -m commit &&
790 test-tool dump-untracked-cache >../after &&
791 test_cmp ../before ../after
794 test_expect_success 'teardown worktree' '
795 cd ..
798 test_expect_success SYMLINKS 'setup worktree for symlink test' '
799 git init worktree-symlink &&
800 cd worktree-symlink &&
801 git config core.untrackedCache true &&
802 mkdir one two &&
803 touch one/file two/file &&
804 git add one/file two/file &&
805 git commit -m"first commit" &&
806 git rm -rf one &&
807 ln -s two one &&
808 git add one &&
809 git commit -m"second commit"
812 test_expect_success SYMLINKS '"status" after symlink replacement should be clean with UC=true' '
813 git checkout HEAD~ &&
814 status_is_clean &&
815 status_is_clean &&
816 git checkout main &&
817 avoid_racy &&
818 status_is_clean &&
819 status_is_clean
822 test_expect_success SYMLINKS '"status" after symlink replacement should be clean with UC=false' '
823 git config core.untrackedCache false &&
824 git checkout HEAD~ &&
825 status_is_clean &&
826 status_is_clean &&
827 git checkout main &&
828 avoid_racy &&
829 status_is_clean &&
830 status_is_clean
833 test_expect_success 'setup worktree for non-symlink test' '
834 git init worktree-non-symlink &&
835 cd worktree-non-symlink &&
836 git config core.untrackedCache true &&
837 mkdir one two &&
838 touch one/file two/file &&
839 git add one/file two/file &&
840 git commit -m"first commit" &&
841 git rm -rf one &&
842 cp two/file one &&
843 git add one &&
844 git commit -m"second commit"
847 test_expect_success '"status" after file replacement should be clean with UC=true' '
848 git checkout HEAD~ &&
849 status_is_clean &&
850 status_is_clean &&
851 git checkout main &&
852 avoid_racy &&
853 status_is_clean &&
854 test-tool dump-untracked-cache >../actual &&
855 grep -F "recurse valid" ../actual >../actual.grep &&
856 cat >../expect.grep <<EOF &&
857 / $ZERO_OID recurse valid
858 /two/ $ZERO_OID recurse valid
860 status_is_clean &&
861 test_cmp ../expect.grep ../actual.grep
864 test_expect_success '"status" after file replacement should be clean with UC=false' '
865 git config core.untrackedCache false &&
866 git checkout HEAD~ &&
867 status_is_clean &&
868 status_is_clean &&
869 git checkout main &&
870 avoid_racy &&
871 status_is_clean &&
872 status_is_clean
875 test_done