diff options
| author | Karthik Nayak <karthik.188@gmail.com> | 2025-01-19 12:19:26 +0100 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2025-01-21 12:36:34 -0800 |
| commit | 8244d01de6402606c9fb588ce2143aa629aa7d0e (patch) | |
| tree | beec447534938776b2ebecb945192f1ec4057984 /builtin | |
| parent | fbe8d3079d4a96aeb4e4529cc93cc0043b759a05 (diff) | |
| download | git-8244d01de6402606c9fb588ce2143aa629aa7d0e.tar.xz | |
pack-write: pass hash_algo to `fixup_pack_header_footer()`
The `fixup_pack_header_footer()` function uses the global
`the_hash_algo` variable to access the repository's hash function. To
avoid global variable usage, pass a hash_algo from the layers above.
Altough the layers above could have access to the hash_algo internally,
simply pass in `the_hash_algo`. This avoids any compatibility issues and
bubbles up global variable usage to upper layers which can be eventually
resolved.
Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
| -rw-r--r-- | builtin/fast-import.c | 7 | ||||
| -rw-r--r-- | builtin/index-pack.c | 2 | ||||
| -rw-r--r-- | builtin/pack-objects.c | 5 |
3 files changed, 8 insertions, 6 deletions
diff --git a/builtin/fast-import.c b/builtin/fast-import.c index 0f86392761..6baf2b1b71 100644 --- a/builtin/fast-import.c +++ b/builtin/fast-import.c @@ -878,9 +878,10 @@ static void end_packfile(void) close_pack_windows(pack_data); finalize_hashfile(pack_file, cur_pack_oid.hash, FSYNC_COMPONENT_PACK, 0); - fixup_pack_header_footer(pack_data->pack_fd, pack_data->hash, - pack_data->pack_name, object_count, - cur_pack_oid.hash, pack_size); + fixup_pack_header_footer(the_hash_algo, pack_data->pack_fd, + pack_data->hash, pack_data->pack_name, + object_count, cur_pack_oid.hash, + pack_size); if (object_count <= unpack_limit) { if (!loosen_small_pack(pack_data)) { diff --git a/builtin/index-pack.c b/builtin/index-pack.c index 0b62b2589f..cb9de5ca2c 100644 --- a/builtin/index-pack.c +++ b/builtin/index-pack.c @@ -1387,7 +1387,7 @@ static void conclude_pack(int fix_thin_pack, const char *curr_pack, unsigned cha strbuf_release(&msg); finalize_hashfile(f, tail_hash, FSYNC_COMPONENT_PACK, 0); hashcpy(read_hash, pack_hash, the_repository->hash_algo); - fixup_pack_header_footer(output_fd, pack_hash, + fixup_pack_header_footer(the_hash_algo, output_fd, pack_hash, curr_pack, nr_objects, read_hash, consumed_bytes-the_hash_algo->rawsz); if (!hasheq(read_hash, tail_hash, the_repository->hash_algo)) diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c index 1c3b842651..6188e82059 100644 --- a/builtin/pack-objects.c +++ b/builtin/pack-objects.c @@ -1318,8 +1318,9 @@ static void write_pack_file(void) */ int fd = finalize_hashfile(f, hash, FSYNC_COMPONENT_PACK, 0); - fixup_pack_header_footer(fd, hash, pack_tmp_name, - nr_written, hash, offset); + fixup_pack_header_footer(the_hash_algo, fd, hash, + pack_tmp_name, nr_written, + hash, offset); close(fd); if (write_bitmap_index) { if (write_bitmap_index != WRITE_BITMAP_QUIET) |
