Re: [PATCH 17/17] odb/source: make `begin_transaction()` function pluggable
- From
Patrick Steinhardt <ps@pks.im>
- Date
- Mar 5, 2026, 13:24 UTC
- Message-ID
- <aamD8bMk0FLhR0dl@pks.im>
- In-Reply-To
- <aaiqJlmFgi92a0iC@denethor>
On Wed, Mar 04, 2026 at 04:01:32PM -0600, Justin Tobler wrote:
Show 29 quoted lines
> On 26/02/23 05:18PM, Patrick Steinhardt wrote:
> > Introduce a new callback function in `struct odb_source` to make the
> > function pluggable.
> >
> > Signed-off-by: Patrick Steinhardt <ps@pks.im>
> > ---
> > odb/source-files.c | 11 +++++++++++
> > odb/source.h | 27 +++++++++++++++++++++++++++
> > 2 files changed, 38 insertions(+)
> >
> > diff --git a/odb/source-files.c b/odb/source-files.c
> > index c32cd67b26..14cb9adeca 100644
> > --- a/odb/source-files.c
> > +++ b/odb/source-files.c
> > @@ -122,6 +122,16 @@ static int odb_source_files_write_object_stream(struct odb_source *source,
> > return odb_source_loose_write_stream(source, stream, len, oid);
> > }
> >
> > +static int odb_source_files_begin_transaction(struct odb_source *source,
> > + struct odb_transaction **out)
> > +{
> > + struct odb_transaction *tx = odb_transaction_files_begin(source);
>
> For a given ODB source, I would always expect that the resulting
> transaction would always be of the same source type. This makes me think
> that the underlying logic to handle transactions should also live along
> side the concrete ODB source implementation. Doesn't have to be a part
> of this series, but maybe in the future we should just merge
> odb_transaction_files_begin() into here.I'm not quite sure. The current transaction mechanism we have has two different modes: it either writes loose objects, or it writes all objects into packfiles. So arguably, we should split up this transaction so that we implement it on the respective sub-types of the "files" source and then have the "files" source route requests to the correct backend depending on the current use case.
But this area definitely needs more work, agreed.
Patrick