]> git.ipfire.org Git - thirdparty/git.git/commit
midx: introduce `midx_get_checksum_hex()`
authorTaylor Blau <me@ttaylorr.com>
Wed, 14 Jan 2026 19:54:24 +0000 (14:54 -0500)
committerJunio C Hamano <gitster@pobox.com>
Wed, 14 Jan 2026 20:52:55 +0000 (12:52 -0800)
commit14453bfb6661e3d1fdb8ef66cd5e0d80387058cb
tree2915a3e87930b9fdd88585592ea8582758620298
parent2fb1a068ecdd237c4336ff5afeeef704eaf7dee9
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>
midx-write.c
midx.c
midx.h
pack-bitmap.c
t/helper/test-read-midx.c