Skip to content

Commit 45af715

Browse files
KarthikNayakgitster
authored andcommitted
midx: pass down hash_algo to get_split_midx_filename_ext
Similar to the previous commit, pass down `hash_algo` to `get_split_midx_filename_ext` and use `hash_to_hex_algop`. Signed-off-by: Karthik Nayak <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 75e99b8 commit 45af715

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

midx-write.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -993,7 +993,8 @@ static int link_midx_to_chain(struct multi_pack_index *m)
993993

994994
get_midx_filename_ext(m->repo->hash_algo, &from, m->object_dir,
995995
hash, midx_exts[i].non_split);
996-
get_split_midx_filename_ext(&to, m->object_dir, hash,
996+
get_split_midx_filename_ext(m->repo->hash_algo, &to,
997+
m->object_dir, hash,
997998
midx_exts[i].split);
998999

9991000
if (link(from.buf, to.buf) < 0 && errno != ENOENT) {
@@ -1439,8 +1440,8 @@ static int write_midx_internal(struct repository *r, const char *object_dir,
14391440
if (link_midx_to_chain(ctx.base_midx) < 0)
14401441
return -1;
14411442

1442-
get_split_midx_filename_ext(&final_midx_name, object_dir,
1443-
midx_hash, MIDX_EXT_MIDX);
1443+
get_split_midx_filename_ext(r->hash_algo, &final_midx_name,
1444+
object_dir, midx_hash, MIDX_EXT_MIDX);
14441445

14451446
if (rename_tempfile(&incr, final_midx_name.buf) < 0) {
14461447
error_errno(_("unable to rename new multi-pack-index layer"));

midx.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -236,11 +236,13 @@ void get_midx_chain_filename(struct strbuf *buf, const char *object_dir)
236236
strbuf_addstr(buf, "/multi-pack-index-chain");
237237
}
238238

239-
void get_split_midx_filename_ext(struct strbuf *buf, const char *object_dir,
239+
void get_split_midx_filename_ext(const struct git_hash_algo *hash_algo,
240+
struct strbuf *buf, const char *object_dir,
240241
const unsigned char *hash, const char *ext)
241242
{
242243
get_midx_chain_dirname(buf, object_dir);
243-
strbuf_addf(buf, "/multi-pack-index-%s.%s", hash_to_hex(hash), ext);
244+
strbuf_addf(buf, "/multi-pack-index-%s.%s",
245+
hash_to_hex_algop(hash, hash_algo), ext);
244246
}
245247

246248
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,
328330
valid = 0;
329331

330332
strbuf_reset(&buf);
331-
get_split_midx_filename_ext(&buf, object_dir, layer.hash,
332-
MIDX_EXT_MIDX);
333+
get_split_midx_filename_ext(r->hash_algo, &buf, object_dir,
334+
layer.hash, MIDX_EXT_MIDX);
333335
m = load_multi_pack_index_one(r, object_dir, buf.buf, local);
334336

335337
if (m) {

midx.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ void get_midx_filename_ext(const struct git_hash_algo *hash_algo,
9797
const unsigned char *hash, const char *ext);
9898
void get_midx_chain_dirname(struct strbuf *buf, const char *object_dir);
9999
void get_midx_chain_filename(struct strbuf *buf, const char *object_dir);
100-
void get_split_midx_filename_ext(struct strbuf *buf, const char *object_dir,
100+
void get_split_midx_filename_ext(const struct git_hash_algo *hash_algo,
101+
struct strbuf *buf, const char *object_dir,
101102
const unsigned char *hash, const char *ext);
102103

103104
struct multi_pack_index *load_multi_pack_index(struct repository *r,

0 commit comments

Comments
 (0)