3 test_description='test untracked cache'
11 git update-index --untracked-cache
12 # It's fine if git update-index returns an error code other than one,
13 # it'll be caught in the first test.
14 if test $? -eq 1; then
15 skip_all='This system does not support untracked cache'
19 test_expect_success 'setup' '
22 mkdir done dtwo dthree &&
23 touch one two three done/one dtwo/two dthree/three &&
24 git add one two done/one &&
25 : >.git/info/exclude &&
26 git update-index --untracked-cache
29 test_expect_success 'untracked cache is empty' '
30 test-dump-untracked-cache >../actual &&
31 cat >../expect <<EOF &&
32 info/exclude 0000000000000000000000000000000000000000
33 core.excludesfile 0000000000000000000000000000000000000000
34 exclude_per_dir .gitignore
37 test_cmp ../expect ../actual
40 cat >../status.expect <<EOF &&
49 cat >../dump.expect <<EOF &&
50 info/exclude e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
51 core.excludesfile 0000000000000000000000000000000000000000
52 exclude_per_dir .gitignore
54 / 0000000000000000000000000000000000000000 recurse valid
58 /done/ 0000000000000000000000000000000000000000 recurse valid
59 /dthree/ 0000000000000000000000000000000000000000 recurse check_only valid
61 /dtwo/ 0000000000000000000000000000000000000000 recurse check_only valid
65 test_expect_success 'status first time (empty cache)' '
68 GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \
69 git status --porcelain >../actual &&
70 test_cmp ../status.expect ../actual &&
71 cat >../trace.expect <<EOF &&
73 gitignore invalidation: 1
74 directory invalidation: 0
77 test_cmp ../trace.expect ../trace
80 test_expect_success 'untracked cache after first status' '
81 test-dump-untracked-cache >../actual &&
82 test_cmp ../dump.expect ../actual
85 test_expect_success 'status second time (fully populated cache)' '
88 GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \
89 git status --porcelain >../actual &&
90 test_cmp ../status.expect ../actual &&
91 cat >../trace.expect <<EOF &&
93 gitignore invalidation: 0
94 directory invalidation: 0
97 test_cmp ../trace.expect ../trace
100 test_expect_success 'untracked cache after second status' '
101 test-dump-untracked-cache >../actual &&
102 test_cmp ../dump.expect ../actual
105 test_expect_success 'modify in root directory, one dir invalidation' '
109 GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \
110 git status --porcelain >../actual &&
111 cat >../status.expect <<EOF &&
120 test_cmp ../status.expect ../actual &&
121 cat >../trace.expect <<EOF &&
123 gitignore invalidation: 0
124 directory invalidation: 1
127 test_cmp ../trace.expect ../trace
131 test_expect_success 'verify untracked cache dump' '
132 test-dump-untracked-cache >../actual &&
133 cat >../expect <<EOF &&
134 info/exclude e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
135 core.excludesfile 0000000000000000000000000000000000000000
136 exclude_per_dir .gitignore
138 / 0000000000000000000000000000000000000000 recurse valid
143 /done/ 0000000000000000000000000000000000000000 recurse valid
144 /dthree/ 0000000000000000000000000000000000000000 recurse check_only valid
146 /dtwo/ 0000000000000000000000000000000000000000 recurse check_only valid
149 test_cmp ../expect ../actual
152 test_expect_success 'new .gitignore invalidates recursively' '
154 echo four >.gitignore &&
156 GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \
157 git status --porcelain >../actual &&
158 cat >../status.expect <<EOF &&
167 test_cmp ../status.expect ../actual &&
168 cat >../trace.expect <<EOF &&
170 gitignore invalidation: 1
171 directory invalidation: 1
174 test_cmp ../trace.expect ../trace
178 test_expect_success 'verify untracked cache dump' '
179 test-dump-untracked-cache >../actual &&
180 cat >../expect <<EOF &&
181 info/exclude e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
182 core.excludesfile 0000000000000000000000000000000000000000
183 exclude_per_dir .gitignore
185 / e6fcc8f2ee31bae321d66afd183fcb7237afae6e recurse valid
190 /done/ 0000000000000000000000000000000000000000 recurse valid
191 /dthree/ 0000000000000000000000000000000000000000 recurse check_only valid
193 /dtwo/ 0000000000000000000000000000000000000000 recurse check_only valid
196 test_cmp ../expect ../actual
199 test_expect_success 'new info/exclude invalidates everything' '
201 echo three >>.git/info/exclude &&
203 GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \
204 git status --porcelain >../actual &&
205 cat >../status.expect <<EOF &&
212 test_cmp ../status.expect ../actual &&
213 cat >../trace.expect <<EOF &&
215 gitignore invalidation: 1
216 directory invalidation: 0
219 test_cmp ../trace.expect ../trace
222 test_expect_success 'verify untracked cache dump' '
223 test-dump-untracked-cache >../actual &&
224 cat >../expect <<EOF &&
225 info/exclude 13263c0978fb9fad16b2d580fb800b6d811c3ff0
226 core.excludesfile 0000000000000000000000000000000000000000
227 exclude_per_dir .gitignore
229 / e6fcc8f2ee31bae321d66afd183fcb7237afae6e recurse valid
232 /done/ 0000000000000000000000000000000000000000 recurse valid
233 /dthree/ 0000000000000000000000000000000000000000 recurse check_only valid
234 /dtwo/ 0000000000000000000000000000000000000000 recurse check_only valid
237 test_cmp ../expect ../actual
240 test_expect_success 'move two from tracked to untracked' '
241 git rm --cached two &&
242 test-dump-untracked-cache >../actual &&
243 cat >../expect <<EOF &&
244 info/exclude 13263c0978fb9fad16b2d580fb800b6d811c3ff0
245 core.excludesfile 0000000000000000000000000000000000000000
246 exclude_per_dir .gitignore
248 / e6fcc8f2ee31bae321d66afd183fcb7237afae6e recurse
249 /done/ 0000000000000000000000000000000000000000 recurse valid
250 /dthree/ 0000000000000000000000000000000000000000 recurse check_only valid
251 /dtwo/ 0000000000000000000000000000000000000000 recurse check_only valid
254 test_cmp ../expect ../actual
257 test_expect_success 'status after the move' '
259 GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \
260 git status --porcelain >../actual &&
261 cat >../status.expect <<EOF &&
268 test_cmp ../status.expect ../actual &&
269 cat >../trace.expect <<EOF &&
271 gitignore invalidation: 0
272 directory invalidation: 0
275 test_cmp ../trace.expect ../trace
278 test_expect_success 'verify untracked cache dump' '
279 test-dump-untracked-cache >../actual &&
280 cat >../expect <<EOF &&
281 info/exclude 13263c0978fb9fad16b2d580fb800b6d811c3ff0
282 core.excludesfile 0000000000000000000000000000000000000000
283 exclude_per_dir .gitignore
285 / e6fcc8f2ee31bae321d66afd183fcb7237afae6e recurse valid
289 /done/ 0000000000000000000000000000000000000000 recurse valid
290 /dthree/ 0000000000000000000000000000000000000000 recurse check_only valid
291 /dtwo/ 0000000000000000000000000000000000000000 recurse check_only valid
294 test_cmp ../expect ../actual
297 test_expect_success 'move two from untracked to tracked' '
299 test-dump-untracked-cache >../actual &&
300 cat >../expect <<EOF &&
301 info/exclude 13263c0978fb9fad16b2d580fb800b6d811c3ff0
302 core.excludesfile 0000000000000000000000000000000000000000
303 exclude_per_dir .gitignore
305 / e6fcc8f2ee31bae321d66afd183fcb7237afae6e recurse
306 /done/ 0000000000000000000000000000000000000000 recurse valid
307 /dthree/ 0000000000000000000000000000000000000000 recurse check_only valid
308 /dtwo/ 0000000000000000000000000000000000000000 recurse check_only valid
311 test_cmp ../expect ../actual
314 test_expect_success 'status after the move' '
316 GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \
317 git status --porcelain >../actual &&
318 cat >../status.expect <<EOF &&
325 test_cmp ../status.expect ../actual &&
326 cat >../trace.expect <<EOF &&
328 gitignore invalidation: 0
329 directory invalidation: 0
332 test_cmp ../trace.expect ../trace
335 test_expect_success 'verify untracked cache dump' '
336 test-dump-untracked-cache >../actual &&
337 cat >../expect <<EOF &&
338 info/exclude 13263c0978fb9fad16b2d580fb800b6d811c3ff0
339 core.excludesfile 0000000000000000000000000000000000000000
340 exclude_per_dir .gitignore
342 / e6fcc8f2ee31bae321d66afd183fcb7237afae6e recurse valid
345 /done/ 0000000000000000000000000000000000000000 recurse valid
346 /dthree/ 0000000000000000000000000000000000000000 recurse check_only valid
347 /dtwo/ 0000000000000000000000000000000000000000 recurse check_only valid
350 test_cmp ../expect ../actual