Skip to content

Commit fbc6526

Browse files
rscharfegitster
authored andcommitted
t6300: avoid hard-coding object sizes
f4ee22b (ref-filter: add tests for objectsize:disk, 2018-12-24) hard-coded the expected object sizes. Coincidentally the size of commit and tag is the same with zlib at the default compression level. 1f5f8f3 (t6300: abstract away SHA-1-specific constants, 2020-02-22) encoded the sizes as a single value, which coincidentally also works with sha256. Different compression libraries like zlib-ng may arrive at different values. Get them from the file system instead of hard-coding them to make switching the compression library (or changing the compression level) easier. Reported-by: Ondrej Pohorelsky <[email protected]> Signed-off-by: René Scharfe <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 564d025 commit fbc6526

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

t/t6300-for-each-ref.sh

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,13 @@ setdate_and_increment () {
2020
export GIT_COMMITTER_DATE GIT_AUTHOR_DATE
2121
}
2222

23-
test_expect_success setup '
24-
test_oid_cache <<-EOF &&
25-
disklen sha1:138
26-
disklen sha256:154
27-
EOF
23+
test_object_file_size () {
24+
oid=$(git rev-parse "$1")
25+
path=".git/objects/$(test_oid_to_path $oid)"
26+
test_file_size "$path"
27+
}
2828

29+
test_expect_success setup '
2930
# setup .mailmap
3031
cat >.mailmap <<-EOF &&
3132
@@ -94,7 +95,6 @@ test_atom () {
9495
}
9596

9697
hexlen=$(test_oid hexsz)
97-
disklen=$(test_oid disklen)
9898

9999
test_atom head refname refs/heads/main
100100
test_atom head refname: refs/heads/main
@@ -129,7 +129,7 @@ test_atom head push:strip=1 remotes/myfork/main
129129
test_atom head push:strip=-1 main
130130
test_atom head objecttype commit
131131
test_atom head objectsize $((131 + hexlen))
132-
test_atom head objectsize:disk $disklen
132+
test_atom head objectsize:disk $(test_object_file_size refs/heads/main)
133133
test_atom head deltabase $ZERO_OID
134134
test_atom head objectname $(git rev-parse refs/heads/main)
135135
test_atom head objectname:short $(git rev-parse --short refs/heads/main)
@@ -203,8 +203,8 @@ test_atom tag upstream ''
203203
test_atom tag push ''
204204
test_atom tag objecttype tag
205205
test_atom tag objectsize $((114 + hexlen))
206-
test_atom tag objectsize:disk $disklen
207-
test_atom tag '*objectsize:disk' $disklen
206+
test_atom tag objectsize:disk $(test_object_file_size refs/tags/testtag)
207+
test_atom tag '*objectsize:disk' $(test_object_file_size refs/heads/main)
208208
test_atom tag deltabase $ZERO_OID
209209
test_atom tag '*deltabase' $ZERO_OID
210210
test_atom tag objectname $(git rev-parse refs/tags/testtag)

0 commit comments

Comments
 (0)