[PATCH 00/16] odb: introduce "inmemory" source
- From
Patrick Steinhardt <ps@pks.im>
- Date
- Apr 3, 2026, 06:01 UTC
- Message-ID
- <20260403-b4-pks-odb-source-inmemory-v1-0-8b8d1abaa25e@pks.im>
Hi,
this patch series introduces the second object database source type, which is the "inmemory" source.
This source may seem somewhat odd at first: it always starts out empty, and any object written into it will only exist in memory until the process exits. But the source already serves a purpose in our codebase, where some commands, for example git-blame(1), write an in-memory worktree commit.
Furthermore, I think that going forward it can serve more purposes as we now have an easy way to write and read objects that will not get persisted. I could see that this may be useful when for example re-merging diffs. But eventually, once we have the object storage format extension wired up, callers might even want to manually set up an in-memory database as the primary ODB for write operations so that no data will be persisted in an arbitrary write.
Last but not least, this patch series also serves the purpose of eventually getting rid of the `struct object_info::whence` member. Instead, we'll simply yield the ODB source a specific object has been read from, together with some backend-specific data, which gives strictly more information compared to the status quo.
The series is based on cf2139f8e1 (The 24th batch, 2026-04-01) with ps/odb-cleanup at 109bcb7d1d (odb: drop unneeded headers and forward decls, 2026-04-01) merged into it.
Thanks!
Patrick
---
Patrick Steinhardt (16):
odb: introduce "inmemory" source
odb/source-inmemory: implement `free()` callback
odb: fix unnecessary call to `find_cached_object()`
odb/source-inmemory: implement `read_object_info()` callback
odb/source-inmemory: implement `read_object_stream()` callback
odb/source-inmemory: implement `write_object()` callback
odb/source-inmemory: implement `write_object_stream()` callback
cbtree: allow using arbitrary wrapper structures for nodes
oidtree: add ability to store data
odb/source-inmemory: convert to use oidtree
odb/source-inmemory: implement `for_each_object()` callback
odb/source-inmemory: implement `find_abbrev_len()` callback
odb/source-inmemory: implement `count_objects()` callback
odb/source-inmemory: implement `freshen_object()` callback
odb/source-inmemory: stub out remaining functions
odb: generic inmemory sourceMakefile | 1 + cbtree.c | 25 +++- cbtree.h | 11 +- loose.c | 2 +- meson.build | 1 + object-file.c | 3 +- odb.c | 82 ++--------- odb.h | 4 +- odb/source-inmemory.c | 375 +++++++++++++++++++++++++++++++++++++++++++++++ odb/source-inmemory.h | 33 +++++ odb/source.h | 3 + oidtree.c | 66 ++++++--- oidtree.h | 12 +- t/unit-tests/u-oidtree.c | 26 +++- 14 files changed, 529 insertions(+), 115 deletions(-)
--- base-commit: 3d05c3e2906489caa9f12f0af18dc233a6b8032c change-id: 20260401-b4-pks-odb-source-inmemory-7b17c83d9e43