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:
committed by
Junio C Hamano
parent
d5c2ca576a
commit
f59de71cf7
22
midx-write.c
22
midx-write.c
@ -991,9 +991,10 @@ static int link_midx_to_chain(struct multi_pack_index *m)
|
||||
for (i = 0; i < ARRAY_SIZE(midx_exts); i++) {
|
||||
const unsigned char *hash = get_midx_checksum(m);
|
||||
|
||||
get_midx_filename_ext(&from, m->object_dir, hash,
|
||||
midx_exts[i].non_split);
|
||||
get_split_midx_filename_ext(&to, m->object_dir, hash,
|
||||
get_midx_filename_ext(m->repo->hash_algo, &from, m->object_dir,
|
||||
hash, midx_exts[i].non_split);
|
||||
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) {
|
||||
@ -1012,9 +1013,8 @@ done:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void clear_midx_files(const char *object_dir,
|
||||
const char **hashes,
|
||||
uint32_t hashes_nr,
|
||||
static void clear_midx_files(struct repository *r, const char *object_dir,
|
||||
const char **hashes, uint32_t hashes_nr,
|
||||
unsigned incremental)
|
||||
{
|
||||
/*
|
||||
@ -1039,7 +1039,7 @@ static void clear_midx_files(const char *object_dir,
|
||||
}
|
||||
|
||||
if (incremental)
|
||||
get_midx_filename(&buf, object_dir);
|
||||
get_midx_filename(r->hash_algo, &buf, object_dir);
|
||||
else
|
||||
get_midx_chain_filename(&buf, object_dir);
|
||||
|
||||
@ -1083,7 +1083,7 @@ static int write_midx_internal(struct repository *r, const char *object_dir,
|
||||
"%s/pack/multi-pack-index.d/tmp_midx_XXXXXX",
|
||||
object_dir);
|
||||
else
|
||||
get_midx_filename(&midx_name, object_dir);
|
||||
get_midx_filename(r->hash_algo, &midx_name, object_dir);
|
||||
if (safe_create_leading_directories(midx_name.buf))
|
||||
die_errno(_("unable to create leading directories of %s"),
|
||||
midx_name.buf);
|
||||
@ -1440,8 +1440,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"));
|
||||
@ -1474,7 +1474,7 @@ static int write_midx_internal(struct repository *r, const char *object_dir,
|
||||
if (commit_lock_file(&lk) < 0)
|
||||
die_errno(_("could not write multi-pack-index"));
|
||||
|
||||
clear_midx_files(object_dir, keep_hashes,
|
||||
clear_midx_files(r, object_dir, keep_hashes,
|
||||
ctx.num_multi_pack_indexes_before + 1,
|
||||
ctx.incremental);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user