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

View File

@@ -227,7 +227,7 @@ static int migrate_one(struct tmp_objdir *t,
return -1;
return migrate_paths(t, src, dst, flags);
}
return finalize_object_file_flags(src->buf, dst->buf, flags);
return finalize_object_file_flags(t->repo, src->buf, dst->buf, flags);
}
static int is_loose_object_shard(const char *name)