From 0f9b18935745fcdebcad613a6e3e52db5b29b1d4 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Thu, 17 Jul 2025 06:56:34 +0200 Subject: loose: write loose objects map via their source When a repository is configured to have a compatibility hash algorithm we keep track of object ID mappings for loose objects via the loose object map. This map simply maps an object ID of the actual hash to the object ID of the compatibility hash. This loose object map is an inherent property of the loose files backend and thus of one specific object source. Refactor the interfaces to reflect this by requiring a `struct odb_source` as input instead of a repository. This prepares for subsequent commits where we will refactor writing of loose objects to work on a `struct odb_source`, as well. Signed-off-by: Patrick Steinhardt Signed-off-by: Junio C Hamano --- object-file.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'object-file.c') diff --git a/object-file.c b/object-file.c index 6a7049a9e9..a9248760a2 100644 --- a/object-file.c +++ b/object-file.c @@ -1025,7 +1025,7 @@ int stream_loose_object(struct input_stream *in_stream, size_t len, err = finalize_object_file_flags(the_repository, tmp_file.buf, filename.buf, FOF_SKIP_COLLISION_CHECK); if (!err && compat) - err = repo_add_loose_object_map(the_repository, oid, &compat_oid); + err = repo_add_loose_object_map(the_repository->objects->sources, oid, &compat_oid); cleanup: strbuf_release(&tmp_file); strbuf_release(&filename); @@ -1069,7 +1069,7 @@ int write_object_file_flags(const void *buf, unsigned long len, if (write_loose_object(oid, hdr, hdrlen, buf, len, 0, flags)) return -1; if (compat) - return repo_add_loose_object_map(repo, oid, &compat_oid); + return repo_add_loose_object_map(repo->objects->sources, oid, &compat_oid); return 0; } @@ -1103,7 +1103,7 @@ int force_object_loose(const struct object_id *oid, time_t mtime) hdrlen = format_object_header(hdr, sizeof(hdr), type, len); ret = write_loose_object(oid, hdr, hdrlen, buf, len, mtime, 0); if (!ret && compat) - ret = repo_add_loose_object_map(the_repository, oid, &compat_oid); + ret = repo_add_loose_object_map(the_repository->objects->sources, oid, &compat_oid); free(buf); return ret; -- cgit v1.2.3