aboutsummaryrefslogtreecommitdiff
path: root/http.c
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2026-03-05 15:19:43 +0100
committerJunio C Hamano <gitster@pobox.com>2026-03-05 11:45:15 -0800
commitd9ecf268ef3f69130fa269012318470d908978f6 (patch)
tree66550ddc707f4f2c1a562201b33a89140f581bc5 /http.c
parentcb506a8a69c953f7b87bb3ae099e0bed8218d3ab (diff)
downloadgit-d9ecf268ef3f69130fa269012318470d908978f6.tar.xz
odb: embed base source in the "files" backend
The "files" backend is implemented as a pointer in the `struct odb_source`. This contradicts our typical pattern for pluggable backends like we use it for example in the ref store or for object database streams, where we typically embed the generic base structure in the specialized implementation. This pattern has a couple of small benefits: - We avoid an extra allocation. - We hide implementation details in the generic structure. - We can easily downcast from a generic backend to the specialized structure and vice versa because the offsets are known at compile time. - It becomes trivial to identify locations where we depend on backend specific logic because the cast needs to be explicit. Refactor our "files" object database source to do the same and embed the `struct odb_source` in the `struct odb_source_files`. There are still a bunch of sites in our code base where we do have to access internals of the "files" backend. The intent is that those will go away over time, but this will certainly take a while. Meanwhile, provide a `odb_source_files_downcast()` function that can convert a generic source into a "files" source. As we only have a single source the downcast succeeds unconditionally for now. Eventually though the intent is to make the cast `BUG()` in case the caller requests to downcast a non-"files" backend to a "files" backend. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'http.c')
-rw-r--r--http.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/http.c b/http.c
index b44f493919..8ea1b9d1f6 100644
--- a/http.c
+++ b/http.c
@@ -2543,8 +2543,9 @@ cleanup:
void http_install_packfile(struct packed_git *p,
struct packfile_list *list_to_remove_from)
{
+ struct odb_source_files *files = odb_source_files_downcast(the_repository->objects->sources);
packfile_list_remove(list_to_remove_from, p);
- packfile_store_add_pack(the_repository->objects->sources->files->packed, p);
+ packfile_store_add_pack(files->packed, p);
}
struct http_pack_request *new_http_pack_request(