@@ -992,7 +992,8 @@ static int link_midx_to_chain(struct multi_pack_index *m)
get_midx_filename_ext(m->repo->hash_algo, &from, m->object_dir,
hash, midx_exts[i].non_split);
- get_split_midx_filename_ext(&to, m->object_dir, hash,
+ get_split_midx_filename_ext(m->repo->hash_algo, &to,
+ m->object_dir, hash,
midx_exts[i].split);
if (link(from.buf, to.buf) < 0 && errno != ENOENT) {
@@ -1438,8 +1439,8 @@ static int write_midx_internal(struct repository *r, const char *object_dir,
if (link_midx_to_chain(ctx.base_midx) < 0)
return -1;
- get_split_midx_filename_ext(&final_midx_name, object_dir,
- midx_hash, MIDX_EXT_MIDX);
+ get_split_midx_filename_ext(r->hash_algo, &final_midx_name,
+ object_dir, midx_hash, MIDX_EXT_MIDX);
if (rename_tempfile(&incr, final_midx_name.buf) < 0) {
error_errno(_("unable to rename new multi-pack-index layer"));
@@ -236,11 +236,13 @@ void get_midx_chain_filename(struct strbuf *buf, const char *object_dir)
strbuf_addstr(buf, "/multi-pack-index-chain");
}
-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)
{
get_midx_chain_dirname(buf, object_dir);
- strbuf_addf(buf, "/multi-pack-index-%s.%s", hash_to_hex(hash), ext);
+ strbuf_addf(buf, "/multi-pack-index-%s.%s",
+ hash_to_hex_algop(hash, hash_algo), ext);
}
static int open_multi_pack_index_chain(const struct git_hash_algo *hash_algo,
@@ -328,8 +330,8 @@ static struct multi_pack_index *load_midx_chain_fd_st(struct repository *r,
valid = 0;
strbuf_reset(&buf);
- get_split_midx_filename_ext(&buf, object_dir, layer.hash,
- MIDX_EXT_MIDX);
+ get_split_midx_filename_ext(r->hash_algo, &buf, object_dir,
+ layer.hash, MIDX_EXT_MIDX);
m = load_multi_pack_index_one(r, object_dir, buf.buf, local);
if (m) {
@@ -97,7 +97,8 @@ void get_midx_filename_ext(const struct git_hash_algo *hash_algo,
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,
Similar to the previous commit, pass down `hash_algo` to `get_split_midx_filename_ext` so we can use `hash_to_hex_algop` and not rely on the `the_repository` global variable. Signed-off-by: Karthik Nayak <karthik.188@gmail.com> --- midx-write.c | 7 ++++--- midx.c | 10 ++++++---- midx.h | 3 ++- 3 files changed, 12 insertions(+), 8 deletions(-)