csum-file: stop depending on the_repository

There are multiple sites in "csum-file.c" where we use the global
`the_repository` variable, either explicitly or implicitly by using
`the_hash_algo`.

Refactor the code to stop using `the_repository` by adapting functions
to receive required data as parameters. Adapt callsites accordingly by
either using `the_repository->hash_algo`, or by using a context-provided
hash algorithm in case the subsystem already got rid of its dependency
on `the_repository`.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Patrick Steinhardt
2025-03-10 08:13:20 +01:00
committed by Junio C Hamano
parent e969bc8759
commit 228457c9d9
14 changed files with 56 additions and 39 deletions

View File

@@ -2090,11 +2090,13 @@ static int write_commit_graph_file(struct write_commit_graph_context *ctx)
return -1;
}
f = hashfd(get_tempfile_fd(graph_layer), get_tempfile_path(graph_layer));
f = hashfd(the_repository->hash_algo,
get_tempfile_fd(graph_layer), get_tempfile_path(graph_layer));
} else {
hold_lock_file_for_update_mode(&lk, ctx->graph_name,
LOCK_DIE_ON_ERROR, 0444);
f = hashfd(get_lock_file_fd(&lk), get_lock_file_path(&lk));
f = hashfd(the_repository->hash_algo,
get_lock_file_fd(&lk), get_lock_file_path(&lk));
}
cf = init_chunkfile(f);
@@ -2716,7 +2718,8 @@ static void graph_report(const char *fmt, ...)
static int commit_graph_checksum_valid(struct commit_graph *g)
{
return hashfile_checksum_valid(g->data, g->data_len);
return hashfile_checksum_valid(the_repository->hash_algo,
g->data, g->data_len);
}
static int verify_one_commit_graph(struct repository *r,