Re: [PATCH 2/7] setup: introduce object storage extension
- From
Karthik Nayak <karthik.188@gmail.com>
- Date
- Oct 19, 2026, 21:29 UTC
- Message-ID
- <CAOLa=ZQj0sZu7WRzmvgZx23ZeO1KBtOm6yWOLCzeVP_86zkTPQ@mail.gmail.com>
- In-Reply-To
- <20261019-b4-pks-odb-extension-v1-2-143a5963b77f@pks.im>
Patrick Steinhardt <ps@pks.im> writes:
[snip]
Show 22 quoted lines
> diff --git a/odb/source-files.c b/odb/source-files.c
> index 455f409db0..4a7cbbfd9b 100644
> --- a/odb/source-files.c
> +++ b/odb/source-files.c
> @@ -1235,6 +1235,7 @@ struct odb_files_dir *odb_source_files_find_dir(struct object_database *odb, con
> }
>
> struct odb_source_files *odb_source_files_new(struct object_database *odb,
> + const char *payload,
> enum odb_new_flags flags)
> {
> struct odb_source_files *files;
> @@ -1245,6 +1246,12 @@ struct odb_source_files *odb_source_files_new(struct object_database *odb,
> object_dir = xstrdup_or_null(getenv(DB_ENVIRONMENT));
> alternates = xstrdup_or_null(getenv(ALTERNATE_DB_ENVIRONMENT));
> }
> + if (!object_dir && payload) {
> + if (is_absolute_path(payload))
> + object_dir = xstrdup(payload);
> + else
> + object_dir = xstrfmt("%s/%s", odb->repo->commondir, payload);
> + }On the reference side, we use `strbuf_realpath()` to convert the relative paths to absolute paths, should we be doing that here too?
> if (!object_dir)
> object_dir = xstrfmt("%s/objects", odb->repo->commondir);
>[snip]
Show 10 quoted lines
> diff --git a/odb/source.c b/odb/source.c > index b25ef14df8..10abe33a26 100644 > --- a/odb/source.c > +++ b/odb/source.c > @@ -1,4 +1,5 @@ > #include "git-compat-util.h" > +#include "gettext.h" > #include "object-file.h" > #include "odb/source-files.h" > #include "odb/source.h"
Do we need this import? This commit seems to compile without it.
[snip]
Show 20 quoted lines
> diff --git a/t/t0001-init.sh b/t/t0001-init.sh > index f1d227f271..c7c464d3a2 100755 > --- a/t/t0001-init.sh > +++ b/t/t0001-init.sh > @@ -839,6 +839,36 @@ test_expect_success 'init with --ref-storage-format=garbage' ' > test_cmp expect err > ' > > +test_expect_success DEFAULT_REPO_FORMAT 'extensions.objectStorage is not allowed with repo version 0' ' > + test_when_finished "rm -rf objstorage" && > + git init objstorage && > + git -C objstorage config set extensions.objectStorage files && > + test_must_fail git -C objstorage rev-parse 2>err && > + test_grep "repo version is 0, but v1-only extension found" err > +' > + > +test_expect_success DEFAULT_REPO_FORMAT 'extensions.objectStorage with files backend' ' > + test_when_finished "rm -rf objstorage" && > + git init objstorage && > + git -C objstorage config set core.repositoryformatversion 1 &&
If we're doing this, do we still need DEFAULT_REPO_FORMAT?
Show 9 quoted lines
> + git -C objstorage config set extensions.objectStorage files && > + test_commit -C objstorage A && > + git -C objstorage rev-parse --verify HEAD > +' > + > +test_expect_success DEFAULT_REPO_FORMAT 'extensions.objectStorage with unknown backend' ' > + test_when_finished "rm -rf objstorage" && > + git init objstorage && > + git -C objstorage config set core.repositoryformatversion 1 &&
Same question here.
Show 9 quoted lines
> + git -C objstorage config set extensions.objectStorage garbage &&
> + test_must_fail git -C objstorage rev-parse 2>err &&
> + test_grep "invalid value for ${SQ}extensions.objectstorage${SQ}: ${SQ}garbage${SQ}" err &&
> +
> + git config --file objstorage/.git/config extensions.objectStorage garbage://payload &&
> + test_must_fail git -C objstorage rev-parse 2>err &&
> + test_grep "invalid value for ${SQ}extensions.objectstorage${SQ}: ${SQ}garbage://payload${SQ}" err
> +'
> +We should add tests for the files ODB with {valid, invalid} payload. We should probably also test absolute and relative paths in the valid flow.
Show 6 quoted lines
> test_expect_success MINGW 'core.hidedotfiles = false' ' > git config --global core.hidedotfiles false && > rm -rf newdir && > > -- > 2.56.0.269.g68944adf51.dirty