@matheusbsbs / matheus-bagliano / commits / ce5c61a3f5
Fork 0

t7063: more thorough status checking

It turns out the t7063 has some testcases that even without using the untracked cache cover situations that nothing else in the testsuite handles. Checking the results of git status --porcelain both with and without the untracked cache, and comparing both against our expected results helped uncover a critical bug in some dir.c restructuring. Unfortunately, it's not easy to run status and tell it to ignore the untracked cache; the only knob we have is core.untrackedCache=false, which is used to instruct git to *delete* the untracked cache (which might also ignore the untracked cache when it operates, but that isn't specified in the docs). Create a simple helper that will create a clone of the index that is missing the untracked cache bits, and use it to compare that the results with the untracked cache match the results we get without the untracked cache. Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Elijah Newren committed Apr 1, 2020 at 04:17 UTC ce5c61a3f52b48497898dbe4e535e725b1c45794
1 file changed +52
t/t7063-status-untracked-cache.sh
+52
@@ -30,6 +30,30 @@ status_is_clean() {
30 test_must_be_empty ../status.actual
31 }
32
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 +
57 test_lazy_prereq UNTRACKED_CACHE '
58 { git update-index --test-untracked-cache; ret=$?; } &&
59 test $ret -ne 1
@@ -95,6 +119,8 @@ test_expect_success 'status first time (empty cache)' '
119 : >../trace &&
120 GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \
121 git status --porcelain >../actual &&
122 + iuc status --porcelain >../status.iuc &&
123 + test_cmp ../status.expect ../status.iuc &&
124 test_cmp ../status.expect ../actual &&
125 cat >../trace.expect <<EOF &&
126 node creation: 3
@@ -115,6 +141,8 @@ test_expect_success 'status second time (fully populated cache)' '
141 : >../trace &&
142 GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \
143 git status --porcelain >../actual &&
144 + iuc status --porcelain >../status.iuc &&
145 + test_cmp ../status.expect ../status.iuc &&
146 test_cmp ../status.expect ../actual &&
147 cat >../trace.expect <<EOF &&
148 node creation: 0
@@ -136,6 +164,7 @@ test_expect_success 'modify in root directory, one dir invalidation' '
164 : >../trace &&
165 GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \
166 git status --porcelain >../actual &&
167 + iuc status --porcelain >../status.iuc &&
168 cat >../status.expect <<EOF &&
169 A done/one
170 A one
@@ -145,6 +174,7 @@ A two
174 ?? four
175 ?? three
176 EOF
177 + test_cmp ../status.expect ../status.iuc &&
178 test_cmp ../status.expect ../actual &&
179 cat >../trace.expect <<EOF &&
180 node creation: 0
@@ -183,6 +213,7 @@ test_expect_success 'new .gitignore invalidates recursively' '
213 : >../trace &&
214 GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \
215 git status --porcelain >../actual &&
216 + iuc status --porcelain >../status.iuc &&
217 cat >../status.expect <<EOF &&
218 A done/one
219 A one
@@ -192,6 +223,7 @@ A two
223 ?? dtwo/
224 ?? three
225 EOF
226 + test_cmp ../status.expect ../status.iuc &&
227 test_cmp ../status.expect ../actual &&
228 cat >../trace.expect <<EOF &&
229 node creation: 0
@@ -230,6 +262,7 @@ test_expect_success 'new info/exclude invalidates everything' '
262 : >../trace &&
263 GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \
264 git status --porcelain >../actual &&
265 + iuc status --porcelain >../status.iuc &&
266 cat >../status.expect <<EOF &&
267 A done/one
268 A one
@@ -237,6 +270,7 @@ A two
270 ?? .gitignore
271 ?? dtwo/
272 EOF
273 + test_cmp ../status.expect ../status.iuc &&
274 test_cmp ../status.expect ../actual &&
275 cat >../trace.expect <<EOF &&
276 node creation: 0
@@ -286,6 +320,7 @@ test_expect_success 'status after the move' '
320 : >../trace &&
321 GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \
322 git status --porcelain >../actual &&
323 + iuc status --porcelain >../status.iuc &&
324 cat >../status.expect <<EOF &&
325 A done/one
326 A one
@@ -293,6 +328,7 @@ A one
328 ?? dtwo/
329 ?? two
330 EOF
331 + test_cmp ../status.expect ../status.iuc &&
332 test_cmp ../status.expect ../actual &&
333 cat >../trace.expect <<EOF &&
334 node creation: 0
@@ -343,6 +379,7 @@ test_expect_success 'status after the move' '
379 : >../trace &&
380 GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \
381 git status --porcelain >../actual &&
382 + iuc status --porcelain >../status.iuc &&
383 cat >../status.expect <<EOF &&
384 A done/one
385 A one
@@ -350,6 +387,7 @@ A two
387 ?? .gitignore
388 ?? dtwo/
389 EOF
390 + test_cmp ../status.expect ../status.iuc &&
391 test_cmp ../status.expect ../actual &&
392 cat >../trace.expect <<EOF &&
393 node creation: 0
@@ -390,10 +428,12 @@ test_expect_success 'status after commit' '
428 : >../trace &&
429 GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \
430 git status --porcelain >../actual &&
431 + iuc status --porcelain >../status.iuc &&
432 cat >../status.expect <<EOF &&
433 ?? .gitignore
434 ?? dtwo/
435 EOF
436 + test_cmp ../status.expect ../status.iuc &&
437 test_cmp ../status.expect ../actual &&
438 cat >../trace.expect <<EOF &&
439 node creation: 0
@@ -447,12 +487,14 @@ test_expect_success 'test sparse status with untracked cache' '
487 avoid_racy &&
488 GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \
489 git status --porcelain >../status.actual &&
490 + iuc status --porcelain >../status.iuc &&
491 cat >../status.expect <<EOF &&
492 M done/two
493 ?? .gitignore
494 ?? done/five
495 ?? dtwo/
496 EOF
497 + test_cmp ../status.expect ../status.iuc &&
498 test_cmp ../status.expect ../status.actual &&
499 cat >../trace.expect <<EOF &&
500 node creation: 0
@@ -487,12 +529,14 @@ test_expect_success 'test sparse status again with untracked cache' '
529 : >../trace &&
530 GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \
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/
538 EOF
539 + test_cmp ../status.expect ../status.iuc &&
540 test_cmp ../status.expect ../status.actual &&
541 cat >../trace.expect <<EOF &&
542 node creation: 0
@@ -514,6 +558,7 @@ test_expect_success 'test sparse status with untracked cache and subdir' '
558 : >../trace &&
559 GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \
560 git status --porcelain >../status.actual &&
561 + iuc status --porcelain >../status.iuc &&
562 cat >../status.expect <<EOF &&
563 M done/two
564 ?? .gitignore
@@ -521,6 +566,7 @@ test_expect_success 'test sparse status with untracked cache and subdir' '
566 ?? done/sub/
567 ?? dtwo/
568 EOF
569 + test_cmp ../status.expect ../status.iuc &&
570 test_cmp ../status.expect ../status.actual &&
571 cat >../trace.expect <<EOF &&
572 node creation: 2
@@ -560,6 +606,8 @@ test_expect_success 'test sparse status again with untracked cache and subdir' '
606 : >../trace &&
607 GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \
608 git status --porcelain >../status.actual &&
609 + iuc status --porcelain >../status.iuc &&
610 + test_cmp ../status.expect ../status.iuc &&
611 test_cmp ../status.expect ../status.actual &&
612 cat >../trace.expect <<EOF &&
613 node creation: 0
@@ -573,6 +621,7 @@ EOF
621 test_expect_success 'move entry in subdir from untracked to cached' '
622 git add dtwo/two &&
623 git status --porcelain >../status.actual &&
624 + iuc status --porcelain >../status.iuc &&
625 cat >../status.expect <<EOF &&
626 M done/two
627 A dtwo/two
@@ -580,12 +629,14 @@ A dtwo/two
629 ?? done/five
630 ?? done/sub/
631 EOF
632 + test_cmp ../status.expect ../status.iuc &&
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 &&
639 + iuc status --porcelain >../status.iuc &&
640 cat >../status.expect <<EOF &&
641 M done/two
642 ?? .gitignore
@@ -593,6 +644,7 @@ test_expect_success 'move entry in subdir from cached to untracked' '
644 ?? done/sub/
645 ?? dtwo/
646 EOF
647 + test_cmp ../status.expect ../status.iuc &&
648 test_cmp ../status.expect ../status.actual
649 '
650