3 test_description
='test untracked cache'
11 test_lazy_prereq UNTRACKED_CACHE
'
12 { git update-index --test-untracked-cache; ret=$?; } &&
16 if ! test_have_prereq UNTRACKED_CACHE
; then
17 skip_all
='This system does not support untracked cache'
21 test_expect_success
'setup' '
24 mkdir done dtwo dthree &&
25 touch one two three done/one dtwo/two dthree/three &&
26 git add one two done/one &&
27 : >.git/info/exclude &&
28 git update-index --untracked-cache
31 test_expect_success
'untracked cache is empty' '
32 test-dump-untracked-cache >../actual &&
33 cat >../expect <<EOF &&
34 info/exclude 0000000000000000000000000000000000000000
35 core.excludesfile 0000000000000000000000000000000000000000
36 exclude_per_dir .gitignore
39 test_cmp ../expect ../actual
42 cat >..
/status.expect
<<EOF &&
51 cat >..
/dump.expect
<<EOF &&
52 info/exclude e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
53 core.excludesfile 0000000000000000000000000000000000000000
54 exclude_per_dir .gitignore
56 / 0000000000000000000000000000000000000000 recurse valid
60 /done/ 0000000000000000000000000000000000000000 recurse valid
61 /dthree/ 0000000000000000000000000000000000000000 recurse check_only valid
63 /dtwo/ 0000000000000000000000000000000000000000 recurse check_only valid
67 test_expect_success
'status first time (empty cache)' '
70 GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \
71 git status --porcelain >../actual &&
72 test_cmp ../status.expect ../actual &&
73 cat >../trace.expect <<EOF &&
75 gitignore invalidation: 1
76 directory invalidation: 0
79 test_cmp ../trace.expect ../trace
82 test_expect_success
'untracked cache after first status' '
83 test-dump-untracked-cache >../actual &&
84 test_cmp ../dump.expect ../actual
87 test_expect_success
'status second time (fully populated cache)' '
90 GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \
91 git status --porcelain >../actual &&
92 test_cmp ../status.expect ../actual &&
93 cat >../trace.expect <<EOF &&
95 gitignore invalidation: 0
96 directory invalidation: 0
99 test_cmp ../trace.expect ../trace
102 test_expect_success
'untracked cache after second status' '
103 test-dump-untracked-cache >../actual &&
104 test_cmp ../dump.expect ../actual
107 test_expect_success
'modify in root directory, one dir invalidation' '
111 GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \
112 git status --porcelain >../actual &&
113 cat >../status.expect <<EOF &&
122 test_cmp ../status.expect ../actual &&
123 cat >../trace.expect <<EOF &&
125 gitignore invalidation: 0
126 directory invalidation: 1
129 test_cmp ../trace.expect ../trace
133 test_expect_success
'verify untracked cache dump' '
134 test-dump-untracked-cache >../actual &&
135 cat >../expect <<EOF &&
136 info/exclude e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
137 core.excludesfile 0000000000000000000000000000000000000000
138 exclude_per_dir .gitignore
140 / 0000000000000000000000000000000000000000 recurse valid
145 /done/ 0000000000000000000000000000000000000000 recurse valid
146 /dthree/ 0000000000000000000000000000000000000000 recurse check_only valid
148 /dtwo/ 0000000000000000000000000000000000000000 recurse check_only valid
151 test_cmp ../expect ../actual
154 test_expect_success
'new .gitignore invalidates recursively' '
156 echo four >.gitignore &&
158 GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \
159 git status --porcelain >../actual &&
160 cat >../status.expect <<EOF &&
169 test_cmp ../status.expect ../actual &&
170 cat >../trace.expect <<EOF &&
172 gitignore invalidation: 1
173 directory invalidation: 1
176 test_cmp ../trace.expect ../trace
180 test_expect_success
'verify untracked cache dump' '
181 test-dump-untracked-cache >../actual &&
182 cat >../expect <<EOF &&
183 info/exclude e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
184 core.excludesfile 0000000000000000000000000000000000000000
185 exclude_per_dir .gitignore
187 / e6fcc8f2ee31bae321d66afd183fcb7237afae6e recurse valid
192 /done/ 0000000000000000000000000000000000000000 recurse valid
193 /dthree/ 0000000000000000000000000000000000000000 recurse check_only valid
195 /dtwo/ 0000000000000000000000000000000000000000 recurse check_only valid
198 test_cmp ../expect ../actual
201 test_expect_success
'new info/exclude invalidates everything' '
203 echo three >>.git/info/exclude &&
205 GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \
206 git status --porcelain >../actual &&
207 cat >../status.expect <<EOF &&
214 test_cmp ../status.expect ../actual &&
215 cat >../trace.expect <<EOF &&
217 gitignore invalidation: 1
218 directory invalidation: 0
221 test_cmp ../trace.expect ../trace
224 test_expect_success
'verify untracked cache dump' '
225 test-dump-untracked-cache >../actual &&
226 cat >../expect <<EOF &&
227 info/exclude 13263c0978fb9fad16b2d580fb800b6d811c3ff0
228 core.excludesfile 0000000000000000000000000000000000000000
229 exclude_per_dir .gitignore
231 / e6fcc8f2ee31bae321d66afd183fcb7237afae6e recurse valid
234 /done/ 0000000000000000000000000000000000000000 recurse valid
235 /dthree/ 0000000000000000000000000000000000000000 recurse check_only valid
236 /dtwo/ 0000000000000000000000000000000000000000 recurse check_only valid
239 test_cmp ../expect ../actual
242 test_expect_success
'move two from tracked to untracked' '
243 git rm --cached two &&
244 test-dump-untracked-cache >../actual &&
245 cat >../expect <<EOF &&
246 info/exclude 13263c0978fb9fad16b2d580fb800b6d811c3ff0
247 core.excludesfile 0000000000000000000000000000000000000000
248 exclude_per_dir .gitignore
250 / e6fcc8f2ee31bae321d66afd183fcb7237afae6e recurse
251 /done/ 0000000000000000000000000000000000000000 recurse valid
252 /dthree/ 0000000000000000000000000000000000000000 recurse check_only valid
253 /dtwo/ 0000000000000000000000000000000000000000 recurse check_only valid
256 test_cmp ../expect ../actual
259 test_expect_success
'status after the move' '
261 GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \
262 git status --porcelain >../actual &&
263 cat >../status.expect <<EOF &&
270 test_cmp ../status.expect ../actual &&
271 cat >../trace.expect <<EOF &&
273 gitignore invalidation: 0
274 directory invalidation: 0
277 test_cmp ../trace.expect ../trace
280 test_expect_success
'verify untracked cache dump' '
281 test-dump-untracked-cache >../actual &&
282 cat >../expect <<EOF &&
283 info/exclude 13263c0978fb9fad16b2d580fb800b6d811c3ff0
284 core.excludesfile 0000000000000000000000000000000000000000
285 exclude_per_dir .gitignore
287 / e6fcc8f2ee31bae321d66afd183fcb7237afae6e recurse valid
291 /done/ 0000000000000000000000000000000000000000 recurse valid
292 /dthree/ 0000000000000000000000000000000000000000 recurse check_only valid
293 /dtwo/ 0000000000000000000000000000000000000000 recurse check_only valid
296 test_cmp ../expect ../actual
299 test_expect_success
'move two from untracked to tracked' '
301 test-dump-untracked-cache >../actual &&
302 cat >../expect <<EOF &&
303 info/exclude 13263c0978fb9fad16b2d580fb800b6d811c3ff0
304 core.excludesfile 0000000000000000000000000000000000000000
305 exclude_per_dir .gitignore
307 / e6fcc8f2ee31bae321d66afd183fcb7237afae6e recurse
308 /done/ 0000000000000000000000000000000000000000 recurse valid
309 /dthree/ 0000000000000000000000000000000000000000 recurse check_only valid
310 /dtwo/ 0000000000000000000000000000000000000000 recurse check_only valid
313 test_cmp ../expect ../actual
316 test_expect_success
'status after the move' '
318 GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \
319 git status --porcelain >../actual &&
320 cat >../status.expect <<EOF &&
327 test_cmp ../status.expect ../actual &&
328 cat >../trace.expect <<EOF &&
330 gitignore invalidation: 0
331 directory invalidation: 0
334 test_cmp ../trace.expect ../trace
337 test_expect_success
'verify untracked cache dump' '
338 test-dump-untracked-cache >../actual &&
339 cat >../expect <<EOF &&
340 info/exclude 13263c0978fb9fad16b2d580fb800b6d811c3ff0
341 core.excludesfile 0000000000000000000000000000000000000000
342 exclude_per_dir .gitignore
344 / e6fcc8f2ee31bae321d66afd183fcb7237afae6e recurse valid
347 /done/ 0000000000000000000000000000000000000000 recurse valid
348 /dthree/ 0000000000000000000000000000000000000000 recurse check_only valid
349 /dtwo/ 0000000000000000000000000000000000000000 recurse check_only valid
352 test_cmp ../expect ../actual
355 test_expect_success
'set up for sparse checkout testing' '
356 echo two >done/.gitignore &&
357 echo three >>done/.gitignore &&
358 echo two >done/two &&
359 git add -f done/two done/.gitignore &&
360 git commit -m "first commit"
363 test_expect_success
'status after commit' '
365 GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \
366 git status --porcelain >../actual &&
367 cat >../status.expect <<EOF &&
371 test_cmp ../status.expect ../actual &&
372 cat >../trace.expect <<EOF &&
374 gitignore invalidation: 0
375 directory invalidation: 0
378 test_cmp ../trace.expect ../trace
381 test_expect_success
'untracked cache correct after commit' '
382 test-dump-untracked-cache >../actual &&
383 cat >../expect <<EOF &&
384 info/exclude 13263c0978fb9fad16b2d580fb800b6d811c3ff0
385 core.excludesfile 0000000000000000000000000000000000000000
386 exclude_per_dir .gitignore
388 / e6fcc8f2ee31bae321d66afd183fcb7237afae6e recurse valid
391 /done/ 0000000000000000000000000000000000000000 recurse valid
392 /dthree/ 0000000000000000000000000000000000000000 recurse check_only valid
393 /dtwo/ 0000000000000000000000000000000000000000 recurse check_only valid
396 test_cmp ../expect ../actual
399 test_expect_success
'set up sparse checkout' '
400 echo "done/[a-z]*" >.git/info/sparse-checkout &&
401 test_config core.sparsecheckout true &&
402 git checkout master &&
403 git update-index --force-untracked-cache &&
404 git status --porcelain >/dev/null && # prime the cache
405 test_path_is_missing done/.gitignore &&
406 test_path_is_file done/one
409 test_expect_success
'create/modify files, some of which are gitignored' '
410 echo two bis >done/two &&
411 echo three >done/three && # three is gitignored
412 echo four >done/four && # four is gitignored at a higher level
413 echo five >done/five && # five is not gitignored
414 echo test >base && #we need to ensure that the root dir is touched
418 test_expect_success
'test sparse status with untracked cache' '
421 GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \
422 git status --porcelain >../status.actual &&
423 cat >../status.expect <<EOF &&
429 test_cmp ../status.expect ../status.actual &&
430 cat >../trace.expect <<EOF &&
432 gitignore invalidation: 1
433 directory invalidation: 2
436 test_cmp ../trace.expect ../trace
439 test_expect_success
'untracked cache correct after status' '
440 test-dump-untracked-cache >../actual &&
441 cat >../expect <<EOF &&
442 info/exclude 13263c0978fb9fad16b2d580fb800b6d811c3ff0
443 core.excludesfile 0000000000000000000000000000000000000000
444 exclude_per_dir .gitignore
446 / e6fcc8f2ee31bae321d66afd183fcb7237afae6e recurse valid
449 /done/ 1946f0437f90c5005533cbe1736a6451ca301714 recurse valid
451 /dthree/ 0000000000000000000000000000000000000000 recurse check_only valid
452 /dtwo/ 0000000000000000000000000000000000000000 recurse check_only valid
455 test_cmp ../expect ../actual
458 test_expect_success
'test sparse status again with untracked cache' '
461 GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \
462 git status --porcelain >../status.actual &&
463 cat >../status.expect <<EOF &&
469 test_cmp ../status.expect ../status.actual &&
470 cat >../trace.expect <<EOF &&
472 gitignore invalidation: 0
473 directory invalidation: 0
476 test_cmp ../trace.expect ../trace
479 test_expect_success
'set up for test of subdir and sparse checkouts' '
481 mkdir done/sub/sub &&
482 echo "sub" > done/sub/sub/file
485 test_expect_success
'test sparse status with untracked cache and subdir' '
488 GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \
489 git status --porcelain >../status.actual &&
490 cat >../status.expect <<EOF &&
497 test_cmp ../status.expect ../status.actual &&
498 cat >../trace.expect <<EOF &&
500 gitignore invalidation: 0
501 directory invalidation: 1
504 test_cmp ../trace.expect ../trace
507 test_expect_success
'verify untracked cache dump (sparse/subdirs)' '
508 test-dump-untracked-cache >../actual &&
509 cat >../expect <<EOF &&
510 info/exclude 13263c0978fb9fad16b2d580fb800b6d811c3ff0
511 core.excludesfile 0000000000000000000000000000000000000000
512 exclude_per_dir .gitignore
514 / e6fcc8f2ee31bae321d66afd183fcb7237afae6e recurse valid
517 /done/ 1946f0437f90c5005533cbe1736a6451ca301714 recurse valid
520 /done/sub/ 0000000000000000000000000000000000000000 recurse check_only valid
522 /done/sub/sub/ 0000000000000000000000000000000000000000 recurse check_only valid
524 /dthree/ 0000000000000000000000000000000000000000 recurse check_only valid
525 /dtwo/ 0000000000000000000000000000000000000000 recurse check_only valid
528 test_cmp ../expect ../actual
531 test_expect_success
'test sparse status again with untracked cache and subdir' '
534 GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \
535 git status --porcelain >../status.actual &&
536 test_cmp ../status.expect ../status.actual &&
537 cat >../trace.expect <<EOF &&
539 gitignore invalidation: 0
540 directory invalidation: 0
543 test_cmp ../trace.expect ../trace
546 test_expect_success
'move entry in subdir from untracked to cached' '
548 git status --porcelain >../status.actual &&
549 cat >../status.expect <<EOF &&
556 test_cmp ../status.expect ../status.actual
559 test_expect_success
'move entry in subdir from cached to untracked' '
560 git rm --cached dtwo/two &&
561 git status --porcelain >../status.actual &&
562 cat >../status.expect <<EOF &&
569 test_cmp ../status.expect ../status.actual