Skip to content

Commit ce5c61a

Browse files
newrengitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0822e66 commit ce5c61a

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

t/t7063-status-untracked-cache.sh

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,30 @@ status_is_clean() {
3030
test_must_be_empty ../status.actual
3131
}
3232

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+
3357
test_lazy_prereq UNTRACKED_CACHE '
3458
{ git update-index --test-untracked-cache; ret=$?; } &&
3559
test $ret -ne 1
@@ -95,6 +119,8 @@ test_expect_success 'status first time (empty cache)' '
95119
: >../trace &&
96120
GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \
97121
git status --porcelain >../actual &&
122+
iuc status --porcelain >../status.iuc &&
123+
test_cmp ../status.expect ../status.iuc &&
98124
test_cmp ../status.expect ../actual &&
99125
cat >../trace.expect <<EOF &&
100126
node creation: 3
@@ -115,6 +141,8 @@ test_expect_success 'status second time (fully populated cache)' '
115141
: >../trace &&
116142
GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \
117143
git status --porcelain >../actual &&
144+
iuc status --porcelain >../status.iuc &&
145+
test_cmp ../status.expect ../status.iuc &&
118146
test_cmp ../status.expect ../actual &&
119147
cat >../trace.expect <<EOF &&
120148
node creation: 0
@@ -136,6 +164,7 @@ test_expect_success 'modify in root directory, one dir invalidation' '
136164
: >../trace &&
137165
GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \
138166
git status --porcelain >../actual &&
167+
iuc status --porcelain >../status.iuc &&
139168
cat >../status.expect <<EOF &&
140169
A done/one
141170
A one
@@ -145,6 +174,7 @@ A two
145174
?? four
146175
?? three
147176
EOF
177+
test_cmp ../status.expect ../status.iuc &&
148178
test_cmp ../status.expect ../actual &&
149179
cat >../trace.expect <<EOF &&
150180
node creation: 0
@@ -183,6 +213,7 @@ test_expect_success 'new .gitignore invalidates recursively' '
183213
: >../trace &&
184214
GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \
185215
git status --porcelain >../actual &&
216+
iuc status --porcelain >../status.iuc &&
186217
cat >../status.expect <<EOF &&
187218
A done/one
188219
A one
@@ -192,6 +223,7 @@ A two
192223
?? dtwo/
193224
?? three
194225
EOF
226+
test_cmp ../status.expect ../status.iuc &&
195227
test_cmp ../status.expect ../actual &&
196228
cat >../trace.expect <<EOF &&
197229
node creation: 0
@@ -230,13 +262,15 @@ test_expect_success 'new info/exclude invalidates everything' '
230262
: >../trace &&
231263
GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \
232264
git status --porcelain >../actual &&
265+
iuc status --porcelain >../status.iuc &&
233266
cat >../status.expect <<EOF &&
234267
A done/one
235268
A one
236269
A two
237270
?? .gitignore
238271
?? dtwo/
239272
EOF
273+
test_cmp ../status.expect ../status.iuc &&
240274
test_cmp ../status.expect ../actual &&
241275
cat >../trace.expect <<EOF &&
242276
node creation: 0
@@ -286,13 +320,15 @@ test_expect_success 'status after the move' '
286320
: >../trace &&
287321
GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \
288322
git status --porcelain >../actual &&
323+
iuc status --porcelain >../status.iuc &&
289324
cat >../status.expect <<EOF &&
290325
A done/one
291326
A one
292327
?? .gitignore
293328
?? dtwo/
294329
?? two
295330
EOF
331+
test_cmp ../status.expect ../status.iuc &&
296332
test_cmp ../status.expect ../actual &&
297333
cat >../trace.expect <<EOF &&
298334
node creation: 0
@@ -343,13 +379,15 @@ test_expect_success 'status after the move' '
343379
: >../trace &&
344380
GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \
345381
git status --porcelain >../actual &&
382+
iuc status --porcelain >../status.iuc &&
346383
cat >../status.expect <<EOF &&
347384
A done/one
348385
A one
349386
A two
350387
?? .gitignore
351388
?? dtwo/
352389
EOF
390+
test_cmp ../status.expect ../status.iuc &&
353391
test_cmp ../status.expect ../actual &&
354392
cat >../trace.expect <<EOF &&
355393
node creation: 0
@@ -390,10 +428,12 @@ test_expect_success 'status after commit' '
390428
: >../trace &&
391429
GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \
392430
git status --porcelain >../actual &&
431+
iuc status --porcelain >../status.iuc &&
393432
cat >../status.expect <<EOF &&
394433
?? .gitignore
395434
?? dtwo/
396435
EOF
436+
test_cmp ../status.expect ../status.iuc &&
397437
test_cmp ../status.expect ../actual &&
398438
cat >../trace.expect <<EOF &&
399439
node creation: 0
@@ -447,12 +487,14 @@ test_expect_success 'test sparse status with untracked cache' '
447487
avoid_racy &&
448488
GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \
449489
git status --porcelain >../status.actual &&
490+
iuc status --porcelain >../status.iuc &&
450491
cat >../status.expect <<EOF &&
451492
M done/two
452493
?? .gitignore
453494
?? done/five
454495
?? dtwo/
455496
EOF
497+
test_cmp ../status.expect ../status.iuc &&
456498
test_cmp ../status.expect ../status.actual &&
457499
cat >../trace.expect <<EOF &&
458500
node creation: 0
@@ -487,12 +529,14 @@ test_expect_success 'test sparse status again with untracked cache' '
487529
: >../trace &&
488530
GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \
489531
git status --porcelain >../status.actual &&
532+
iuc status --porcelain >../status.iuc &&
490533
cat >../status.expect <<EOF &&
491534
M done/two
492535
?? .gitignore
493536
?? done/five
494537
?? dtwo/
495538
EOF
539+
test_cmp ../status.expect ../status.iuc &&
496540
test_cmp ../status.expect ../status.actual &&
497541
cat >../trace.expect <<EOF &&
498542
node creation: 0
@@ -514,13 +558,15 @@ test_expect_success 'test sparse status with untracked cache and subdir' '
514558
: >../trace &&
515559
GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \
516560
git status --porcelain >../status.actual &&
561+
iuc status --porcelain >../status.iuc &&
517562
cat >../status.expect <<EOF &&
518563
M done/two
519564
?? .gitignore
520565
?? done/five
521566
?? done/sub/
522567
?? dtwo/
523568
EOF
569+
test_cmp ../status.expect ../status.iuc &&
524570
test_cmp ../status.expect ../status.actual &&
525571
cat >../trace.expect <<EOF &&
526572
node creation: 2
@@ -560,6 +606,8 @@ test_expect_success 'test sparse status again with untracked cache and subdir' '
560606
: >../trace &&
561607
GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \
562608
git status --porcelain >../status.actual &&
609+
iuc status --porcelain >../status.iuc &&
610+
test_cmp ../status.expect ../status.iuc &&
563611
test_cmp ../status.expect ../status.actual &&
564612
cat >../trace.expect <<EOF &&
565613
node creation: 0
@@ -573,26 +621,30 @@ EOF
573621
test_expect_success 'move entry in subdir from untracked to cached' '
574622
git add dtwo/two &&
575623
git status --porcelain >../status.actual &&
624+
iuc status --porcelain >../status.iuc &&
576625
cat >../status.expect <<EOF &&
577626
M done/two
578627
A dtwo/two
579628
?? .gitignore
580629
?? done/five
581630
?? done/sub/
582631
EOF
632+
test_cmp ../status.expect ../status.iuc &&
583633
test_cmp ../status.expect ../status.actual
584634
'
585635

586636
test_expect_success 'move entry in subdir from cached to untracked' '
587637
git rm --cached dtwo/two &&
588638
git status --porcelain >../status.actual &&
639+
iuc status --porcelain >../status.iuc &&
589640
cat >../status.expect <<EOF &&
590641
M done/two
591642
?? .gitignore
592643
?? done/five
593644
?? done/sub/
594645
?? dtwo/
595646
EOF
647+
test_cmp ../status.expect ../status.iuc &&
596648
test_cmp ../status.expect ../status.actual
597649
'
598650

0 commit comments

Comments
 (0)