]> git.ipfire.org Git - thirdparty/git.git/commitdiff
odb/source-packed: wire up `read_object_stream()` callback
authorPatrick Steinhardt <ps@pks.im>
Wed, 17 Jun 2026 06:39:53 +0000 (08:39 +0200)
committerJunio C Hamano <gitster@pobox.com>
Wed, 17 Jun 2026 12:00:00 +0000 (05:00 -0700)
Wire up the `read_object_stream()` callback for the packed source and
call it in the "files" source via the `odb_source_read_object_stream()`
interface.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
odb/source-files.c
odb/source-packed.c
packfile.c
packfile.h

index 8cae35d25e73f98b7e89b6a8deecac65bf6e3de7..dff69d0e4e08c94c23709441e83dc8ef837cd2e1 100644 (file)
@@ -67,7 +67,7 @@ static int odb_source_files_read_object_stream(struct odb_read_stream **out,
                                               const struct object_id *oid)
 {
        struct odb_source_files *files = odb_source_files_downcast(source);
-       if (!packfile_store_read_object_stream(out, files->packed, oid) ||
+       if (!odb_source_read_object_stream(out, &files->packed->base, oid) ||
            !odb_source_read_object_stream(out, &files->loose->base, oid))
                return 0;
        return -1;
index f71a19473991d15065bd0c3b4526d77c31aaa32a..23d7149fe389eff8cfd7457adb5c0dfb456f58f1 100644 (file)
@@ -2,9 +2,11 @@
 #include "abspath.h"
 #include "chdir-notify.h"
 #include "dir.h"
+#include "git-zlib.h"
 #include "mergesort.h"
 #include "midx.h"
 #include "odb/source-packed.h"
+#include "odb/streaming.h"
 #include "packfile.h"
 
 int find_pack_entry(struct odb_source_packed *store,
@@ -66,6 +68,19 @@ static int odb_source_packed_read_object_info(struct odb_source *source,
        return 0;
 }
 
+static int odb_source_packed_read_object_stream(struct odb_read_stream **out,
+                                               struct odb_source *source,
+                                               const struct object_id *oid)
+{
+       struct odb_source_packed *packed = odb_source_packed_downcast(source);
+       struct pack_entry e;
+
+       if (!find_pack_entry(packed, oid, &e))
+               return -1;
+
+       return packfile_read_object_stream(out, oid, e.p, e.offset);
+}
+
 void (*report_garbage)(unsigned seen_bits, const char *path);
 
 static void report_helper(const struct string_list *list,
@@ -275,6 +290,7 @@ struct odb_source_packed *odb_source_packed_new(struct odb_source_files *parent)
        packed->base.close = odb_source_packed_close;
        packed->base.reprepare = odb_source_packed_reprepare;
        packed->base.read_object_info = odb_source_packed_read_object_info;
+       packed->base.read_object_stream = odb_source_packed_read_object_stream;
 
        if (!is_absolute_path(parent->base.path))
                chdir_notify_register(NULL, odb_source_packed_reparent, packed);
index 29530532bac51458899ccb325b6abf182128cfa7..42c84397eb266731795ab693b685a91f603c64e7 100644 (file)
@@ -2658,15 +2658,3 @@ int packfile_read_object_stream(struct odb_read_stream **out,
 
        return 0;
 }
-
-int packfile_store_read_object_stream(struct odb_read_stream **out,
-                                     struct odb_source_packed *store,
-                                     const struct object_id *oid)
-{
-       struct pack_entry e;
-
-       if (!find_pack_entry(store, oid, &e))
-               return -1;
-
-       return packfile_read_object_stream(out, oid, e.p, e.offset);
-}
index 25d458beb09f4216b41ef267b2c49644aaaaab53..dd97684e7098ddd6e15c138864c8021ba3f3f4ae 100644 (file)
@@ -124,10 +124,6 @@ static inline void repo_for_each_pack_data_next(struct repo_for_each_pack_data *
             ((p) = (eack_pack_data.entry ? eack_pack_data.entry->pack : NULL)); \
             repo_for_each_pack_data_next(&eack_pack_data))
 
-int packfile_store_read_object_stream(struct odb_read_stream **out,
-                                     struct odb_source_packed *store,
-                                     const struct object_id *oid);
-
 /*
  * Open the packfile and add it to the store if it isn't yet known. Returns
  * either the newly opened packfile or the preexisting packfile. Returns a