Skip to content

Commit 866be6e

Browse files
bk2204gitster
authored andcommitted
t7063: make hash size independent
Use test_oid instead of hard-coding algorithm-specific constants and all-zero values. Signed-off-by: brian m. carlson <[email protected]> Reviewed-by: Eric Sunshine <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4bacb6d commit 866be6e

File tree

1 file changed

+80
-70
lines changed

1 file changed

+80
-70
lines changed

t/t7063-status-untracked-cache.sh

Lines changed: 80 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,24 @@ test_expect_success 'setup' '
7575
touch one two three done/one dtwo/two dthree/three &&
7676
git add one two done/one &&
7777
: >.git/info/exclude &&
78-
git update-index --untracked-cache
78+
git update-index --untracked-cache &&
79+
test_oid_cache <<-EOF
80+
root sha1:e6fcc8f2ee31bae321d66afd183fcb7237afae6e
81+
root sha256:b90c672088c015b9c83876e919da311bad4cd39639fb139f988af6a11493b974
82+
83+
exclude sha1:13263c0978fb9fad16b2d580fb800b6d811c3ff0
84+
exclude sha256:fe4aaa1bbbbce4cb8f73426748a14c5ad6026b26f90505a0bf2494b165a5b76c
85+
86+
done sha1:1946f0437f90c5005533cbe1736a6451ca301714
87+
done sha256:7f079501d79f665b3acc50f5e0e9e94509084d5032ac20113a37dd5029b757cc
88+
EOF
7989
'
8090

8191
test_expect_success 'untracked cache is empty' '
8292
test-tool dump-untracked-cache >../actual &&
8393
cat >../expect-empty <<EOF &&
84-
info/exclude 0000000000000000000000000000000000000000
85-
core.excludesfile 0000000000000000000000000000000000000000
94+
info/exclude $ZERO_OID
95+
core.excludesfile $ZERO_OID
8696
exclude_per_dir .gitignore
8797
flags 00000006
8898
EOF
@@ -100,17 +110,17 @@ EOF
100110

101111
cat >../dump.expect <<EOF &&
102112
info/exclude $EMPTY_BLOB
103-
core.excludesfile 0000000000000000000000000000000000000000
113+
core.excludesfile $ZERO_OID
104114
exclude_per_dir .gitignore
105115
flags 00000006
106-
/ 0000000000000000000000000000000000000000 recurse valid
116+
/ $ZERO_OID recurse valid
107117
dthree/
108118
dtwo/
109119
three
110-
/done/ 0000000000000000000000000000000000000000 recurse valid
111-
/dthree/ 0000000000000000000000000000000000000000 recurse check_only valid
120+
/done/ $ZERO_OID recurse valid
121+
/dthree/ $ZERO_OID recurse check_only valid
112122
three
113-
/dtwo/ 0000000000000000000000000000000000000000 recurse check_only valid
123+
/dtwo/ $ZERO_OID recurse check_only valid
114124
two
115125
EOF
116126

