odb/source-packed: wire up `read_object_stream()` callback
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>
Patrick Steinhardt committed
Jun 17, 2026 at 08:39 UTC
83f3a2b91b44d4a39bce371a7580b0ad853df8a2
4 files changed
+17
-17
odb/source-files.c
+1
-1
@@ -67,7 +67,7 @@ static int odb_source_files_read_object_stream(struct odb_read_stream **out,
67
const struct object_id *oid)
68
{
69
struct odb_source_files *files = odb_source_files_downcast(source);
70
- if (!packfile_store_read_object_stream(out, files->packed, oid) ||
70
+ if (!odb_source_read_object_stream(out, &files->packed->base, oid) ||
71
!odb_source_read_object_stream(out, &files->loose->base, oid))
72
return 0;
73
return -1;
odb/source-packed.c
+16
@@ -2,9 +2,11 @@
2
#include "abspath.h"
3
#include "chdir-notify.h"
4
#include "dir.h"
5
+#include "git-zlib.h"
6
#include "mergesort.h"
7
#include "midx.h"
8
#include "odb/source-packed.h"
9
+#include "odb/streaming.h"
10
#include "packfile.h"
11
12
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,
68
return 0;
69
}
70
71
+static int odb_source_packed_read_object_stream(struct odb_read_stream **out,
72
+ struct odb_source *source,
73
+ const struct object_id *oid)
74
+{
75
+ struct odb_source_packed *packed = odb_source_packed_downcast(source);
76
+ struct pack_entry e;
77
+
78
+ if (!find_pack_entry(packed, oid, &e))
79
+ return -1;
80
+
81
+ return packfile_read_object_stream(out, oid, e.p, e.offset);
82
+}
83
+
84
void (*report_garbage)(unsigned seen_bits, const char *path);
85
86
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)
290
packed->base.close = odb_source_packed_close;
291
packed->base.reprepare = odb_source_packed_reprepare;
292
packed->base.read_object_info = odb_source_packed_read_object_info;
293
+ packed->base.read_object_stream = odb_source_packed_read_object_stream;
294
295
if (!is_absolute_path(parent->base.path))
296
chdir_notify_register(NULL, odb_source_packed_reparent, packed);
packfile.c
-12
@@ -2658,15 +2658,3 @@ int packfile_read_object_stream(struct odb_read_stream **out,
2658
2659
return 0;
2660
}
2661
-
2662
-int packfile_store_read_object_stream(struct odb_read_stream **out,
2663
- struct odb_source_packed *store,
2664
- const struct object_id *oid)
2665
-{
2666
- struct pack_entry e;
2667
-
2668
- if (!find_pack_entry(store, oid, &e))
2669
- return -1;
2670
-
2671
- return packfile_read_object_stream(out, oid, e.p, e.offset);
2672
-}
packfile.h
-4
@@ -124,10 +124,6 @@ static inline void repo_for_each_pack_data_next(struct repo_for_each_pack_data *
124
((p) = (eack_pack_data.entry ? eack_pack_data.entry->pack : NULL)); \
125
repo_for_each_pack_data_next(&eack_pack_data))
126
127
-int packfile_store_read_object_stream(struct odb_read_stream **out,
128
- struct odb_source_packed *store,
129
- const struct object_id *oid);
130
-
127
/*
128
* Open the packfile and add it to the store if it isn't yet known. Returns
129
* either the newly opened packfile or the preexisting packfile. Returns a