]> git.ipfire.org Git - thirdparty/git.git/blame - t/t7063-status-untracked-cache.sh
path.c: don't call the match function without value in trie_find()
[thirdparty/git.git] / t / t7063-status-untracked-cache.sh
CommitLineData
a3ddcefd
NTND
1#!/bin/sh
2
3test_description='test untracked cache'
4
5. ./test-lib.sh
6
6b7728db
NTND
7# On some filesystems (e.g. FreeBSD's ext2 and ufs) directory mtime
8# is updated lazily after contents in the directory changes, which
9# forces the untracked cache code to take the slow path. A test
10# that wants to make sure that the fast path works correctly should
11# call this helper to make mtime of the containing directory in sync
12# with the reality before checking the fast path behaviour.
13#
14# See <20160803174522.5571-1-pclouds@gmail.com> if you want to know
15# more.
16
026336cb
JH
17GIT_FORCE_UNTRACKED_CACHE=true
18export GIT_FORCE_UNTRACKED_CACHE
fc9ecbeb 19
6b7728db
NTND
20sync_mtime () {
21 find . -type d -ls >/dev/null
22}
23
a3ddcefd
NTND
24avoid_racy() {
25 sleep 1
26}
27
ce0330ca 28status_is_clean() {
ce0330ca 29 git status --porcelain >../status.actual &&
d3c6751b 30 test_must_be_empty ../status.actual
ce0330ca
ÆAB
31}
32
fa73a582 33test_lazy_prereq UNTRACKED_CACHE '
435ec090 34 { git update-index --test-untracked-cache; ret=$?; } &&
fa73a582
JK
35 test $ret -ne 1
36'
37
38if ! test_have_prereq UNTRACKED_CACHE; then
a3ddcefd
NTND
39 skip_all='This system does not support untracked cache'
40 test_done
41fi
42
7c121788
CC
43test_expect_success 'core.untrackedCache is unset' '
44 test_must_fail git config --get core.untrackedCache
45'
46
a3ddcefd
NTND
47test_expect_success 'setup' '
48 git init worktree &&
49 cd worktree &&
50 mkdir done dtwo dthree &&
51 touch one two three done/one dtwo/two dthree/three &&
52 git add one two done/one &&
53 : >.git/info/exclude &&
54 git update-index --untracked-cache
55'
56
57test_expect_success 'untracked cache is empty' '
cd780f0b 58 test-tool dump-untracked-cache >../actual &&
7c121788 59 cat >../expect-empty <<EOF &&
a3ddcefd
NTND
60info/exclude 0000000000000000000000000000000000000000
61core.excludesfile 0000000000000000000000000000000000000000
62exclude_per_dir .gitignore
63flags 00000006
64EOF
7c121788 65 test_cmp ../expect-empty ../actual
a3ddcefd
NTND
66'
67
68cat >../status.expect <<EOF &&
69A done/one
70A one
71A two
72?? dthree/
73?? dtwo/
74?? three
75EOF
76
77cat >../dump.expect <<EOF &&
378932d3 78info/exclude $EMPTY_BLOB
a3ddcefd
NTND
79core.excludesfile 0000000000000000000000000000000000000000
80exclude_per_dir .gitignore
81flags 00000006
82/ 0000000000000000000000000000000000000000 recurse valid
83dthree/
84dtwo/
85three
86/done/ 0000000000000000000000000000000000000000 recurse valid
87/dthree/ 0000000000000000000000000000000000000000 recurse check_only valid
88three
89/dtwo/ 0000000000000000000000000000000000000000 recurse check_only valid
90two
91EOF
92
93test_expect_success 'status first time (empty cache)' '
94 avoid_racy &&
95 : >../trace &&
96 GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \
97 git status --porcelain >../actual &&
98 test_cmp ../status.expect ../actual &&
99 cat >../trace.expect <<EOF &&
100node creation: 3
101gitignore invalidation: 1
102directory invalidation: 0
103opendir: 4
104EOF
105 test_cmp ../trace.expect ../trace
106'
107
108test_expect_success 'untracked cache after first status' '
cd780f0b 109 test-tool dump-untracked-cache >../actual &&
a3ddcefd
NTND
110 test_cmp ../dump.expect ../actual
111'
112
113test_expect_success 'status second time (fully populated cache)' '
114 avoid_racy &&
115 : >../trace &&
116 GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \
117 git status --porcelain >../actual &&
118 test_cmp ../status.expect ../actual &&
119 cat >../trace.expect <<EOF &&
120node creation: 0
121gitignore invalidation: 0
122directory invalidation: 0
123opendir: 0
124EOF
125 test_cmp ../trace.expect ../trace
126'
127
128test_expect_success 'untracked cache after second status' '
cd780f0b 129 test-tool dump-untracked-cache >../actual &&
a3ddcefd
NTND
130 test_cmp ../dump.expect ../actual
131'
132
133test_expect_success 'modify in root directory, one dir invalidation' '
134 avoid_racy &&
135 : >four &&
136 : >../trace &&
137 GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \
138 git status --porcelain >../actual &&
139 cat >../status.expect <<EOF &&
140A done/one
141A one
142A two
143?? dthree/
144?? dtwo/
145?? four
146?? three
147EOF
148 test_cmp ../status.expect ../actual &&
149 cat >../trace.expect <<EOF &&
150node creation: 0
151gitignore invalidation: 0
152directory invalidation: 1
153opendir: 1
154EOF
155 test_cmp ../trace.expect ../trace
156
157'
158
159test_expect_success 'verify untracked cache dump' '
cd780f0b 160 test-tool dump-untracked-cache >../actual &&
a3ddcefd 161 cat >../expect <<EOF &&
378932d3 162info/exclude $EMPTY_BLOB
a3ddcefd
NTND
163core.excludesfile 0000000000000000000000000000000000000000
164exclude_per_dir .gitignore
165flags 00000006
166/ 0000000000000000000000000000000000000000 recurse valid
167dthree/
168dtwo/
169four
170three
171/done/ 0000000000000000000000000000000000000000 recurse valid
172/dthree/ 0000000000000000000000000000000000000000 recurse check_only valid
173three
174/dtwo/ 0000000000000000000000000000000000000000 recurse check_only valid
175two
176EOF
177 test_cmp ../expect ../actual
178'
179
180test_expect_success 'new .gitignore invalidates recursively' '
181 avoid_racy &&
182 echo four >.gitignore &&
183 : >../trace &&
184 GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \
185 git status --porcelain >../actual &&
186 cat >../status.expect <<EOF &&
187A done/one
188A one
189A two
190?? .gitignore
191?? dthree/
192?? dtwo/
193?? three
194EOF
195 test_cmp ../status.expect ../actual &&
196 cat >../trace.expect <<EOF &&
197node creation: 0
198gitignore invalidation: 1
199directory invalidation: 1
200opendir: 4
201EOF
202 test_cmp ../trace.expect ../trace
203
204'
205
206test_expect_success 'verify untracked cache dump' '
cd780f0b 207 test-tool dump-untracked-cache >../actual &&
a3ddcefd 208 cat >../expect <<EOF &&
378932d3 209info/exclude $EMPTY_BLOB
a3ddcefd
NTND
210core.excludesfile 0000000000000000000000000000000000000000
211exclude_per_dir .gitignore
212flags 00000006
213/ e6fcc8f2ee31bae321d66afd183fcb7237afae6e recurse valid
214.gitignore
215dthree/
216dtwo/
217three
218/done/ 0000000000000000000000000000000000000000 recurse valid
219/dthree/ 0000000000000000000000000000000000000000 recurse check_only valid
220three
221/dtwo/ 0000000000000000000000000000000000000000 recurse check_only valid
222two
223EOF
224 test_cmp ../expect ../actual
225'
226
227test_expect_success 'new info/exclude invalidates everything' '
228 avoid_racy &&
229 echo three >>.git/info/exclude &&
230 : >../trace &&
231 GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \
232 git status --porcelain >../actual &&
233 cat >../status.expect <<EOF &&
234A done/one
235A one
236A two
237?? .gitignore
238?? dtwo/
239EOF
240 test_cmp ../status.expect ../actual &&
241 cat >../trace.expect <<EOF &&
242node creation: 0
243gitignore invalidation: 1
244directory invalidation: 0
245opendir: 4
246EOF
247 test_cmp ../trace.expect ../trace
248'
249
250test_expect_success 'verify untracked cache dump' '
cd780f0b 251 test-tool dump-untracked-cache >../actual &&
a3ddcefd
NTND
252 cat >../expect <<EOF &&
253info/exclude 13263c0978fb9fad16b2d580fb800b6d811c3ff0
254core.excludesfile 0000000000000000000000000000000000000000
255exclude_per_dir .gitignore
256flags 00000006
257/ e6fcc8f2ee31bae321d66afd183fcb7237afae6e recurse valid
258.gitignore
259dtwo/
260/done/ 0000000000000000000000000000000000000000 recurse valid
261/dthree/ 0000000000000000000000000000000000000000 recurse check_only valid
262/dtwo/ 0000000000000000000000000000000000000000 recurse check_only valid
263two
264EOF
265 test_cmp ../expect ../actual
266'
267
268test_expect_success 'move two from tracked to untracked' '
269 git rm --cached two &&
cd780f0b 270 test-tool dump-untracked-cache >../actual &&
a3ddcefd
NTND
271 cat >../expect <<EOF &&
272info/exclude 13263c0978fb9fad16b2d580fb800b6d811c3ff0
273core.excludesfile 0000000000000000000000000000000000000000
274exclude_per_dir .gitignore
275flags 00000006
276/ e6fcc8f2ee31bae321d66afd183fcb7237afae6e recurse
277/done/ 0000000000000000000000000000000000000000 recurse valid
278/dthree/ 0000000000000000000000000000000000000000 recurse check_only valid
279/dtwo/ 0000000000000000000000000000000000000000 recurse check_only valid
280two
281EOF
282 test_cmp ../expect ../actual
283'
284
285test_expect_success 'status after the move' '
286 : >../trace &&
287 GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \
288 git status --porcelain >../actual &&
289 cat >../status.expect <<EOF &&
290A done/one
291A one
292?? .gitignore
293?? dtwo/
294?? two
295EOF
296 test_cmp ../status.expect ../actual &&
297 cat >../trace.expect <<EOF &&
298node creation: 0
299gitignore invalidation: 0
300directory invalidation: 0
301opendir: 1
302EOF
303 test_cmp ../trace.expect ../trace
304'
305
306test_expect_success 'verify untracked cache dump' '
cd780f0b 307 test-tool dump-untracked-cache >../actual &&
a3ddcefd
NTND
308 cat >../expect <<EOF &&
309info/exclude 13263c0978fb9fad16b2d580fb800b6d811c3ff0
310core.excludesfile 0000000000000000000000000000000000000000
311exclude_per_dir .gitignore
312flags 00000006
313/ e6fcc8f2ee31bae321d66afd183fcb7237afae6e recurse valid
314.gitignore
315dtwo/
316two
317/done/ 0000000000000000000000000000000000000000 recurse valid
318/dthree/ 0000000000000000000000000000000000000000 recurse check_only valid
319/dtwo/ 0000000000000000000000000000000000000000 recurse check_only valid
320two
321EOF
322 test_cmp ../expect ../actual
323'
324
325test_expect_success 'move two from untracked to tracked' '
326 git add two &&
cd780f0b 327 test-tool dump-untracked-cache >../actual &&
a3ddcefd
NTND
328 cat >../expect <<EOF &&
329info/exclude 13263c0978fb9fad16b2d580fb800b6d811c3ff0
330core.excludesfile 0000000000000000000000000000000000000000
331exclude_per_dir .gitignore
332flags 00000006
333/ e6fcc8f2ee31bae321d66afd183fcb7237afae6e recurse
334/done/ 0000000000000000000000000000000000000000 recurse valid
335/dthree/ 0000000000000000000000000000000000000000 recurse check_only valid
336/dtwo/ 0000000000000000000000000000000000000000 recurse check_only valid
337two
338EOF
339 test_cmp ../expect ../actual
340'
341
342test_expect_success 'status after the move' '
343 : >../trace &&
344 GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \
345 git status --porcelain >../actual &&
346 cat >../status.expect <<EOF &&
347A done/one
348A one
349A two
350?? .gitignore
351?? dtwo/
352EOF
353 test_cmp ../status.expect ../actual &&
354 cat >../trace.expect <<EOF &&
355node creation: 0
356gitignore invalidation: 0
357directory invalidation: 0
358opendir: 1
359EOF
360 test_cmp ../trace.expect ../trace
361'
362
363test_expect_success 'verify untracked cache dump' '
cd780f0b 364 test-tool dump-untracked-cache >../actual &&
a3ddcefd
NTND
365 cat >../expect <<EOF &&
366info/exclude 13263c0978fb9fad16b2d580fb800b6d811c3ff0
367core.excludesfile 0000000000000000000000000000000000000000
368exclude_per_dir .gitignore
369flags 00000006
370/ e6fcc8f2ee31bae321d66afd183fcb7237afae6e recurse valid
371.gitignore
372dtwo/
373/done/ 0000000000000000000000000000000000000000 recurse valid
374/dthree/ 0000000000000000000000000000000000000000 recurse check_only valid
375/dtwo/ 0000000000000000000000000000000000000000 recurse check_only valid
376two
377EOF
378 test_cmp ../expect ../actual
379'
380
7687252f
DT
381test_expect_success 'set up for sparse checkout testing' '
382 echo two >done/.gitignore &&
383 echo three >>done/.gitignore &&
384 echo two >done/two &&
385 git add -f done/two done/.gitignore &&
386 git commit -m "first commit"
387'
388
389test_expect_success 'status after commit' '
390 : >../trace &&
391 GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \
392 git status --porcelain >../actual &&
393 cat >../status.expect <<EOF &&
394?? .gitignore
395?? dtwo/
396EOF
397 test_cmp ../status.expect ../actual &&
398 cat >../trace.expect <<EOF &&
399node creation: 0
400gitignore invalidation: 0
401directory invalidation: 0
73f9145f 402opendir: 2
7687252f
DT
403EOF
404 test_cmp ../trace.expect ../trace
405'
406
407test_expect_success 'untracked cache correct after commit' '
cd780f0b 408 test-tool dump-untracked-cache >../actual &&
7687252f
DT
409 cat >../expect <<EOF &&
410info/exclude 13263c0978fb9fad16b2d580fb800b6d811c3ff0
411core.excludesfile 0000000000000000000000000000000000000000
412exclude_per_dir .gitignore
413flags 00000006
414/ e6fcc8f2ee31bae321d66afd183fcb7237afae6e recurse valid
415.gitignore
416dtwo/
417/done/ 0000000000000000000000000000000000000000 recurse valid
418/dthree/ 0000000000000000000000000000000000000000 recurse check_only valid
419/dtwo/ 0000000000000000000000000000000000000000 recurse check_only valid
420two
421EOF
422 test_cmp ../expect ../actual
423'
424
425test_expect_success 'set up sparse checkout' '
426 echo "done/[a-z]*" >.git/info/sparse-checkout &&
427 test_config core.sparsecheckout true &&
428 git checkout master &&
f178136e 429 git update-index --force-untracked-cache &&
7687252f
DT
430 git status --porcelain >/dev/null && # prime the cache
431 test_path_is_missing done/.gitignore &&
432 test_path_is_file done/one
433'
434
2e5910f2
DT
435test_expect_success 'create/modify files, some of which are gitignored' '
436 echo two bis >done/two &&
7687252f
DT
437 echo three >done/three && # three is gitignored
438 echo four >done/four && # four is gitignored at a higher level
9b680fbd
DT
439 echo five >done/five && # five is not gitignored
440 echo test >base && #we need to ensure that the root dir is touched
6b7728db
NTND
441 rm base &&
442 sync_mtime
7687252f
DT
443'
444
445test_expect_success 'test sparse status with untracked cache' '
446 : >../trace &&
447 avoid_racy &&
448 GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \
449 git status --porcelain >../status.actual &&
450 cat >../status.expect <<EOF &&
2e5910f2 451 M done/two
7687252f
DT
452?? .gitignore
453?? done/five
454?? dtwo/
455EOF
456 test_cmp ../status.expect ../status.actual &&
457 cat >../trace.expect <<EOF &&
458node creation: 0
459gitignore invalidation: 1
460directory invalidation: 2
461opendir: 2
462EOF
463 test_cmp ../trace.expect ../trace
464'
465
466test_expect_success 'untracked cache correct after status' '
cd780f0b 467 test-tool dump-untracked-cache >../actual &&
7687252f
DT
468 cat >../expect <<EOF &&
469info/exclude 13263c0978fb9fad16b2d580fb800b6d811c3ff0
470core.excludesfile 0000000000000000000000000000000000000000
471exclude_per_dir .gitignore
472flags 00000006
473/ e6fcc8f2ee31bae321d66afd183fcb7237afae6e recurse valid
474.gitignore
475dtwo/
476/done/ 1946f0437f90c5005533cbe1736a6451ca301714 recurse valid
477five
478/dthree/ 0000000000000000000000000000000000000000 recurse check_only valid
479/dtwo/ 0000000000000000000000000000000000000000 recurse check_only valid
480two
481EOF
482 test_cmp ../expect ../actual
483'
484
485test_expect_success 'test sparse status again with untracked cache' '
486 avoid_racy &&
487 : >../trace &&
488 GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \
489 git status --porcelain >../status.actual &&
490 cat >../status.expect <<EOF &&
2e5910f2 491 M done/two
7687252f
DT
492?? .gitignore
493?? done/five
494?? dtwo/
495EOF
496 test_cmp ../status.expect ../status.actual &&
497 cat >../trace.expect <<EOF &&
498node creation: 0
499gitignore invalidation: 0
500directory invalidation: 0
501opendir: 0
502EOF
503 test_cmp ../trace.expect ../trace
504'
505
2e5910f2
DT
506test_expect_success 'set up for test of subdir and sparse checkouts' '
507 mkdir done/sub &&
508 mkdir done/sub/sub &&
509 echo "sub" > done/sub/sub/file
510'
511
512test_expect_success 'test sparse status with untracked cache and subdir' '
513 avoid_racy &&
514 : >../trace &&
515 GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \
516 git status --porcelain >../status.actual &&
517 cat >../status.expect <<EOF &&
518 M done/two
519?? .gitignore
520?? done/five
521?? done/sub/
522?? dtwo/
523EOF
524 test_cmp ../status.expect ../status.actual &&
525 cat >../trace.expect <<EOF &&
526node creation: 2
527gitignore invalidation: 0
528directory invalidation: 1
529opendir: 3
530EOF
531 test_cmp ../trace.expect ../trace
532'
533
534test_expect_success 'verify untracked cache dump (sparse/subdirs)' '
cd780f0b 535 test-tool dump-untracked-cache >../actual &&
7c121788 536 cat >../expect-from-test-dump <<EOF &&
2e5910f2
DT
537info/exclude 13263c0978fb9fad16b2d580fb800b6d811c3ff0
538core.excludesfile 0000000000000000000000000000000000000000
539exclude_per_dir .gitignore
540flags 00000006
541/ e6fcc8f2ee31bae321d66afd183fcb7237afae6e recurse valid
542.gitignore
543dtwo/
544/done/ 1946f0437f90c5005533cbe1736a6451ca301714 recurse valid
545five
546sub/
547/done/sub/ 0000000000000000000000000000000000000000 recurse check_only valid
548sub/
549/done/sub/sub/ 0000000000000000000000000000000000000000 recurse check_only valid
550file
551/dthree/ 0000000000000000000000000000000000000000 recurse check_only valid
552/dtwo/ 0000000000000000000000000000000000000000 recurse check_only valid
553two
554EOF
7c121788 555 test_cmp ../expect-from-test-dump ../actual
2e5910f2
DT
556'
557
558test_expect_success 'test sparse status again with untracked cache and subdir' '
559 avoid_racy &&
560 : >../trace &&
561 GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \
562 git status --porcelain >../status.actual &&
563 test_cmp ../status.expect ../status.actual &&
564 cat >../trace.expect <<EOF &&
565node creation: 0
566gitignore invalidation: 0
567directory invalidation: 0
568opendir: 0
569EOF
570 test_cmp ../trace.expect ../trace
571'
572
73f9145f
NTND
573test_expect_success 'move entry in subdir from untracked to cached' '
574 git add dtwo/two &&
575 git status --porcelain >../status.actual &&
576 cat >../status.expect <<EOF &&
577 M done/two
578A dtwo/two
579?? .gitignore
580?? done/five
581?? done/sub/
582EOF
583 test_cmp ../status.expect ../status.actual
584'
585
586test_expect_success 'move entry in subdir from cached to untracked' '
587 git rm --cached dtwo/two &&
588 git status --porcelain >../status.actual &&
589 cat >../status.expect <<EOF &&
590 M done/two
591?? .gitignore
592?? done/five
593?? done/sub/
594?? dtwo/
595EOF
596 test_cmp ../status.expect ../status.actual
597'
598
7c121788
CC
599test_expect_success '--no-untracked-cache removes the cache' '
600 git update-index --no-untracked-cache &&
cd780f0b 601 test-tool dump-untracked-cache >../actual &&
7c121788
CC
602 echo "no untracked cache" >../expect-no-uc &&
603 test_cmp ../expect-no-uc ../actual
604'
605
606test_expect_success 'git status does not change anything' '
607 git status &&
cd780f0b 608 test-tool dump-untracked-cache >../actual &&
7c121788
CC
609 test_cmp ../expect-no-uc ../actual
610'
611
612test_expect_success 'setting core.untrackedCache to true and using git status creates the cache' '
613 git config core.untrackedCache true &&
cd780f0b 614 test-tool dump-untracked-cache >../actual &&
7c121788
CC
615 test_cmp ../expect-no-uc ../actual &&
616 git status &&
cd780f0b 617 test-tool dump-untracked-cache >../actual &&
7c121788
CC
618 test_cmp ../expect-from-test-dump ../actual
619'
620
621test_expect_success 'using --no-untracked-cache does not fail when core.untrackedCache is true' '
622 git update-index --no-untracked-cache &&
cd780f0b 623 test-tool dump-untracked-cache >../actual &&
7c121788
CC
624 test_cmp ../expect-no-uc ../actual &&
625 git update-index --untracked-cache &&
cd780f0b 626 test-tool dump-untracked-cache >../actual &&
7c121788
CC
627 test_cmp ../expect-empty ../actual
628'
629
630test_expect_success 'setting core.untrackedCache to false and using git status removes the cache' '
631 git config core.untrackedCache false &&
cd780f0b 632 test-tool dump-untracked-cache >../actual &&
7c121788
CC
633 test_cmp ../expect-empty ../actual &&
634 git status &&
cd780f0b 635 test-tool dump-untracked-cache >../actual &&
7c121788
CC
636 test_cmp ../expect-no-uc ../actual
637'
638
639test_expect_success 'using --untracked-cache does not fail when core.untrackedCache is false' '
640 git update-index --untracked-cache &&
cd780f0b 641 test-tool dump-untracked-cache >../actual &&
7c121788
CC
642 test_cmp ../expect-empty ../actual
643'
644
645test_expect_success 'setting core.untrackedCache to keep' '
646 git config core.untrackedCache keep &&
647 git update-index --untracked-cache &&
cd780f0b 648 test-tool dump-untracked-cache >../actual &&
7c121788
CC
649 test_cmp ../expect-empty ../actual &&
650 git status &&
cd780f0b 651 test-tool dump-untracked-cache >../actual &&
7c121788
CC
652 test_cmp ../expect-from-test-dump ../actual &&
653 git update-index --no-untracked-cache &&
cd780f0b 654 test-tool dump-untracked-cache >../actual &&
7c121788
CC
655 test_cmp ../expect-no-uc ../actual &&
656 git update-index --force-untracked-cache &&
cd780f0b 657 test-tool dump-untracked-cache >../actual &&
7c121788
CC
658 test_cmp ../expect-empty ../actual &&
659 git status &&
cd780f0b 660 test-tool dump-untracked-cache >../actual &&
7c121788
CC
661 test_cmp ../expect-from-test-dump ../actual
662'
663
664test_expect_success 'test ident field is working' '
665 mkdir ../other_worktree &&
666 cp -R done dthree dtwo four three ../other_worktree &&
667 GIT_WORK_TREE=../other_worktree git status 2>../err &&
1a07e59c 668 echo "warning: untracked cache is disabled on this system or location" >../expect &&
1edbaac3 669 test_i18ncmp ../expect ../err
7c121788
CC
670'
671
edf3b905
DT
672test_expect_success 'untracked cache survives a checkout' '
673 git commit --allow-empty -m empty &&
cd780f0b 674 test-tool dump-untracked-cache >../before &&
edf3b905
DT
675 test_when_finished "git checkout master" &&
676 git checkout -b other_branch &&
cd780f0b 677 test-tool dump-untracked-cache >../after &&
edf3b905
DT
678 test_cmp ../before ../after &&
679 test_commit test &&
cd780f0b 680 test-tool dump-untracked-cache >../before &&
edf3b905 681 git checkout master &&
cd780f0b 682 test-tool dump-untracked-cache >../after &&
edf3b905
DT
683 test_cmp ../before ../after
684'
685
686test_expect_success 'untracked cache survives a commit' '
cd780f0b 687 test-tool dump-untracked-cache >../before &&
edf3b905
DT
688 git add done/two &&
689 git commit -m commit &&
cd780f0b 690 test-tool dump-untracked-cache >../after &&
edf3b905
DT
691 test_cmp ../before ../after
692'
693
ce0330ca
ÆAB
694test_expect_success 'teardown worktree' '
695 cd ..
696'
697
698test_expect_success SYMLINKS 'setup worktree for symlink test' '
699 git init worktree-symlink &&
700 cd worktree-symlink &&
701 git config core.untrackedCache true &&
702 mkdir one two &&
703 touch one/file two/file &&
704 git add one/file two/file &&
705 git commit -m"first commit" &&
706 git rm -rf one &&
707 ln -s two one &&
708 git add one &&
709 git commit -m"second commit"
710'
711
b6403131 712test_expect_success SYMLINKS '"status" after symlink replacement should be clean with UC=true' '
ce0330ca
ÆAB
713 git checkout HEAD~ &&
714 status_is_clean &&
715 status_is_clean &&
716 git checkout master &&
717 avoid_racy &&
718 status_is_clean &&
719 status_is_clean
720'
721
722test_expect_success SYMLINKS '"status" after symlink replacement should be clean with UC=false' '
723 git config core.untrackedCache false &&
724 git checkout HEAD~ &&
725 status_is_clean &&
726 status_is_clean &&
727 git checkout master &&
728 avoid_racy &&
729 status_is_clean &&
730 status_is_clean
731'
732
733test_expect_success 'setup worktree for non-symlink test' '
734 git init worktree-non-symlink &&
735 cd worktree-non-symlink &&
736 git config core.untrackedCache true &&
737 mkdir one two &&
738 touch one/file two/file &&
739 git add one/file two/file &&
740 git commit -m"first commit" &&
741 git rm -rf one &&
742 cp two/file one &&
743 git add one &&
744 git commit -m"second commit"
745'
746
b6403131 747test_expect_success '"status" after file replacement should be clean with UC=true' '
ce0330ca
ÆAB
748 git checkout HEAD~ &&
749 status_is_clean &&
750 status_is_clean &&
751 git checkout master &&
752 avoid_racy &&
753 status_is_clean &&
cd780f0b 754 test-tool dump-untracked-cache >../actual &&
ce0330ca
ÆAB
755 grep -F "recurse valid" ../actual >../actual.grep &&
756 cat >../expect.grep <<EOF &&
757/ 0000000000000000000000000000000000000000 recurse valid
758/two/ 0000000000000000000000000000000000000000 recurse valid
759EOF
760 status_is_clean &&
761 test_cmp ../expect.grep ../actual.grep
762'
763
764test_expect_success '"status" after file replacement should be clean with UC=false' '
765 git config core.untrackedCache false &&
766 git checkout HEAD~ &&
767 status_is_clean &&
768 status_is_clean &&
769 git checkout master &&
770 avoid_racy &&
771 status_is_clean &&
772 status_is_clean
773'
774
a3ddcefd 775test_done