25
* Updates the pack checksum context.
26
*/
27
static void write_uncompressed_zlib(FILE *f, struct git_hash_ctx *pack_ctx,
28
- const void *data, size_t len,
29
- const struct git_hash_algo *algo)
28
+ const void *data, size_t len)
29
{
30
unsigned char zlib_header[2] = { 0x78, 0x01 }; /* CMF, FLG */
31
unsigned char block_header[5];
36
37
/* Write zlib header */
38
fwrite_or_die(f, zlib_header, sizeof(zlib_header));
40
- algo->update_fn(pack_ctx, zlib_header, 2);
39
+ git_hash_update(pack_ctx, zlib_header, 2);
40
41
/* Write uncompressed blocks (max 64KB each) */
42
do {
51
block_header[4] = block_header[2] ^ 0xff;
52
53
fwrite_or_die(f, block_header, sizeof(block_header));
55
- algo->update_fn(pack_ctx, block_header, 5);
54
+ git_hash_update(pack_ctx, block_header, 5);
55
56
if (block_len) {
57
fwrite_or_die(f, block_data, block_len);
59
- algo->update_fn(pack_ctx, block_data, block_len);
58
+ git_hash_update(pack_ctx, block_data, block_len);
59
adler = adler32(adler, block_data, block_len);
60
}
61
67
/* Write adler32 checksum */
68
put_be32(adler_buf, adler);
69
fwrite_or_die(f, adler_buf, sizeof(adler_buf));
71
- algo->update_fn(pack_ctx, adler_buf, 4);
70
+ git_hash_update(pack_ctx, adler_buf, 4);
71
}
72
73
/*
91
sizeof(pack_header),
92
type, len);
93
fwrite_or_die(f, pack_header, pack_header_len);
95
- algo->update_fn(pack_ctx, pack_header, pack_header_len);
94
+ git_hash_update(pack_ctx, pack_header, pack_header_len);
95
96
/* Write the data as uncompressed zlib */
98
- write_uncompressed_zlib(f, pack_ctx, data, len, algo);
97
+ write_uncompressed_zlib(f, pack_ctx, data, len);
98
99
git_hash_init(&ctx, algo);
100
object_header_len = format_object_header(object_header,
101
sizeof(object_header),
102
type, len);
104
- algo->update_fn(&ctx, object_header, object_header_len);
103
+ git_hash_update(&ctx, object_header, object_header_len);
104
if (data)
106
- algo->update_fn(&ctx, data, len);
105
+ git_hash_update(&ctx, data, len);
106
else {
107
for (size_t i = len / BLOCK_SIZE; i; i--)
109
- algo->update_fn(&ctx, zeros, BLOCK_SIZE);
110
- algo->update_fn(&ctx, zeros, len % BLOCK_SIZE);
108
+ git_hash_update(&ctx, zeros, BLOCK_SIZE);
109
+ git_hash_update(&ctx, zeros, len % BLOCK_SIZE);
110
}
112
- algo->final_oid_fn(oid, &ctx);
111
+ git_hash_final_oid(oid, &ctx);
112
}
113
114
/*
433
434
/* Write pack header */
435
fwrite_or_die(f, &pack_header, sizeof(pack_header));
437
- algo->update_fn(&pack_ctx, &pack_header, sizeof(pack_header));
436
+ git_hash_update(&pack_ctx, &pack_header, sizeof(pack_header));
437
438
/* 1. Write the large blob */
439
write_pack_object(f, &pack_ctx, OBJ_BLOB, NULL, blob_size, &blob_oid, algo);
471
write_pack_object(f, &pack_ctx, OBJ_COMMIT, buf.buf, buf.len, &final_commit_oid, algo);
472
473
/* Write pack trailer (checksum) */
475
- algo->final_fn(pack_hash, &pack_ctx);
474
+ git_hash_final(pack_hash, &pack_ctx);
475
fwrite_or_die(f, pack_hash, algo->rawsz);
476
if (fclose(f))
477
die_errno(_("could not close '%s'"), path);