@@ -190,18 +200,18 @@ test_expect_success 'verify untracked cache dump' '
190200
test-tool dump-untracked-cache >../actual &&
191201
cat >../expect <<EOF &&
192202
info/exclude $EMPTY_BLOB
193-
core.excludesfile 0000000000000000000000000000000000000000
203+
core.excludesfile $ZERO_OID
194204
exclude_per_dir .gitignore
195205
flags 00000006
196-
/ 0000000000000000000000000000000000000000 recurse valid
206+
/ $ZERO_OID recurse valid
197207
dthree/
198208
dtwo/
199209
four
200210
three
201-
/done/ 0000000000000000000000000000000000000000 recurse valid
202-
/dthree/ 0000000000000000000000000000000000000000 recurse check_only valid
211+
/done/ $ZERO_OID recurse valid
212+
/dthree/ $ZERO_OID recurse check_only valid
203213
three
204-
/dtwo/ 0000000000000000000000000000000000000000 recurse check_only valid
214+
/dtwo/ $ZERO_OID recurse check_only valid
205215
two
206216
EOF
207217
test_cmp ../expect ../actual
@@ -239,18 +249,18 @@ test_expect_success 'verify untracked cache dump' '
239249
test-tool dump-untracked-cache >../actual &&
240250
cat >../expect <<EOF &&
241251
info/exclude $EMPTY_BLOB
242-
core.excludesfile 0000000000000000000000000000000000000000
252+
core.excludesfile $ZERO_OID
243253
exclude_per_dir .gitignore
244254
flags 00000006
245-
/ e6fcc8f2ee31bae321d66afd183fcb7237afae6e recurse valid
255+
/ $(test_oid root) recurse valid
246256
.gitignore
247257
dthree/
248258
dtwo/
249259
three
250-
/done/ 0000000000000000000000000000000000000000 recurse valid
251-
/dthree/ 0000000000000000000000000000000000000000 recurse check_only valid
260+
/done/ $ZERO_OID recurse valid
261+
/dthree/ $ZERO_OID recurse check_only valid
252262
three
253-
/dtwo/ 0000000000000000000000000000000000000000 recurse check_only valid
263+
/dtwo/ $ZERO_OID recurse check_only valid
254264
two
255265
EOF
256266
test_cmp ../expect ../actual
@@ -284,16 +294,16 @@ EOF
284294
test_expect_success 'verify untracked cache dump' '
285295
test-tool dump-untracked-cache >../actual &&
286296
cat >../expect <<EOF &&
287-
info/exclude 13263c0978fb9fad16b2d580fb800b6d811c3ff0
288-
core.excludesfile 0000000000000000000000000000000000000000
297+
info/exclude $(test_oid exclude)
298+
core.excludesfile $ZERO_OID
289299
exclude_per_dir .gitignore
290300
flags 00000006
291-
/ e6fcc8f2ee31bae321d66afd183fcb7237afae6e recurse valid
301+
/ $(test_oid root) recurse valid
292302
.gitignore
293303
dtwo/
294-
/done/ 0000000000000000000000000000000000000000 recurse valid
295-
/dthree/ 0000000000000000000000000000000000000000 recurse check_only valid
296-
/dtwo/ 0000000000000000000000000000000000000000 recurse check_only valid
304+
/done/ $ZERO_OID recurse valid
305+
/dthree/ $ZERO_OID recurse check_only valid
306+
/dtwo/ $ZERO_OID recurse check_only valid
297307
two
298308
EOF
299309
test_cmp ../expect ../actual
@@ -303,14 +313,14 @@ test_expect_success 'move two from tracked to untracked' '
303313
git rm --cached two &&
304314
test-tool dump-untracked-cache >../actual &&
305315
cat >../expect <<EOF &&
306-
info/exclude 13263c0978fb9fad16b2d580fb800b6d811c3ff0
307-
core.excludesfile 0000000000000000000000000000000000000000
316+
info/exclude $(test_oid exclude)
317+
core.excludesfile $ZERO_OID
308318
exclude_per_dir .gitignore
309319
flags 00000006
310-
/ e6fcc8f2ee31bae321d66afd183fcb7237afae6e recurse
311-
/done/ 0000000000000000000000000000000000000000 recurse valid
312-
/dthree/ 0000000000000000000000000000000000000000 recurse check_only valid
313-
/dtwo/ 0000000000000000000000000000000000000000 recurse check_only valid
320+
/ $(test_oid root) recurse
321+
/done/ $ZERO_OID recurse valid
322+
/dthree/ $ZERO_OID recurse check_only valid
323+
/dtwo/ $ZERO_OID recurse check_only valid
314324
two
315325
EOF
316326
test_cmp ../expect ../actual
@@ -342,17 +352,17 @@ EOF
342352
test_expect_success 'verify untracked cache dump' '
343353
test-tool dump-untracked-cache >../actual &&
344354
cat >../expect <<EOF &&
345-
info/exclude 13263c0978fb9fad16b2d580fb800b6d811c3ff0
346-
core.excludesfile 0000000000000000000000000000000000000000
355+
info/exclude $(test_oid exclude)
356+
core.excludesfile $ZERO_OID
347357
exclude_per_dir .gitignore
348358
flags 00000006
349-
/ e6fcc8f2ee31bae321d66afd183fcb7237afae6e recurse valid
359+
/ $(test_oid root) recurse valid
350360
.gitignore
351361
dtwo/
352362
two
353-
/done/ 0000000000000000000000000000000000000000 recurse valid
354-
/dthree/ 0000000000000000000000000000000000000000 recurse check_only valid
355-
/dtwo/ 0000000000000000000000000000000000000000 recurse check_only valid
363+
/done/ $ZERO_OID recurse valid
364+
/dthree/ $ZERO_OID recurse check_only valid
365+
/dtwo/ $ZERO_OID recurse check_only valid
356366
two
357367
EOF
358368
test_cmp ../expect ../actual
@@ -362,14 +372,14 @@ test_expect_success 'move two from untracked to tracked' '
362372
git add two &&
363373
test-tool dump-untracked-cache >../actual &&
364374
cat >../expect <<EOF &&
365-
info/exclude 13263c0978fb9fad16b2d580fb800b6d811c3ff0
366-
core.excludesfile 0000000000000000000000000000000000000000
375+
info/exclude $(test_oid exclude)
376+
core.excludesfile $ZERO_OID
367377
exclude_per_dir .gitignore
368378
flags 00000006
369-
/ e6fcc8f2ee31bae321d66afd183fcb7237afae6e recurse
370-
/done/ 0000000000000000000000000000000000000000 recurse valid
371-
/dthree/ 0000000000000000000000000000000000000000 recurse check_only valid
372-
/dtwo/ 0000000000000000000000000000000000000000 recurse check_only valid
379+
/ $(test_oid root) recurse
380+
/done/ $ZERO_OID recurse valid
381+
/dthree/ $ZERO_OID recurse check_only valid
382+
/dtwo/ $ZERO_OID recurse check_only valid
373383
two
374384
EOF
375385
test_cmp ../expect ../actual
@@ -401,16 +411,16 @@ EOF
401411
test_expect_success 'verify untracked cache dump' '
402412
test-tool dump-untracked-cache >../actual &&
403413
cat >../expect <<EOF &&
404-
info/exclude 13263c0978fb9fad16b2d580fb800b6d811c3ff0
405-
core.excludesfile 0000000000000000000000000000000000000000
414+
info/exclude $(test_oid exclude)
415+
core.excludesfile $ZERO_OID
406416
exclude_per_dir .gitignore
407417
flags 00000006
408-
/ e6fcc8f2ee31bae321d66afd183fcb7237afae6e recurse valid
418+
/ $(test_oid root) recurse valid
409419
.gitignore
410420
dtwo/
411-
/done/ 0000000000000000000000000000000000000000 recurse valid
412-
/dthree/ 0000000000000000000000000000000000000000 recurse check_only valid
413-
/dtwo/ 0000000000000000000000000000000000000000 recurse check_only valid
421+
/done/ $ZERO_OID recurse valid
422+
/dthree/ $ZERO_OID recurse check_only valid
423+
/dtwo/ $ZERO_OID recurse check_only valid
414424
two
415425
EOF
416426
test_cmp ../expect ../actual
@@ -447,16 +457,16 @@ EOF
447457
test_expect_success 'untracked cache correct after commit' '
448458
test-tool dump-untracked-cache >../actual &&
449459
cat >../expect <<EOF &&
450-
info/exclude 13263c0978fb9fad16b2d580fb800b6d811c3ff0
451-
core.excludesfile 0000000000000000000000000000000000000000
460+
info/exclude $(test_oid exclude)
461+
core.excludesfile $ZERO_OID
452462
exclude_per_dir .gitignore
453463
flags 00000006
454-
/ e6fcc8f2ee31bae321d66afd183fcb7237afae6e recurse valid
464+
/ $(test_oid root) recurse valid
455465
.gitignore
456466
dtwo/
457-
/done/ 0000000000000000000000000000000000000000 recurse valid
458-
/dthree/ 0000000000000000000000000000000000000000 recurse check_only valid
459-
/dtwo/ 0000000000000000000000000000000000000000 recurse check_only valid
467+
/done/ $ZERO_OID recurse valid
468+
/dthree/ $ZERO_OID recurse check_only valid
469+
/dtwo/ $ZERO_OID recurse check_only valid
460470
two
461471
EOF
462472
test_cmp ../expect ../actual
@@ -508,17 +518,17 @@ EOF
508518
test_expect_success 'untracked cache correct after status' '
509519
test-tool dump-untracked-cache >../actual &&
510520
cat >../expect <<EOF &&
511-
info/exclude 13263c0978fb9fad16b2d580fb800b6d811c3ff0
512-
core.excludesfile 0000000000000000000000000000000000000000
521+
info/exclude $(test_oid exclude)
522+
core.excludesfile $ZERO_OID
513523
exclude_per_dir .gitignore
514524
flags 00000006
515-
/ e6fcc8f2ee31bae321d66afd183fcb7237afae6e recurse valid
525+
/ $(test_oid root) recurse valid
516526
.gitignore
517527
dtwo/
518-
/done/ 1946f0437f90c5005533cbe1736a6451ca301714 recurse valid
528+
/done/ $(test_oid done) recurse valid
519529
five
520-
/dthree/ 0000000000000000000000000000000000000000 recurse check_only valid
521-
/dtwo/ 0000000000000000000000000000000000000000 recurse check_only valid
530+
/dthree/ $ZERO_OID recurse check_only valid
531+
/dtwo/ $ZERO_OID recurse check_only valid
522532
two
523533
EOF
524534
test_cmp ../expect ../actual
@@ -580,22 +590,22 @@ EOF
580590
test_expect_success 'verify untracked cache dump (sparse/subdirs)' '
581591
test-tool dump-untracked-cache >../actual &&
582592
cat >../expect-from-test-dump <<EOF &&
583-
info/exclude 13263c0978fb9fad16b2d580fb800b6d811c3ff0
584-
core.excludesfile 0000000000000000000000000000000000000000
593+
info/exclude $(test_oid exclude)
594+
core.excludesfile $ZERO_OID
585595
exclude_per_dir .gitignore
586596
flags 00000006
587-
/ e6fcc8f2ee31bae321d66afd183fcb7237afae6e recurse valid
597+
/ $(test_oid root) recurse valid
588598
.gitignore
589599
dtwo/
590-
/done/ 1946f0437f90c5005533cbe1736a6451ca301714 recurse valid
600+
/done/ $(test_oid done) recurse valid
591601
five
592602
sub/
593-
/done/sub/ 0000000000000000000000000000000000000000 recurse check_only valid
603+
/done/sub/ $ZERO_OID recurse check_only valid
594604
sub/
595-
/done/sub/sub/ 0000000000000000000000000000000000000000 recurse check_only valid
605+
/done/sub/sub/ $ZERO_OID recurse check_only valid
596606
file
597-
/dthree/ 0000000000000000000000000000000000000000 recurse check_only valid
598-
/dtwo/ 0000000000000000000000000000000000000000 recurse check_only valid
607+
/dthree/ $ZERO_OID recurse check_only valid
608+
/dtwo/ $ZERO_OID recurse check_only valid
599609
two
600610
EOF
601611
test_cmp ../expect-from-test-dump ../actual
@@ -806,8 +816,8 @@ test_expect_success '"status" after file replacement should be clean with UC=tru
806816
test-tool dump-untracked-cache >../actual &&
807817
grep -F "recurse valid" ../actual >../actual.grep &&
808818
cat >../expect.grep <<EOF &&
809-
/ 0000000000000000000000000000000000000000 recurse valid
810-
/two/ 0000000000000000000000000000000000000000 recurse valid
819+
/ $ZERO_OID recurse valid
820+
/two/ $ZERO_OID recurse valid
811821
EOF
812822
status_is_clean &&
813823
test_cmp ../expect.grep ../actual.grep

0 commit comments

Comments
 (0)