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