Skip to content

Commit 77257e3

Browse files
pks-tgitster
authored andcommitted
t6500: extract objects with "17" prefix
The ".git/obects/17/" shard is somewhat special because it is used by git-gc(1) to estimate how many objects there are by extrapolating the number of objects in that shard, only. In t6500 we thus have a hard coded set of data that, when written to the object database, result in blobs starting with that prefix. We are about to need such "17"-prefixed objects in another test suite. Extract them into "t/oid-info/hash-info" so that they can be reused by other tests. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0e05d53 commit 77257e3

File tree

2 files changed

+19
-23
lines changed

2 files changed

+19
-23
lines changed

t/oid-info/hash-info

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,15 @@ empty_blob sha256:473a0f4c3be8a93681a267e3b1e9a7dcda1185436fe141f7749120a3037218
1515

1616
empty_tree sha1:4b825dc642cb6eb9a060e54bf8d69288fbee4904
1717
empty_tree sha256:6ef19b41225c5369f1c104d45d8d85efa9b057b53b14b4b9b939dd74decc5321
18+
19+
blob17_1 sha1:263
20+
blob17_1 sha256:34
21+
22+
blob17_2 sha1:410
23+
blob17_2 sha256:174
24+
25+
blob17_3 sha1:523
26+
blob17_3 sha256:313
27+
28+
blob17_4 sha1:790
29+
blob17_4 sha256:481

t/t6500-gc.sh

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,7 @@ test_expect_success 'setup' '
1111
# behavior, make sure we always pack everything to one pack by
1212
# default
1313
git config gc.bigPackThreshold 2g &&
14-
15-
# These are simply values which, when hashed as a blob with a newline,
16-
# produce a hash where the first byte is 0x17 in their respective
17-
# algorithms.
18-
test_oid_cache <<-EOF
19-
obj1 sha1:263
20-
obj1 sha256:34
21-
22-
obj2 sha1:410
23-
obj2 sha256:174
24-
25-
obj3 sha1:523
26-
obj3 sha256:313
27-
28-
obj4 sha1:790
29-
obj4 sha256:481
30-
EOF
14+
test_oid_init
3115
'
3216

3317
test_expect_success 'gc empty repository' '
@@ -114,8 +98,8 @@ test_expect_success 'pre-auto-gc hook can stop auto gc' '
11498
# We need to create two object whose sha1s start with 17
11599
# since this is what git gc counts. As it happens, these
116100
# two blobs will do so.
117-
test_commit "$(test_oid obj1)" &&
118-
test_commit "$(test_oid obj2)" &&
101+
test_commit "$(test_oid blob17_1)" &&
102+
test_commit "$(test_oid blob17_2)" &&
119103
120104
git gc --auto >../out.actual 2>../err.actual
121105
) &&
@@ -146,13 +130,13 @@ test_expect_success 'auto gc with too many loose objects does not attempt to cre
146130
# We need to create two object whose sha1s start with 17
147131
# since this is what git gc counts. As it happens, these
148132
# two blobs will do so.
149-
test_commit "$(test_oid obj1)" &&
150-
test_commit "$(test_oid obj2)" &&
133+
test_commit "$(test_oid blob17_1)" &&
134+
test_commit "$(test_oid blob17_2)" &&
151135
# Our first gc will create a pack; our second will create a second pack
152136
git gc --auto &&
153137
ls .git/objects/pack/pack-*.pack | sort >existing_packs &&
154-
test_commit "$(test_oid obj3)" &&
155-
test_commit "$(test_oid obj4)" &&
138+
test_commit "$(test_oid blob17_3)" &&
139+
test_commit "$(test_oid blob17_4)" &&
156140
157141
git gc --auto 2>err &&
158142
test_grep ! "^warning:" err &&

0 commit comments

Comments
 (0)