{"thread":{"id":"66966","subject":"[PATCH] setup: use SHA-256 when experimental features are enabled","startedAt":"2026-12-01T06:47:09Z","lastAt":"2026-12-02T07:02:56Z","messageCount":5,"participants":["Toon Claes","Patrick Steinhardt","brian m. carlson"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"559758","messageId":"20261201-toon-init-experimental-sha256-v1-1-eecd8454be9e@iotcl.com","threadId":"66966","inReplyTo":null,"subject":"[PATCH] setup: use SHA-256 when experimental features are enabled","fromName":"Toon Claes","fromEmail":"toon@iotcl.com","sentAt":"2026-12-01T06:47:09Z","receivedAt":"2026-12-01T06:47:09Z","isPatch":true,"sender":{"key":"toon@iotcl.com","avatar":"https://avatars.githubusercontent.com/u/121621?v=4"},"body":"In 793b14e1c8 (setup: use \"reftable\" format when experimental features\nare enabled, 2025-07-04), git-init(1) learned to create new repositories\nwith the reftable backend when \"feature.experimental\" is enabled, so\nthat users can test the format that is planned to become the default in\nGit 3.0. The SHA-256 object format is also planned to become the default\nin Git 3.0, but \"feature.experimental\" does not affect the object\nformat, so new repositories still use SHA-1.\n\nTeach \"feature.experimental\" to also make SHA-256 the default object\nformat for new repositories. As with the ref storage format, this\ndefault can still be overridden by setting \"init.defaultObjectFormat\",\nsetting the GIT_DEFAULT_HASH environment variable, or passing\n\"--object-format=\".\n\nSigned-off-by: Toon Claes <toon@iotcl.com>\n---\nWith the release of Git 3.0 being planned, I noticed SHA-256 isn't\ndefault-selected when \"feature.experimental\" is set. This small patch\nfixes that.\n\nThis follows what Patrick did for the reftable backend in [1], which\nmade \"feature.experimental\" select the reftable format for new\nrepositories.\n\nThere is a related topic in flight, bc/setup-default-hash-algo [2],\nwhich fixes the default hash algorithm not being applied by git-init(1)\nin WITH_BREAKING_CHANGES builds. It touches the same area of setup.c,\nbut this patch does not depend on it and both merge cleanly together.\n\n[1]: https://lore.kernel.org/git/20250703-pks-reftable-default-backend-v2-0-5a27e72a8c5e@pks.im/\n[2]: https://lore.kernel.org/git/20261124225952.1616547-1-sandals@crustytoothpaste.net/\n\nLaters,\nToon\n---\n Documentation/config/feature.adoc |  6 ++++++\n setup.c                           | 11 +++++++----\n t/t0001-init.sh                   | 34 ++++++++++++++++++++++++++++++++++\n 3 files changed, 47 insertions(+), 4 deletions(-)\n\ndiff --git a/Documentation/config/feature.adoc b/Documentation/config/feature.adoc\nindex e258770591..57e24724b4 100644\n--- a/Documentation/config/feature.adoc\n+++ b/Documentation/config/feature.adoc\n@@ -30,6 +30,12 @@ the reftable format for storing references. This new format solves issues with\n case-insensitive filesystems, compresses better and performs significantly\n better with many use cases. Refer to Documentation/technical/reftable.adoc for\n more information on this new storage format.\n++\n+* `init.defaultObjectFormat=sha256` causes newly initialized repositories to use\n+the SHA-256 object format. SHA-256 is planned to become the default hash\n+algorithm in Git 3.0. Note that repositories using SHA-256 cannot interoperate\n+with SHA-1 repositories, so some forges and third-party tools may not support\n+them yet.\n \n feature.manyFiles::\n \tEnable config options that optimize for repos with many files in the\ndiff --git a/setup.c b/setup.c\nindex f9c03b6c47..d4c263d599 100644\n--- a/setup.c\n+++ b/setup.c\n@@ -2850,13 +2850,16 @@ static int read_default_format_config(const char *key, const char *value,\n \t}\n \n \t/*\n-\t * Enable the reftable format when \"features.experimental\" is enabled.\n-\t * \"init.defaultRefStorageFormat\" takes precedence over this setting.\n+\t * Enable the reftable format and the SHA-256 object format when\n+\t * \"features.experimental\" is enabled. \"init.defaultRefStorageFormat\"\n+\t * and \"init.defaultObjectFormat\" take precedence over this setting.\n \t */\n \tif (!strcmp(key, \"feature.experimental\") &&\n-\t    cfg->ref_storage_format == REF_STORAGE_FORMAT_UNKNOWN &&\n \t    git_config_bool(key, value)) {\n-\t\tcfg->ref_storage_format = REF_STORAGE_FORMAT_REFTABLE;\n+\t\tif (cfg->ref_storage_format == REF_STORAGE_FORMAT_UNKNOWN)\n+\t\t\tcfg->ref_storage_format = REF_STORAGE_FORMAT_REFTABLE;\n+\t\tif (cfg->hash == GIT_HASH_UNKNOWN)\n+\t\t\tcfg->hash = GIT_HASH_SHA256;\n \t\tret = 0;\n \t\tgoto out;\n \t}\ndiff --git a/t/t0001-init.sh b/t/t0001-init.sh\nindex 9e57a06cea..da73ae7395 100755\n--- a/t/t0001-init.sh\n+++ b/t/t0001-init.sh\n@@ -575,6 +575,40 @@ test_expect_success 'init warns about invalid init.defaultObjectFormat' '\n \ttest_cmp expected actual\n '\n \n+test_expect_success 'init with feature.experimental=true uses sha256' '\n+\ttest_when_finished \"rm -rf repo\" &&\n+\ttest_config_global feature.experimental true &&\n+\t(\n+\t\tsane_unset GIT_DEFAULT_HASH &&\n+\t\tgit init repo\n+\t) &&\n+\techo sha256 >expect &&\n+\tgit -C repo rev-parse --show-object-format >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'init.defaultObjectFormat overrides feature.experimental=true' '\n+\ttest_when_finished \"rm -rf repo\" &&\n+\ttest_config_global feature.experimental true &&\n+\ttest_config_global init.defaultObjectFormat sha1 &&\n+\t(\n+\t\tsane_unset GIT_DEFAULT_HASH &&\n+\t\tgit init repo\n+\t) &&\n+\techo sha1 >expect &&\n+\tgit -C repo rev-parse --show-object-format >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'GIT_DEFAULT_HASH overrides feature.experimental=true' '\n+\ttest_when_finished \"rm -rf repo\" &&\n+\ttest_config_global feature.experimental true &&\n+\tGIT_DEFAULT_HASH=sha1 git init repo &&\n+\techo sha1 >expect &&\n+\tgit -C repo rev-parse --show-object-format >actual &&\n+\ttest_cmp expect actual\n+'\n+\n test_expect_success '--object-format overrides GIT_DEFAULT_HASH' '\n \ttest_when_finished \"rm -rf repo\" &&\n \tGIT_DEFAULT_HASH=sha1 git init --object-format=sha256 repo &&\n\n---\nbase-commit: 86e79b2795e3ce3b0ad7685edd368574b0c8b9f2\nchange-id: 20261201-toon-init-experimental-sha256-e7c30b2ef129\n\n\n"},{"id":"559763","messageId":"aw5-RGeiG-axDxX2@pks.im","threadId":"66966","inReplyTo":"20261201-toon-init-experimental-sha256-v1-1-eecd8454be9e@iotcl.com","subject":"Re: [PATCH] setup: use SHA-256 when experimental features are enabled","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-12-01T07:59:19Z","receivedAt":"2026-12-01T07:59:19Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Tue, Dec 01, 2026 at 07:47:09AM +0100, Toon Claes wrote:\n> In 793b14e1c8 (setup: use \"reftable\" format when experimental features\n> are enabled, 2025-07-04), git-init(1) learned to create new repositories\n> with the reftable backend when \"feature.experimental\" is enabled, so\n> that users can test the format that is planned to become the default in\n> Git 3.0. The SHA-256 object format is also planned to become the default\n> in Git 3.0, but \"feature.experimental\" does not affect the object\n> format, so new repositories still use SHA-1.\n\nHuh, interesting, I thought that \"feature.experimental\" already did\nthis!\n\n> Teach \"feature.experimental\" to also make SHA-256 the default object\n> format for new repositories. As with the ref storage format, this\n> default can still be overridden by setting \"init.defaultObjectFormat\",\n> setting the GIT_DEFAULT_HASH environment variable, or passing\n> \"--object-format=\".\n\nThis makes a ton of sense. Now that we're moving closer to Git 3.0 we\nshould make sure to give upcoming breaking changes more exposure.\n\n> diff --git a/setup.c b/setup.c\n> index f9c03b6c47..d4c263d599 100644\n> --- a/setup.c\n> +++ b/setup.c\n> @@ -2850,13 +2850,16 @@ static int read_default_format_config(const char *key, const char *value,\n>  \t}\n>  \n>  \t/*\n> -\t * Enable the reftable format when \"features.experimental\" is enabled.\n> -\t * \"init.defaultRefStorageFormat\" takes precedence over this setting.\n> +\t * Enable the reftable format and the SHA-256 object format when\n> +\t * \"features.experimental\" is enabled. \"init.defaultRefStorageFormat\"\n> +\t * and \"init.defaultObjectFormat\" take precedence over this setting.\n>  \t */\n>  \tif (!strcmp(key, \"feature.experimental\") &&\n> -\t    cfg->ref_storage_format == REF_STORAGE_FORMAT_UNKNOWN &&\n>  \t    git_config_bool(key, value)) {\n> -\t\tcfg->ref_storage_format = REF_STORAGE_FORMAT_REFTABLE;\n> +\t\tif (cfg->ref_storage_format == REF_STORAGE_FORMAT_UNKNOWN)\n> +\t\t\tcfg->ref_storage_format = REF_STORAGE_FORMAT_REFTABLE;\n> +\t\tif (cfg->hash == GIT_HASH_UNKNOWN)\n> +\t\t\tcfg->hash = GIT_HASH_SHA256;\n\nLooks straight-forward. And this function still knows to properly\noverride the hash in case \"init.defaultObjectFormat\" was set. Good.\n\n> diff --git a/t/t0001-init.sh b/t/t0001-init.sh\n> index 9e57a06cea..da73ae7395 100755\n> --- a/t/t0001-init.sh\n> +++ b/t/t0001-init.sh\n> @@ -575,6 +575,40 @@ test_expect_success 'init warns about invalid init.defaultObjectFormat' '\n>  \ttest_cmp expected actual\n>  '\n>  \n> +test_expect_success 'init with feature.experimental=true uses sha256' '\n> +\ttest_when_finished \"rm -rf repo\" &&\n> +\ttest_config_global feature.experimental true &&\n> +\t(\n> +\t\tsane_unset GIT_DEFAULT_HASH &&\n> +\t\tgit init repo\n> +\t) &&\n> +\techo sha256 >expect &&\n> +\tgit -C repo rev-parse --show-object-format >actual &&\n> +\ttest_cmp expect actual\n> +'\n> +\n> +test_expect_success 'init.defaultObjectFormat overrides feature.experimental=true' '\n> +\ttest_when_finished \"rm -rf repo\" &&\n> +\ttest_config_global feature.experimental true &&\n> +\ttest_config_global init.defaultObjectFormat sha1 &&\n> +\t(\n> +\t\tsane_unset GIT_DEFAULT_HASH &&\n> +\t\tgit init repo\n> +\t) &&\n> +\techo sha1 >expect &&\n> +\tgit -C repo rev-parse --show-object-format >actual &&\n> +\ttest_cmp expect actual\n> +'\n> +\n> +test_expect_success 'GIT_DEFAULT_HASH overrides feature.experimental=true' '\n> +\ttest_when_finished \"rm -rf repo\" &&\n> +\ttest_config_global feature.experimental true &&\n> +\tGIT_DEFAULT_HASH=sha1 git init repo &&\n> +\techo sha1 >expect &&\n> +\tgit -C repo rev-parse --show-object-format >actual &&\n> +\ttest_cmp expect actual\n> +'\n\nWe could also verify that \"--object-format=sha256\" overrides\n\"feature.experimental\", but eventually it becomes excessive.\n\nAnother thing we might want to test is whether git-clone(1) works as\nexpected with \"feature.experimental\" set when cloning a SHA1 repo. But\nI'm somewhat sure that our test suite would probably catch such an issue\nif it didn't.\n\nSo overall this looks good to me, thanks!\n\nPatrick\n\n"},{"id":"559766","messageId":"aw5_gkjA9d1O2lc0@pks.im","threadId":"66966","inReplyTo":"aw5-RGeiG-axDxX2@pks.im","subject":"Re: [PATCH] setup: use SHA-256 when experimental features are enabled","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-12-01T08:04:18Z","receivedAt":"2026-12-01T08:04:18Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Tue, Dec 01, 2026 at 08:59:19AM +0100, Patrick Steinhardt wrote:\n> On Tue, Dec 01, 2026 at 07:47:09AM +0100, Toon Claes wrote:\n> > In 793b14e1c8 (setup: use \"reftable\" format when experimental features\n> > are enabled, 2025-07-04), git-init(1) learned to create new repositories\n> > with the reftable backend when \"feature.experimental\" is enabled, so\n> > that users can test the format that is planned to become the default in\n> > Git 3.0. The SHA-256 object format is also planned to become the default\n> > in Git 3.0, but \"feature.experimental\" does not affect the object\n> > format, so new repositories still use SHA-1.\n> \n> Huh, interesting, I thought that \"feature.experimental\" already did\n> this!\n> \n> > Teach \"feature.experimental\" to also make SHA-256 the default object\n> > format for new repositories. As with the ref storage format, this\n> > default can still be overridden by setting \"init.defaultObjectFormat\",\n> > setting the GIT_DEFAULT_HASH environment variable, or passing\n> > \"--object-format=\".\n> \n> This makes a ton of sense. Now that we're moving closer to Git 3.0 we\n> should make sure to give upcoming breaking changes more exposure.\n> \n> > diff --git a/setup.c b/setup.c\n> > index f9c03b6c47..d4c263d599 100644\n> > --- a/setup.c\n> > +++ b/setup.c\n> > @@ -2850,13 +2850,16 @@ static int read_default_format_config(const char *key, const char *value,\n> >  \t}\n> >  \n> >  \t/*\n> > -\t * Enable the reftable format when \"features.experimental\" is enabled.\n> > -\t * \"init.defaultRefStorageFormat\" takes precedence over this setting.\n> > +\t * Enable the reftable format and the SHA-256 object format when\n> > +\t * \"features.experimental\" is enabled. \"init.defaultRefStorageFormat\"\n> > +\t * and \"init.defaultObjectFormat\" take precedence over this setting.\n> >  \t */\n> >  \tif (!strcmp(key, \"feature.experimental\") &&\n> > -\t    cfg->ref_storage_format == REF_STORAGE_FORMAT_UNKNOWN &&\n> >  \t    git_config_bool(key, value)) {\n> > -\t\tcfg->ref_storage_format = REF_STORAGE_FORMAT_REFTABLE;\n> > +\t\tif (cfg->ref_storage_format == REF_STORAGE_FORMAT_UNKNOWN)\n> > +\t\t\tcfg->ref_storage_format = REF_STORAGE_FORMAT_REFTABLE;\n> > +\t\tif (cfg->hash == GIT_HASH_UNKNOWN)\n> > +\t\t\tcfg->hash = GIT_HASH_SHA256;\n> \n> Looks straight-forward. And this function still knows to properly\n> override the hash in case \"init.defaultObjectFormat\" was set. Good.\n> \n> > diff --git a/t/t0001-init.sh b/t/t0001-init.sh\n> > index 9e57a06cea..da73ae7395 100755\n> > --- a/t/t0001-init.sh\n> > +++ b/t/t0001-init.sh\n> > @@ -575,6 +575,40 @@ test_expect_success 'init warns about invalid init.defaultObjectFormat' '\n> >  \ttest_cmp expected actual\n> >  '\n> >  \n> > +test_expect_success 'init with feature.experimental=true uses sha256' '\n> > +\ttest_when_finished \"rm -rf repo\" &&\n> > +\ttest_config_global feature.experimental true &&\n> > +\t(\n> > +\t\tsane_unset GIT_DEFAULT_HASH &&\n> > +\t\tgit init repo\n> > +\t) &&\n> > +\techo sha256 >expect &&\n> > +\tgit -C repo rev-parse --show-object-format >actual &&\n> > +\ttest_cmp expect actual\n> > +'\n> > +\n> > +test_expect_success 'init.defaultObjectFormat overrides feature.experimental=true' '\n> > +\ttest_when_finished \"rm -rf repo\" &&\n> > +\ttest_config_global feature.experimental true &&\n> > +\ttest_config_global init.defaultObjectFormat sha1 &&\n> > +\t(\n> > +\t\tsane_unset GIT_DEFAULT_HASH &&\n> > +\t\tgit init repo\n> > +\t) &&\n> > +\techo sha1 >expect &&\n> > +\tgit -C repo rev-parse --show-object-format >actual &&\n> > +\ttest_cmp expect actual\n> > +'\n> > +\n> > +test_expect_success 'GIT_DEFAULT_HASH overrides feature.experimental=true' '\n> > +\ttest_when_finished \"rm -rf repo\" &&\n> > +\ttest_config_global feature.experimental true &&\n> > +\tGIT_DEFAULT_HASH=sha1 git init repo &&\n> > +\techo sha1 >expect &&\n> > +\tgit -C repo rev-parse --show-object-format >actual &&\n> > +\ttest_cmp expect actual\n> > +'\n> \n> We could also verify that \"--object-format=sha256\" overrides\n> \"feature.experimental\", but eventually it becomes excessive.\n> \n> Another thing we might want to test is whether git-clone(1) works as\n> expected with \"feature.experimental\" set when cloning a SHA1 repo. But\n> I'm somewhat sure that our test suite would probably catch such an issue\n> if it didn't.\n> \n> So overall this looks good to me, thanks!\n\nAh, one more note: this should probably land after [1], as we would\notherwise potentially reinitialize a repository with the wrong hash if\n\"feature.experimental\" was set.\n\nPatrick\n\n[1]: <20261124225952.1616547-1-sandals@crustytoothpaste.net>\n\n"},{"id":"559843","messageId":"aw9V-9vK1ut5MggZ@fruit.crustytoothpaste.net","threadId":"66966","inReplyTo":"20261201-toon-init-experimental-sha256-v1-1-eecd8454be9e@iotcl.com","subject":"Re: [PATCH] setup: use SHA-256 when experimental features are enabled","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2026-12-01T23:19:23Z","receivedAt":"2026-12-01T23:19:23Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On 2026-12-01 at 06:47:09, Toon Claes wrote:\n> In 793b14e1c8 (setup: use \"reftable\" format when experimental features\n> are enabled, 2025-07-04), git-init(1) learned to create new repositories\n> with the reftable backend when \"feature.experimental\" is enabled, so\n> that users can test the format that is planned to become the default in\n> Git 3.0. The SHA-256 object format is also planned to become the default\n> in Git 3.0, but \"feature.experimental\" does not affect the object\n> format, so new repositories still use SHA-1.\n> \n> Teach \"feature.experimental\" to also make SHA-256 the default object\n> format for new repositories. As with the ref storage format, this\n> default can still be overridden by setting \"init.defaultObjectFormat\",\n> setting the GIT_DEFAULT_HASH environment variable, or passing\n> \"--object-format=\".\n> \n> Signed-off-by: Toon Claes <toon@iotcl.com>\n> ---\n> With the release of Git 3.0 being planned, I noticed SHA-256 isn't\n> default-selected when \"feature.experimental\" is set. This small patch\n> fixes that.\n> \n> This follows what Patrick did for the reftable backend in [1], which\n> made \"feature.experimental\" select the reftable format for new\n> repositories.\n> \n> There is a related topic in flight, bc/setup-default-hash-algo [2],\n> which fixes the default hash algorithm not being applied by git-init(1)\n> in WITH_BREAKING_CHANGES builds. It touches the same area of setup.c,\n> but this patch does not depend on it and both merge cleanly together.\n\nThis seems like a sensible patch and a sensible default.  It looks good\nto me.\n\n> diff --git a/setup.c b/setup.c\n> index f9c03b6c47..d4c263d599 100644\n> --- a/setup.c\n> +++ b/setup.c\n> @@ -2850,13 +2850,16 @@ static int read_default_format_config(const char *key, const char *value,\n>  \t}\n>  \n>  \t/*\n> -\t * Enable the reftable format when \"features.experimental\" is enabled.\n> -\t * \"init.defaultRefStorageFormat\" takes precedence over this setting.\n> +\t * Enable the reftable format and the SHA-256 object format when\n> +\t * \"features.experimental\" is enabled. \"init.defaultRefStorageFormat\"\n> +\t * and \"init.defaultObjectFormat\" take precedence over this setting.\n>  \t */\n>  \tif (!strcmp(key, \"feature.experimental\") &&\n> -\t    cfg->ref_storage_format == REF_STORAGE_FORMAT_UNKNOWN &&\n>  \t    git_config_bool(key, value)) {\n> -\t\tcfg->ref_storage_format = REF_STORAGE_FORMAT_REFTABLE;\n> +\t\tif (cfg->ref_storage_format == REF_STORAGE_FORMAT_UNKNOWN)\n> +\t\t\tcfg->ref_storage_format = REF_STORAGE_FORMAT_REFTABLE;\n> +\t\tif (cfg->hash == GIT_HASH_UNKNOWN)\n> +\t\t\tcfg->hash = GIT_HASH_SHA256;\n\nI was curious as to whether this would actually ever be set to\n`GIT_HASH_UNKNOWN` and therefore whether this would actually work, given\nthe conversation I recently had with Junio, but the tests you wrote\nanswered that question for me, so thank you for those.\n-- \nbrian m. carlson (they/them)\nToronto, Ontario, CA\nSpeaking for myself only\n"},{"id":"559851","messageId":"87ld68qi5b.fsf@dev.null.iotcl.com.invalid","threadId":"66966","inReplyTo":"aw5-RGeiG-axDxX2@pks.im","subject":"Re: [PATCH] setup: use SHA-256 when experimental features are enabled","fromName":"Toon Claes","fromEmail":"toon@iotcl.com","sentAt":"2026-12-02T07:02:56Z","receivedAt":"2026-12-02T07:02:56Z","isPatch":true,"sender":{"key":"toon@iotcl.com","avatar":"https://avatars.githubusercontent.com/u/121621?v=4"},"body":"Patrick Steinhardt <ps@pks.im> writes:\n\n> On Tue, Dec 01, 2026 at 07:47:09AM +0100, Toon Claes wrote:\n>> In 793b14e1c8 (setup: use \"reftable\" format when experimental features\n>> are enabled, 2025-07-04), git-init(1) learned to create new repositories\n>> with the reftable backend when \"feature.experimental\" is enabled, so\n>> that users can test the format that is planned to become the default in\n>> Git 3.0. The SHA-256 object format is also planned to become the default\n>> in Git 3.0, but \"feature.experimental\" does not affect the object\n>> format, so new repositories still use SHA-1.\n>\n> Huh, interesting, I thought that \"feature.experimental\" already did\n> this!\n\nWell yes, I was surprised as well.\n\n>> Teach \"feature.experimental\" to also make SHA-256 the default object\n>> format for new repositories. As with the ref storage format, this\n>> default can still be overridden by setting \"init.defaultObjectFormat\",\n>> setting the GIT_DEFAULT_HASH environment variable, or passing\n>> \"--object-format=\".\n>\n> This makes a ton of sense. Now that we're moving closer to Git 3.0 we\n> should make sure to give upcoming breaking changes more exposure.\n>\n>> diff --git a/setup.c b/setup.c\n>> index f9c03b6c47..d4c263d599 100644\n>> --- a/setup.c\n>> +++ b/setup.c\n>> @@ -2850,13 +2850,16 @@ static int read_default_format_config(const char *key, const char *value,\n>>  \t}\n>>  \n>>  \t/*\n>> -\t * Enable the reftable format when \"features.experimental\" is enabled.\n>> -\t * \"init.defaultRefStorageFormat\" takes precedence over this setting.\n>> +\t * Enable the reftable format and the SHA-256 object format when\n>> +\t * \"features.experimental\" is enabled. \"init.defaultRefStorageFormat\"\n>> +\t * and \"init.defaultObjectFormat\" take precedence over this setting.\n>>  \t */\n>>  \tif (!strcmp(key, \"feature.experimental\") &&\n>> -\t    cfg->ref_storage_format == REF_STORAGE_FORMAT_UNKNOWN &&\n>>  \t    git_config_bool(key, value)) {\n>> -\t\tcfg->ref_storage_format = REF_STORAGE_FORMAT_REFTABLE;\n>> +\t\tif (cfg->ref_storage_format == REF_STORAGE_FORMAT_UNKNOWN)\n>> +\t\t\tcfg->ref_storage_format = REF_STORAGE_FORMAT_REFTABLE;\n>> +\t\tif (cfg->hash == GIT_HASH_UNKNOWN)\n>> +\t\t\tcfg->hash = GIT_HASH_SHA256;\n>\n> Looks straight-forward. And this function still knows to properly\n> override the hash in case \"init.defaultObjectFormat\" was set. Good.\n>\n>> diff --git a/t/t0001-init.sh b/t/t0001-init.sh\n>> index 9e57a06cea..da73ae7395 100755\n>> --- a/t/t0001-init.sh\n>> +++ b/t/t0001-init.sh\n>> @@ -575,6 +575,40 @@ test_expect_success 'init warns about invalid init.defaultObjectFormat' '\n>>  \ttest_cmp expected actual\n>>  '\n>>  \n>> +test_expect_success 'init with feature.experimental=true uses sha256' '\n>> +\ttest_when_finished \"rm -rf repo\" &&\n>> +\ttest_config_global feature.experimental true &&\n>> +\t(\n>> +\t\tsane_unset GIT_DEFAULT_HASH &&\n>> +\t\tgit init repo\n>> +\t) &&\n>> +\techo sha256 >expect &&\n>> +\tgit -C repo rev-parse --show-object-format >actual &&\n>> +\ttest_cmp expect actual\n>> +'\n>> +\n>> +test_expect_success 'init.defaultObjectFormat overrides feature.experimental=true' '\n>> +\ttest_when_finished \"rm -rf repo\" &&\n>> +\ttest_config_global feature.experimental true &&\n>> +\ttest_config_global init.defaultObjectFormat sha1 &&\n>> +\t(\n>> +\t\tsane_unset GIT_DEFAULT_HASH &&\n>> +\t\tgit init repo\n>> +\t) &&\n>> +\techo sha1 >expect &&\n>> +\tgit -C repo rev-parse --show-object-format >actual &&\n>> +\ttest_cmp expect actual\n>> +'\n>> +\n>> +test_expect_success 'GIT_DEFAULT_HASH overrides feature.experimental=true' '\n>> +\ttest_when_finished \"rm -rf repo\" &&\n>> +\ttest_config_global feature.experimental true &&\n>> +\tGIT_DEFAULT_HASH=sha1 git init repo &&\n>> +\techo sha1 >expect &&\n>> +\tgit -C repo rev-parse --show-object-format >actual &&\n>> +\ttest_cmp expect actual\n>> +'\n>\n> We could also verify that \"--object-format=sha256\" overrides\n> \"feature.experimental\", but eventually it becomes excessive.\n\nI'm not convinced there is any value in adding such test.\n\n> Another thing we might want to test is whether git-clone(1) works as\n> expected with \"feature.experimental\" set when cloning a SHA1 repo. But\n> I'm somewhat sure that our test suite would probably catch such an issue\n> if it didn't.\n\nEuhm, that's actually not a bad idea, because test-lib.sh sets\nGIT_DEFAULT_HASH, so I'm not sure such test case already exists.\n\n-- \nLaters,\nToon\n\n"}]}