Re: [PATCH v2 5/7] builtin/init: introduce handling of object storage format
- From
Karthik Nayak <karthik.188@gmail.com>
- Date
- Oct 21, 2026, 14:23 UTC
- Message-ID
- <CAOLa=ZRzu_7No085hEHnULo0L50y=ntx3MSkb-VbcywChdOPZA@mail.gmail.com>
- In-Reply-To
- <20261021-b4-pks-odb-extension-v2-5-8cf11b65eda8@pks.im>
Patrick Steinhardt <ps@pks.im> writes:
Show 6 quoted lines
> While the object storage format extension can already be configured > manually via git-config(1), this isn't exactly an ergonomic way of doing > so. For the reference storage format extension, users have a host of > options available to them. > > Introduce the equivalent options for the object storage format.
[snip]
Show 13 quoted lines
> diff --git a/setup.c b/setup.c > index 98140a7641..3d74f8eeed 100644 > --- a/setup.c > +++ b/setup.c > @@ -2466,7 +2466,8 @@ void initialize_repository_version(struct repository *repo, > */ > if (hash_algo != GIT_HASH_SHA1_LEGACY || > ref_storage_format != REF_STORAGE_FORMAT_FILES || > - repo->ref_storage_payload) > + repo->ref_storage_payload || > + strcmp(repo->object_storage_format, "files")) > target_version = GIT_REPO_VERSION_READ; >
Okay so this is what also sets the 'core.repositoryformatversion' config. I was specifically looking for that.
Does this mean that even for the files odb with a payload we need v1 of 'core.repositoryformatversion'?
Show 11 quoted lines
> if (hash_algo != GIT_HASH_SHA1_LEGACY && hash_algo != GIT_HASH_UNKNOWN) > @@ -2490,6 +2491,12 @@ void initialize_repository_version(struct repository *repo, > repo_config_set_gently(repo, "extensions.refstorage", NULL); > } > > + if (strcmp(repo->object_storage_format, "files")) > + repo_config_set(repo, "extensions.objectstorage", > + repo->object_storage_format); > + else if (reinit) > + repo_config_set_gently(repo, "extensions.objectstorage", NULL); > +
So this handled reinitializing the same repo. If there was a previously set object storage format, we unset it gently.
But, we already catch and error out if the extension before and after reinit differ, so this `else` block is not needed, no? Removing it passes all the tests in this patch.
Show 11 quoted lines
> if (reinit) {
> struct strbuf config = STRBUF_INIT;
> struct repository_format repo_fmt = REPOSITORY_FORMAT_INIT;
> @@ -2726,6 +2733,7 @@ static void separate_git_dir(struct repository *repo,
> struct default_format_config {
> int hash;
> enum ref_storage_format ref_storage_format;
> + char *object_storage_format;
> };
>
> static int read_default_format_config(const char *key, const char *value,[snip]
Show 5 quoted lines
> diff --git a/t/t0001-init.sh b/t/t0001-init.sh > index d080ab04a8..0da14e8f70 100755 > --- a/t/t0001-init.sh > +++ b/t/t0001-init.sh > @@ -898,6 +898,168 @@ test_expect_success DEFAULT_REPO_FORMAT 'GIT_OBJECT_STORAGE_FORMAT overrides ext
[snip]
Show 9 quoted lines
> + > +test_expect_success 'init with --object-storage-format=files://<relative-path>' ' > + test_when_finished "rm -rf objformat" && > + git init --object-storage-format=files://objs objformat && > + echo files://objs >expect && > + git -C objformat config get extensions.objectstorage >actual && > + test_cmp expect actual && > + echo 1 >expect && >
Okay what I asked before is expected, files with payload is v1. Makes sense.
Show 11 quoted lines
> + git -C objformat config get core.repositoryformatversion >actual && > + test_cmp expect actual && > + git -C objformat rev-parse --show-object-storage-format >actual && > + echo files://objs >expect && > + test_cmp expect actual && > + test_path_is_dir objformat/.git/objects && > + test_path_is_dir objformat/.git/objs && > + test_commit -C objformat A && > + git -C objformat rev-parse --verify HEAD && > + test_path_is_missing objformat/.git/objects/pack && > + test_path_is_dir objformat/.git/objs/pack
Super nit: some newlines in between would help improve readability of a few of these denser tests.
> +' > +
[snip]
Nice. I like the extensive testing done here.