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

The function `force_object_loose()` forces an object to become a loose
object in case it only exists in its packed form. To do so it implicitly
relies on `the_repository`.

Refactor the function by passing a `struct odb_source` as parameter.
While the check whether any such loose object exists already acts on the
whole object database, writing the loose object happens in one specific
source.

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:41 +02:00
committed by Junio C Hamano
parent 0df005353a
commit c2b5d1490a
3 changed files with 13 additions and 11 deletions

View File

@@ -161,7 +161,8 @@ int stream_loose_object(struct odb_source *source,
struct input_stream *in_stream, size_t len,
struct object_id *oid);
int force_object_loose(const struct object_id *oid, time_t mtime);
int force_object_loose(struct odb_source *source,
const struct object_id *oid, time_t mtime);
/**
* With in-core object data in "buf", rehash it to make sure the