Skip to content

Commit 8e6e720

Browse files
committed
test-tool synthesize: add precomputed SHA-256 pack for 4 GiB + 1
Add a SHA-256 entry to the fast_packs[] table. The pack prefix and deflate block structure are identical to SHA-1 (the pack format does not encode the hash algorithm in its header). Only the suffix differs: SHA-256 OIDs are 32 bytes instead of 20, giving a 609-byte suffix compared to 513 for SHA-1, and a different pack checksum. The constants were generated by running the generic path inside a repository initialized with --object-format=sha256. Assisted-by: Claude Opus 4.6 Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent 29b9a74 commit 8e6e720

1 file changed

Lines changed: 91 additions & 0 deletions

File tree

t/helper/test-synthesize.c

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,13 +246,104 @@ static const unsigned char fast_pack_sha1_suffix[] = {
246246
0xe3
247247
};
248248

249+
/*
250+
* SHA-256 suffix: same structure, but with 32-byte OIDs and SHA-256
251+
* pack checksum (609 bytes vs 513 for SHA-1).
252+
*/
253+
static const unsigned char fast_pack_sha256_suffix[] = {
254+
0xac, 0x02, 0x78, 0x01, 0x01, 0x2c, 0x00, 0xd3,
255+
0xff, 0x31, 0x30, 0x30, 0x36, 0x34, 0x34, 0x20,
256+
0x66, 0x69, 0x6c, 0x65, 0x00, 0x42, 0x53, 0xc1,
257+
0x8a, 0x9f, 0x5e, 0xc3, 0xbb, 0x47, 0xb0, 0x83,
258+
0x8a, 0x19, 0xdb, 0x31, 0xbb, 0x7b, 0x0f, 0x3b,
259+
0x80, 0xa4, 0xbc, 0x2f, 0xaf, 0x72, 0x6b, 0xdb,
260+
0x62, 0xaa, 0xba, 0xdd, 0xde, 0x77, 0xc6, 0x13,
261+
0xeb, 0x9d, 0x0c, 0x78, 0x01, 0x01, 0xcd, 0x00,
262+
0x32, 0xff, 0x74, 0x72, 0x65, 0x65, 0x20, 0x62,
263+
0x36, 0x30, 0x39, 0x37, 0x37, 0x64, 0x37, 0x63,
264+
0x34, 0x63, 0x32, 0x64, 0x31, 0x65, 0x63, 0x63,
265+
0x33, 0x66, 0x62, 0x61, 0x31, 0x64, 0x39, 0x38,
266+
0x65, 0x65, 0x31, 0x32, 0x30, 0x61, 0x64, 0x63,
267+
0x32, 0x34, 0x38, 0x33, 0x34, 0x39, 0x35, 0x30,
268+
0x62, 0x65, 0x34, 0x31, 0x32, 0x64, 0x39, 0x34,
269+
0x63, 0x38, 0x30, 0x39, 0x34, 0x38, 0x30, 0x66,
270+
0x35, 0x38, 0x62, 0x61, 0x39, 0x64, 0x61, 0x0a,
271+
0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x20, 0x41,
272+
0x20, 0x55, 0x20, 0x54, 0x68, 0x6f, 0x72, 0x20,
273+
0x3c, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x40,
274+
0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e,
275+
0x63, 0x6f, 0x6d, 0x3e, 0x20, 0x31, 0x32, 0x33,
276+
0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x30, 0x20,
277+
0x2b, 0x30, 0x30, 0x30, 0x30, 0x0a, 0x63, 0x6f,
278+
0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x72, 0x20,
279+
0x43, 0x20, 0x4f, 0x20, 0x4d, 0x69, 0x74, 0x74,
280+
0x65, 0x72, 0x20, 0x3c, 0x63, 0x6f, 0x6d, 0x6d,
281+
0x69, 0x74, 0x74, 0x65, 0x72, 0x40, 0x65, 0x78,
282+
0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x63, 0x6f,
283+
0x6d, 0x3e, 0x20, 0x31, 0x32, 0x33, 0x34, 0x35,
284+
0x36, 0x37, 0x38, 0x39, 0x30, 0x20, 0x2b, 0x30,
285+
0x30, 0x30, 0x30, 0x0a, 0x0a, 0x4c, 0x61, 0x72,
286+
0x67, 0x65, 0x20, 0x62, 0x6c, 0x6f, 0x62, 0x20,
287+
0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x0a, 0xb7,
288+
0x80, 0x3d, 0xd7, 0x20, 0x78, 0x01, 0x01, 0x00,
289+
0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x01, 0x95,
290+
0x11, 0x78, 0x01, 0x01, 0x15, 0x01, 0xea, 0xfe,
291+
0x74, 0x72, 0x65, 0x65, 0x20, 0x36, 0x65, 0x66,
292+
0x31, 0x39, 0x62, 0x34, 0x31, 0x32, 0x32, 0x35,
293+
0x63, 0x35, 0x33, 0x36, 0x39, 0x66, 0x31, 0x63,
294+
0x31, 0x30, 0x34, 0x64, 0x34, 0x35, 0x64, 0x38,
295+
0x64, 0x38, 0x35, 0x65, 0x66, 0x61, 0x39, 0x62,
296+
0x30, 0x35, 0x37, 0x62, 0x35, 0x33, 0x62, 0x31,
297+
0x34, 0x62, 0x34, 0x62, 0x39, 0x62, 0x39, 0x33,
298+
0x39, 0x64, 0x64, 0x37, 0x34, 0x64, 0x65, 0x63,
299+
0x63, 0x35, 0x33, 0x32, 0x31, 0x0a, 0x70, 0x61,
300+
0x72, 0x65, 0x6e, 0x74, 0x20, 0x37, 0x35, 0x62,
301+
0x66, 0x30, 0x63, 0x34, 0x37, 0x61, 0x65, 0x34,
302+
0x62, 0x62, 0x33, 0x30, 0x38, 0x65, 0x37, 0x63,
303+
0x63, 0x32, 0x34, 0x38, 0x32, 0x65, 0x32, 0x32,
304+
0x65, 0x66, 0x61, 0x65, 0x33, 0x37, 0x38, 0x37,
305+
0x61, 0x39, 0x36, 0x38, 0x34, 0x38, 0x62, 0x64,
306+
0x31, 0x37, 0x34, 0x39, 0x35, 0x36, 0x37, 0x31,
307+
0x34, 0x37, 0x31, 0x35, 0x32, 0x34, 0x36, 0x64,
308+
0x64, 0x62, 0x64, 0x35, 0x34, 0x0a, 0x61, 0x75,
309+
0x74, 0x68, 0x6f, 0x72, 0x20, 0x41, 0x20, 0x55,
310+
0x20, 0x54, 0x68, 0x6f, 0x72, 0x20, 0x3c, 0x61,
311+
0x75, 0x74, 0x68, 0x6f, 0x72, 0x40, 0x65, 0x78,
312+
0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x63, 0x6f,
313+
0x6d, 0x3e, 0x20, 0x31, 0x32, 0x33, 0x34, 0x35,
314+
0x36, 0x37, 0x38, 0x39, 0x30, 0x20, 0x2b, 0x30,
315+
0x30, 0x30, 0x30, 0x0a, 0x63, 0x6f, 0x6d, 0x6d,
316+
0x69, 0x74, 0x74, 0x65, 0x72, 0x20, 0x43, 0x20,
317+
0x4f, 0x20, 0x4d, 0x69, 0x74, 0x74, 0x65, 0x72,
318+
0x20, 0x3c, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74,
319+
0x74, 0x65, 0x72, 0x40, 0x65, 0x78, 0x61, 0x6d,
320+
0x70, 0x6c, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x3e,
321+
0x20, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
322+
0x38, 0x39, 0x30, 0x20, 0x2b, 0x30, 0x30, 0x30,
323+
0x30, 0x0a, 0x0a, 0x45, 0x6d, 0x70, 0x74, 0x79,
324+
0x20, 0x74, 0x72, 0x65, 0x65, 0x20, 0x63, 0x6f,
325+
0x6d, 0x6d, 0x69, 0x74, 0x0a, 0x6d, 0x6d, 0x51,
326+
0x9a, 0xc9, 0x11, 0x76, 0x61, 0xa3, 0x89, 0x49,
327+
0xb7, 0xa1, 0x58, 0xc6, 0x1d, 0x8c, 0x33, 0x75,
328+
0x8d, 0x7e, 0x4d, 0x8e, 0x58, 0x91, 0xf8, 0x5c,
329+
0x57, 0xd9, 0x89, 0x9e, 0xb8, 0xd2, 0x9a, 0xd8,
330+
0xc9
331+
};
332+
249333
static const struct fast_pack fast_packs[] = {
250334
{
251335
.format_id = GIT_SHA1_FORMAT_ID,
252336
.suffix = fast_pack_sha1_suffix,
253337
.suffix_len = sizeof(fast_pack_sha1_suffix),
254338
.commit_oid = "aac43daf40d0377af31aa9c798a4ae8a31b55c1d",
255339
},
340+
{
341+
.format_id = GIT_SHA256_FORMAT_ID,
342+
.suffix = fast_pack_sha256_suffix,
343+
.suffix_len = sizeof(fast_pack_sha256_suffix),
344+
.commit_oid = "63c46ca51267b1d45be69a044bb84b4bf0559f09"
345+
"d727f861d2ae94ddebdddbc9",
346+
},
256347
};
257348

258349
/*

0 commit comments

Comments
 (0)