aboutsummaryrefslogtreecommitdiff
path: root/midx-write.c
diff options
context:
space:
mode:
authorTaylor Blau <me@ttaylorr.com>2026-02-24 13:59:44 -0500
committerJunio C Hamano <gitster@pobox.com>2026-02-24 11:16:32 -0800
commit6e86f679248580bec5c105b37217862f3022b504 (patch)
tree75e780d855857c2cfaf7e265ef0200b7d952fe0f /midx-write.c
parentde811c26bb97ac324b60883ae4f4db84a83be2f1 (diff)
downloadgit-6e86f679248580bec5c105b37217862f3022b504.tar.xz
midx: introduce `midx_get_checksum_hex()`
When trying to print out, say, the hexadecimal representation of a MIDX's hash, our code will do something like: hash_to_hex_algop(midx_get_checksum_hash(m), m->source->odb->repo->hash_algo); , which is both cumbersome and repetitive. In fact, all but a handful of callers to `midx_get_checksum_hash()` do exactly the above. Reduce the repetitive nature of calling `midx_get_checksum_hash()` by having it return a pointer into a static buffer containing the above result. For the handful of callers that do need to compare the raw bytes and don't want to deal with an encoded copy (e.g., because they are passing it to hasheq() or similar), they may still rely on `midx_get_checksum_hash()` which returns the raw bytes. Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'midx-write.c')
-rw-r--r--midx-write.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/midx-write.c b/midx-write.c
index 73d33752ef..13171d7e9c 100644
--- a/midx-write.c
+++ b/midx-write.c
@@ -1151,8 +1151,7 @@ static int write_midx_internal(struct odb_source *source,
while (m) {
if (flags & MIDX_WRITE_BITMAP && load_midx_revindex(m)) {
error(_("could not load reverse index for MIDX %s"),
- hash_to_hex_algop(midx_get_checksum_hash(m),
- m->source->odb->repo->hash_algo));
+ midx_get_checksum_hex(m));
goto cleanup;
}
ctx.num_multi_pack_indexes_before++;
@@ -1520,8 +1519,7 @@ static int write_midx_internal(struct odb_source *source,
for (uint32_t i = 0; i < ctx.num_multi_pack_indexes_before; i++) {
uint32_t j = ctx.num_multi_pack_indexes_before - i - 1;
- keep_hashes[j] = xstrdup(hash_to_hex_algop(midx_get_checksum_hash(m),
- r->hash_algo));
+ keep_hashes[j] = xstrdup(midx_get_checksum_hex(m));
m = m->base_midx;
}