[PATCH v2 00/17] odb: make packed object source a proper `struct odb_source`
- From
Patrick Steinhardt <ps@pks.im>
- Date
- Jun 9, 2026, 08:50 UTC
- Message-ID
- <20260609-pks-odb-source-packed-v2-0-839089132c8b@pks.im>
- In-Reply-To
- <20260604-pks-odb-source-packed-v1-0-2e7ab31b4b5c@pks.im>
Hi,
this patch series converts the "packed" source into a proper `struct odb_source`. It's thus the equivalent to [1], which did the same thing for the "loose" source.
This series here is unfortunately a bit bigger, mostly because I'm also renaming `struct packfile_store` to `struct odb_source_packed`. Back when I introduced the packfile store I didn't yet have the full vision of how the final layout will look like, so I didn't have the foresight yet to call it `struct odb_source_packed`. But now that the layout has materialized I think it's sensible to adjust its naming to match all the other sources that we have.
Also: I don't have anything else in the pipeline anymore that moves around large pieces of our code in the vicinity of the object database. So after this series got merged, subsequent changes should be of a more incremental nature.
This series is built on top of 9ac3f193c0 (The 11th batch, 2026-06-02) with ps/odb-source-loose at ef4778bcba (odb/source-loose: drop pointer to the "files" source, 2026-06-01) merged into it.
Changes in v2:
- Split out `struct packfile_list` into a separate code unit to fix a
cyclic dependency between "packfile.h" and "odb/souurce-packed.h".
- Fix an extraneous newline.
- Link to v1: https://patch.msgid.link/20260604-pks-odb-source-packed-v1-0-2e7ab31b4b5c@pks.imThanks!
Patrick
[1]: <20260521-b4-pks-odb-source-loose-v1-0-6553b399be2d@pks.im>
---
Patrick Steinhardt (17):
packfile: rename `struct packfile_store` to `odb_source_packed`
packfile: split out packfile list logic
packfile: move packed source into "odb/" subsystem
odb/source-packed: store pointer to "files" instead of generic source
odb/source-packed: start converting to a proper `struct odb_source`
odb/source-packed: wire up `close()` callback
odb/source-packed: wire up `reprepare()` callback
packfile: use higher-level interface to implement `has_object_pack()`
odb/source-packed: wire up `read_object_info()` callback
odb/source-packed: wire up `read_object_stream()` callback
odb/source-packed: wire up `for_each_object()` callback
odb/source-packed: wire up `count_objects()` callback
odb/source-packed: wire up `find_abbrev_len()` callback
odb/source-packed: wire up `freshen_object()` callback
odb/source-packed: stub out remaining functions
midx: refactor interfaces to work on "packed" source
odb/source-packed: drop pointer to "files" parent sourceMakefile | 2 + builtin/cat-file.c | 4 +- builtin/grep.c | 2 +- builtin/multi-pack-index.c | 29 +- builtin/pack-objects.c | 7 +- builtin/repack.c | 8 +- commit-graph.c | 4 +- meson.build | 2 + midx-write.c | 34 +- midx.c | 118 +++---- midx.h | 30 +- odb/source-files.c | 20 +- odb/source-files.h | 4 +- odb/source-packed.c | 764 +++++++++++++++++++++++++++++++++++++++++++ odb/source-packed.h | 94 ++++++ odb/source.h | 3 + pack-bitmap.c | 8 +- pack-revindex.c | 6 +- packfile-list.c | 86 +++++ packfile-list.h | 28 ++ packfile.c | 784 +-------------------------------------------- packfile.h | 180 +---------- repack-geometry.c | 3 +- repack-midx.c | 9 +- repack.c | 6 +- t/helper/test-read-midx.c | 7 +- 26 files changed, 1163 insertions(+), 1079 deletions(-)
Range-diff versus v1:
1: 5fb0dcfef9 = 1: 8a5e5f5473 packfile: rename `struct packfile_store` to `odb_source_packed`
-: ---------- > 2: 179416a017 packfile: split out packfile list logic
2: a29ca59090 ! 3: 6e54f9f918 packfile: move packed source into "odb/" subsystem
@@ odb/source-packed.h (new)
+#define ODB_SOURCE_PACKED_H
+
+#include "odb/source.h"
++#include "packfile-list.h"
+#include "strmap.h"
+
-+struct packfile_list {
-+ struct packfile_list_entry *head, *tail;
-+};
-+
-+struct packfile_list_entry {
-+ struct packfile_list_entry *next;
-+ struct packed_git *pack;
-+};
-+
+/*
+ * A store that manages packfiles for a given object database.
+ */
@@ packfile.h
#include "odb/source-files.h"
+#include "odb/source-packed.h"
#include "oidset.h"
+ #include "packfile-list.h"
#include "repository.h"
-#include "strmap.h"
@@ packfile.h: struct packed_git {
char pack_name[FLEX_ARRAY]; /* more */
};
--struct packfile_list {
-- struct packfile_list_entry *head, *tail;
--};
--
--struct packfile_list_entry {
-- struct packfile_list_entry *next;
-- struct packed_git *pack;
--};
--
- void packfile_list_clear(struct packfile_list *list);
- void packfile_list_remove(struct packfile_list *list, struct packed_git *pack);
- void packfile_list_prepend(struct packfile_list *list, struct packed_git *pack);
-@@ packfile.h: void packfile_list_append(struct packfile_list *list, struct packed_git *pack);
- struct packed_git *packfile_list_find_oid(struct packfile_list_entry *packs,
- const struct object_id *oid);
-
-/*
- * A store that manages packfiles for a given object database.
- */
3: d0402d115b ! 4: 85ebdcb253 odb/source-packed: store pointer to "files" instead of generic source
@@ odb/source-packed.c
}
## odb/source-packed.h ##
-@@ odb/source-packed.h: struct packfile_list_entry {
+@@
* A store that manages packfiles for a given object database.
*/
struct odb_source_packed {
4: d92302b497 ! 5: 7d5605b9c7 odb/source-packed: start converting to a proper `struct odb_source`
@@ odb/source-packed.c
}
## odb/source-packed.h ##
-@@ odb/source-packed.h: struct packfile_list_entry {
+@@
* A store that manages packfiles for a given object database.
*/
struct odb_source_packed {
@@ packfile.c: int parse_pack_header_option(const char *in, unsigned char *out, uns
for (struct packfile_list_entry *e = store->packs.head; e; e = e->next) {
## packfile.h ##
-@@ packfile.h: void packfile_list_append(struct packfile_list *list, struct packed_git *pack);
- struct packed_git *packfile_list_find_oid(struct packfile_list_entry *packs,
- const struct object_id *oid);
+@@ packfile.h: struct packed_git {
+ char pack_name[FLEX_ARRAY]; /* more */
+ };
-/*
- * Free the packfile store and all its associated state. All packfiles
5: 9a51dac274 ! 6: 736dc22977 odb/source-packed: wire up `close()` callback
@@ packfile.c: int parse_pack_header_option(const char *in, unsigned char *out, uns
struct packed_git *pack;
## packfile.h ##
-@@ packfile.h: void packfile_list_append(struct packfile_list *list, struct packed_git *pack);
- struct packed_git *packfile_list_find_oid(struct packfile_list_entry *packs,
- const struct object_id *oid);
+@@ packfile.h: struct packed_git {
+ char pack_name[FLEX_ARRAY]; /* more */
+ };
-/*
- * Close all packfiles associated with this store. The packfiles won't be
6: b9571c28f1 ! 7: f2ec21206d odb/source-packed: wire up `reprepare()` callback
@@ packfile.c: int packfile_store_read_object_info(struct odb_source_packed *store,
return 1;
## packfile.h ##
-@@ packfile.h: void packfile_list_append(struct packfile_list *list, struct packed_git *pack);
- struct packed_git *packfile_list_find_oid(struct packfile_list_entry *packs,
- const struct object_id *oid);
+@@ packfile.h: struct packed_git {
+ char pack_name[FLEX_ARRAY]; /* more */
+ };
-/*
- * Prepare the packfile store by loading packfiles and multi-pack indices for
7: 703181be7e = 8: a41dbcf7d9 packfile: use higher-level interface to implement `has_object_pack()`
8: f1f1cb2044 = 9: 3fcdfc2686 odb/source-packed: wire up `read_object_info()` callback
9: 91fad0e9ad = 10: 7b301ce67d odb/source-packed: wire up `read_object_stream()` callback
10: 0dc3c1b836 = 11: 5298ddece5 odb/source-packed: wire up `for_each_object()` callback
11: 461be09a17 ! 12: 929d7ad5af odb/source-packed: wire up `count_objects()` callback
@@ odb/source-packed.c: static int odb_source_packed_for_each_object(struct odb_sou
+out:
+ return ret;
+}
-+
+
void (*report_garbage)(unsigned seen_bits, const char *path);
12: c206556286 ! 13: 5de59e451d odb/source-packed: wire up `find_abbrev_len()` callback
@@ odb/source-packed.c: static int odb_source_packed_count_objects(struct odb_sourc
+ *out = min_len;
+ return 0;
+}
-
++
void (*report_garbage)(unsigned seen_bits, const char *path);
+ static void report_helper(const struct string_list *list,
@@ odb/source-packed.c: struct odb_source_packed *odb_source_packed_new(struct odb_source_files *parent)
packed->base.read_object_stream = odb_source_packed_read_object_stream;
packed->base.for_each_object = odb_source_packed_for_each_object;
13: 3ee5394ce8 = 14: 8e7b0f746c odb/source-packed: wire up `freshen_object()` callback
14: 875ca3572a = 15: 52967e0d24 odb/source-packed: stub out remaining functions
15: 5bd35384d6 = 16: 68cf451c52 midx: refactor interfaces to work on "packed" source
16: d1a7ce9f17 ! 17: fbed40d82a odb/source-packed: drop pointer to "files" parent source
@@ odb/source-packed.c: struct odb_source_packed *odb_source_packed_new(struct odb_
return packed;
## odb/source-packed.h ##
-@@ odb/source-packed.h: struct packfile_list_entry {
+@@
*/
struct odb_source_packed {
struct odb_source base;--- base-commit: 06d49cec508464ced5d42541890ce5d749542a61 change-id: 20260602-pks-odb-source-packed-3826c352f059