midx: pass down hash_algo to functions using global variables

The functions `get_split_midx_filename_ext()`, `get_midx_filename()` and
`get_midx_filename_ext()` use `hash_to_hex()` which internally uses the
`the_hash_algo` global variable.

Remove this dependency on global variables by passing down the
`hash_algo` through to the functions mentioned and instead calling
`hash_to_hex_algop()` along with the obtained `hash_algo`.

Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Karthik Nayak
2024-11-27 17:28:32 +01:00
committed by Junio C Hamano
parent d5c2ca576a
commit f59de71cf7
5 changed files with 37 additions and 29 deletions

10
midx.h
View File

@@ -7,6 +7,7 @@ struct object_id;
struct pack_entry;
struct repository;
struct bitmapped_pack;
struct git_hash_algo;
#define MIDX_SIGNATURE 0x4d494458 /* "MIDX" */
#define MIDX_VERSION 1
@@ -89,12 +90,15 @@ struct multi_pack_index {
#define MIDX_EXT_MIDX "midx"
const unsigned char *get_midx_checksum(struct multi_pack_index *m);
void get_midx_filename(struct strbuf *out, const char *object_dir);
void get_midx_filename_ext(struct strbuf *out, const char *object_dir,
void get_midx_filename(const struct git_hash_algo *hash_algo,
struct strbuf *out, const char *object_dir);
void get_midx_filename_ext(const struct git_hash_algo *hash_algo,
struct strbuf *out, const char *object_dir,
const unsigned char *hash, const char *ext);
void get_midx_chain_dirname(struct strbuf *buf, const char *object_dir);
void get_midx_chain_filename(struct strbuf *buf, const char *object_dir);
void get_split_midx_filename_ext(struct strbuf *buf, const char *object_dir,
void get_split_midx_filename_ext(const struct git_hash_algo *hash_algo,
struct strbuf *buf, const char *object_dir,
const unsigned char *hash, const char *ext);
struct multi_pack_index *load_multi_pack_index(struct repository *r,