midx: rename `get_midx_checksum()` to `midx_get_checksum_hash()`

Since 541204aabea (Documentation: document naming schema for structs and their functions, 2024-07-30), we have adopted a naming convention for functions that would prefer a name like, say, `midx_get_checksum()` over `get_midx_checksum()`. Adopt this convention throughout the midx.h API. Since this function returns a raw (that is, non-hex encoded) hash, let's suffix the function with "_hash()" to make this clear. As a side effect, this prepares us for the subsequent change which will introduce a "_hex()" variant that encodes the checksum itself. Suggested-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Taylor Blau committed Feb 24, 2026 at 13:59 UTC de811c26bb97ac324b60883ae4f4db84a83be2f1
6 files changed +13 -13
midx-write.c
+3 -3
@@ -946,7 +946,7 @@ static int link_midx_to_chain(struct multi_pack_index *m)
946 }
947
948 for (i = 0; i < ARRAY_SIZE(midx_exts); i++) {
949 - const unsigned char *hash = get_midx_checksum(m);
949 + const unsigned char *hash = midx_get_checksum_hash(m);
950
951 get_midx_filename_ext(m->source, &from,
952 hash, midx_exts[i].non_split);
@@ -1151,7 +1151,7 @@ static int write_midx_internal(struct odb_source *source,
1151 while (m) {
1152 if (flags & MIDX_WRITE_BITMAP && load_midx_revindex(m)) {
1153 error(_("could not load reverse index for MIDX %s"),
1154 - hash_to_hex_algop(get_midx_checksum(m),
1154 + hash_to_hex_algop(midx_get_checksum_hash(m),
1155 m->source->odb->repo->hash_algo));
1156 goto cleanup;
1157 }
@@ -1520,7 +1520,7 @@ static int write_midx_internal(struct odb_source *source,
1520 for (uint32_t i = 0; i < ctx.num_multi_pack_indexes_before; i++) {
1521 uint32_t j = ctx.num_multi_pack_indexes_before - i - 1;
1522
1523 - keep_hashes[j] = xstrdup(hash_to_hex_algop(get_midx_checksum(m),
1523 + keep_hashes[j] = xstrdup(hash_to_hex_algop(midx_get_checksum_hash(m),
1524 r->hash_algo));
1525 m = m->base_midx;
1526 }
midx.c
+1 -1
@@ -24,7 +24,7 @@ void clear_incremental_midx_files_ext(struct odb_source *source, const char *ext
24 int cmp_idx_or_pack_name(const char *idx_or_pack_name,
25 const char *idx_name);
26
27 -const unsigned char *get_midx_checksum(const struct multi_pack_index *m)
27 +const unsigned char *midx_get_checksum_hash(const struct multi_pack_index *m)
28 {
29 return m->data + m->data_len - m->source->odb->repo->hash_algo->rawsz;
30 }
midx.h
+1 -1
@@ -85,7 +85,7 @@ struct multi_pack_index {
85 #define MIDX_EXT_BITMAP "bitmap"
86 #define MIDX_EXT_MIDX "midx"
87
88 -const unsigned char *get_midx_checksum(const struct multi_pack_index *m);
88 +const unsigned char *midx_get_checksum_hash(const struct multi_pack_index *m);
89 void get_midx_filename(struct odb_source *source, struct strbuf *out);
90 void get_midx_filename_ext(struct odb_source *source, struct strbuf *out,
91 const unsigned char *hash, const char *ext);
pack-bitmap.c
+4 -4
@@ -441,11 +441,11 @@ char *midx_bitmap_filename(struct multi_pack_index *midx)
441 struct strbuf buf = STRBUF_INIT;
442 if (midx->has_chain)
443 get_split_midx_filename_ext(midx->source, &buf,
444 - get_midx_checksum(midx),
444 + midx_get_checksum_hash(midx),
445 MIDX_EXT_BITMAP);
446 else
447 get_midx_filename_ext(midx->source, &buf,
448 - get_midx_checksum(midx),
448 + midx_get_checksum_hash(midx),
449 MIDX_EXT_BITMAP);
450
451 return strbuf_detach(&buf, NULL);
@@ -502,7 +502,7 @@ static int open_midx_bitmap_1(struct bitmap_index *bitmap_git,
502 if (load_bitmap_header(bitmap_git) < 0)
503 goto cleanup;
504
505 - if (!hasheq(get_midx_checksum(bitmap_git->midx), bitmap_git->checksum,
505 + if (!hasheq(midx_get_checksum_hash(bitmap_git->midx), bitmap_git->checksum,
506 bitmap_repo(bitmap_git)->hash_algo)) {
507 error(_("checksum doesn't match in MIDX and bitmap"));
508 goto cleanup;
@@ -2819,7 +2819,7 @@ void test_bitmap_walk(struct rev_info *revs)
2819
2820 if (bitmap_is_midx(found))
2821 fprintf_ln(stderr, "Located via MIDX '%s'.",
2822 - hash_to_hex_algop(get_midx_checksum(found->midx),
2822 + hash_to_hex_algop(midx_get_checksum_hash(found->midx),
2823 revs->repo->hash_algo));
2824 else
2825 fprintf_ln(stderr, "Located via pack '%s'.",
pack-revindex.c
+2 -2
@@ -390,11 +390,11 @@ int load_midx_revindex(struct multi_pack_index *m)
390
391 if (m->has_chain)
392 get_split_midx_filename_ext(m->source, &revindex_name,
393 - get_midx_checksum(m),
393 + midx_get_checksum_hash(m),
394 MIDX_EXT_REV);
395 else
396 get_midx_filename_ext(m->source, &revindex_name,
397 - get_midx_checksum(m),
397 + midx_get_checksum_hash(m),
398 MIDX_EXT_REV);
399
400 ret = load_revindex_from_disk(m->source->odb->repo->hash_algo,
t/helper/test-read-midx.c
+2 -2
@@ -34,7 +34,7 @@ static int read_midx_file(const char *object_dir, const char *checksum,
34 return 1;
35
36 if (checksum) {
37 - while (m && strcmp(hash_to_hex(get_midx_checksum(m)), checksum))
37 + while (m && strcmp(hash_to_hex(midx_get_checksum_hash(m)), checksum))
38 m = m->base_midx;
39 if (!m)
40 return 1;
@@ -94,7 +94,7 @@ static int read_midx_checksum(const char *object_dir)
94 m = setup_midx(object_dir);
95 if (!m)
96 return 1;
97 - printf("%s\n", hash_to_hex(get_midx_checksum(m)));
97 + printf("%s\n", hash_to_hex(midx_get_checksum_hash(m)));
98
99 close_midx(m);
100 return 0;