Skip to content

Commit de811c2

Browse files
ttaylorrgitster
authored andcommitted
midx: rename get_midx_checksum() to midx_get_checksum_hash()
Since 541204a (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>
1 parent 00c0d84 commit de811c2

6 files changed

Lines changed: 13 additions & 13 deletions

File tree

midx-write.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -946,7 +946,7 @@ static int link_midx_to_chain(struct multi_pack_index *m)
946946
}
947947

948948
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);
950950

951951
get_midx_filename_ext(m->source, &from,
952952
hash, midx_exts[i].non_split);
@@ -1151,7 +1151,7 @@ static int write_midx_internal(struct odb_source *source,
11511151
while (m) {
11521152
if (flags & MIDX_WRITE_BITMAP && load_midx_revindex(m)) {
11531153
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),
11551155
m->source->odb->repo->hash_algo));
11561156
goto cleanup;
11571157
}
@@ -1520,7 +1520,7 @@ static int write_midx_internal(struct odb_source *source,
15201520
for (uint32_t i = 0; i < ctx.num_multi_pack_indexes_before; i++) {
15211521
uint32_t j = ctx.num_multi_pack_indexes_before - i - 1;
15221522

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),
15241524
r->hash_algo));
15251525
m = m->base_midx;
15261526
}

midx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ void clear_incremental_midx_files_ext(struct odb_source *source, const char *ext
2424
int cmp_idx_or_pack_name(const char *idx_or_pack_name,
2525
const char *idx_name);
2626

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)
2828
{
2929
return m->data + m->data_len - m->source->odb->repo->hash_algo->rawsz;
3030
}

midx.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ struct multi_pack_index {
8585
#define MIDX_EXT_BITMAP "bitmap"
8686
#define MIDX_EXT_MIDX "midx"
8787

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);
8989
void get_midx_filename(struct odb_source *source, struct strbuf *out);
9090
void get_midx_filename_ext(struct odb_source *source, struct strbuf *out,
9191
const unsigned char *hash, const char *ext);

pack-bitmap.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -441,11 +441,11 @@ char *midx_bitmap_filename(struct multi_pack_index *midx)
441441
struct strbuf buf = STRBUF_INIT;
442442
if (midx->has_chain)
443443
get_split_midx_filename_ext(midx->source, &buf,
444-
get_midx_checksum(midx),
444+
midx_get_checksum_hash(midx),
445445
MIDX_EXT_BITMAP);
446446
else
447447
get_midx_filename_ext(midx->source, &buf,
448-
get_midx_checksum(midx),
448+
midx_get_checksum_hash(midx),
449449
MIDX_EXT_BITMAP);
450450

451451
return strbuf_detach(&buf, NULL);
@@ -502,7 +502,7 @@ static int open_midx_bitmap_1(struct bitmap_index *bitmap_git,
502502
if (load_bitmap_header(bitmap_git) < 0)
503503
goto cleanup;
504504

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,
506506
bitmap_repo(bitmap_git)->hash_algo)) {
507507
error(_("checksum doesn't match in MIDX and bitmap"));
508508
goto cleanup;
@@ -2819,7 +2819,7 @@ void test_bitmap_walk(struct rev_info *revs)
28192819

28202820
if (bitmap_is_midx(found))
28212821
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),
28232823
revs->repo->hash_algo));
28242824
else
28252825
fprintf_ln(stderr, "Located via pack '%s'.",

pack-revindex.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -390,11 +390,11 @@ int load_midx_revindex(struct multi_pack_index *m)
390390

391391
if (m->has_chain)
392392
get_split_midx_filename_ext(m->source, &revindex_name,
393-
get_midx_checksum(m),
393+
midx_get_checksum_hash(m),
394394
MIDX_EXT_REV);
395395
else
396396
get_midx_filename_ext(m->source, &revindex_name,
397-
get_midx_checksum(m),
397+
midx_get_checksum_hash(m),
398398
MIDX_EXT_REV);
399399

400400
ret = load_revindex_from_disk(m->source->odb->repo->hash_algo,

t/helper/test-read-midx.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ static int read_midx_file(const char *object_dir, const char *checksum,
3434
return 1;
3535

3636
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))
3838
m = m->base_midx;
3939
if (!m)
4040
return 1;
@@ -94,7 +94,7 @@ static int read_midx_checksum(const char *object_dir)
9494
m = setup_midx(object_dir);
9595
if (!m)
9696
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)));
9898

9999
close_midx(m);
100100
return 0;

0 commit comments

Comments
 (0)