Re: [PATCH 02/17] odb: introduce "files" source
- From
Karthik Nayak <karthik.188@gmail.com>
- Date
- Mar 5, 2026, 10:20 UTC
- Message-ID
- <CAOLa=ZSz=5KJvWLavfGdi3g_ETdOpBi+iYXM15p6N3dnyLX6Og@mail.gmail.com>
- In-Reply-To
- <20260223-b4-pks-odb-source-pluggable-v1-2-253bac1db598@pks.im>
Patrick Steinhardt <ps@pks.im> writes:
Show 9 quoted lines
> Introduce a new "files" object database source. This source encapsulates > access to both loose object files and the packfile store, similar to how > the "files" backend for refs encapsulates access to loose refs and the > packed-refs file. > > Note that for now the "files" source is still a direct member of a > `struct odb_source`. This architecture will be reversed in the next > commit so that the files source contains a `struct odb_source`. >
Okay, so peeking ahead, we will follow the same format as in the refs DB, but this is an intermediate step in that direction.
Show 27 quoted lines
> diff --git a/odb/source-files.c b/odb/source-files.c
> new file mode 100644
> index 0000000000..cbdaa6850f
> --- /dev/null
> +++ b/odb/source-files.c
> @@ -0,0 +1,23 @@
> +#include "git-compat-util.h"
> +#include "object-file.h"
> +#include "odb/source-files.h"
> +#include "packfile.h"
> +
> +void odb_source_files_free(struct odb_source_files *files)
> +{
> + if (!files)
> + return;
> + odb_source_loose_free(files->loose);
> + packfile_store_free(files->packed);
> + free(files);
> +}
> +
> +struct odb_source_files *odb_source_files_new(struct odb_source *source)
> +{
> + struct odb_source_files *files;
> + CALLOC_ARRAY(files, 1);
> + files->source = source;
> + files->loose = odb_source_loose_new(source);
> + files->packed = packfile_store_new(source);Instead of defining `loose` and `packed` as part of the `obd_source`, we move it specifically to the `obd_source->files`.
> + return files; > +}
The rest of the patch is just variable swapping, makes sense!