object-file: get rid of the_repository in finalize_object_file()

We implicitly depend on `the_repository` when moving an object file into
place in `finalize_object_file()`. Get rid of this global dependency by
passing in a repository.

Note that one might be pressed to inject an object database instead of a
repository. But the function doesn't really care about the ODB at all.
All it does is to move a file into place while checking whether there is
any collision. As such, the functionality it provides is independent of
the object database and only needs the repository as parameter so that
it can adjust permissions of the file we are about to finalize.

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-07-17 06:56:33 +02:00
committed by Junio C Hamano
parent 1efe0aeaa2
commit cbb388f3e5
11 changed files with 32 additions and 25 deletions

3
pack.h
View File

@@ -145,7 +145,8 @@ void stage_tmp_packfiles(struct repository *repo,
struct pack_idx_option *pack_idx_opts,
unsigned char hash[],
char **idx_tmp_name);
void rename_tmp_packfile_idx(struct strbuf *basename,
void rename_tmp_packfile_idx(struct repository *repo,
struct strbuf *basename,
char **idx_tmp_name);
#endif