From: Patrick Steinhardt <ps@pks.im>
To: Toon Claes <toon@iotcl.com>
Cc: git@vger.kernel.org, "brian m. carlson" <sandals@crustytoothpaste.net>
Subject: Re: [PATCH] setup: use SHA-256 when experimental features are enabled
Date: Tue, 1 Dec 2026 08:59:19 +0100 [thread overview]
Message-ID: <aw5-RGeiG-axDxX2@pks.im> (raw)
In-Reply-To: <20261201-toon-init-experimental-sha256-v1-1-eecd8454be9e@iotcl.com>
On Tue, Dec 01, 2026 at 07:47:09AM +0100, Toon Claes wrote:
> In 793b14e1c8 (setup: use "reftable" format when experimental features
> are enabled, 2025-07-04), git-init(1) learned to create new repositories
> with the reftable backend when "feature.experimental" is enabled, so
> that users can test the format that is planned to become the default in
> Git 3.0. The SHA-256 object format is also planned to become the default
> in Git 3.0, but "feature.experimental" does not affect the object
> format, so new repositories still use SHA-1.
Huh, interesting, I thought that "feature.experimental" already did
this!
> Teach "feature.experimental" to also make SHA-256 the default object
> format for new repositories. As with the ref storage format, this
> default can still be overridden by setting "init.defaultObjectFormat",
> setting the GIT_DEFAULT_HASH environment variable, or passing
> "--object-format=".
This makes a ton of sense. Now that we're moving closer to Git 3.0 we
should make sure to give upcoming breaking changes more exposure.
> diff --git a/setup.c b/setup.c
> index f9c03b6c47..d4c263d599 100644
> --- a/setup.c
> +++ b/setup.c
> @@ -2850,13 +2850,16 @@ static int read_default_format_config(const char *key, const char *value,
> }
>
> /*
> - * Enable the reftable format when "features.experimental" is enabled.
> - * "init.defaultRefStorageFormat" takes precedence over this setting.
> + * Enable the reftable format and the SHA-256 object format when
> + * "features.experimental" is enabled. "init.defaultRefStorageFormat"
> + * and "init.defaultObjectFormat" take precedence over this setting.
> */
> if (!strcmp(key, "feature.experimental") &&
> - cfg->ref_storage_format == REF_STORAGE_FORMAT_UNKNOWN &&
> git_config_bool(key, value)) {
> - cfg->ref_storage_format = REF_STORAGE_FORMAT_REFTABLE;
> + if (cfg->ref_storage_format == REF_STORAGE_FORMAT_UNKNOWN)
> + cfg->ref_storage_format = REF_STORAGE_FORMAT_REFTABLE;
> + if (cfg->hash == GIT_HASH_UNKNOWN)
> + cfg->hash = GIT_HASH_SHA256;
Looks straight-forward. And this function still knows to properly
override the hash in case "init.defaultObjectFormat" was set. Good.
> diff --git a/t/t0001-init.sh b/t/t0001-init.sh
> index 9e57a06cea..da73ae7395 100755
> --- a/t/t0001-init.sh
> +++ b/t/t0001-init.sh
> @@ -575,6 +575,40 @@ test_expect_success 'init warns about invalid init.defaultObjectFormat' '
> test_cmp expected actual
> '
>
> +test_expect_success 'init with feature.experimental=true uses sha256' '
> + test_when_finished "rm -rf repo" &&
> + test_config_global feature.experimental true &&
> + (
> + sane_unset GIT_DEFAULT_HASH &&
> + git init repo
> + ) &&
> + echo sha256 >expect &&
> + git -C repo rev-parse --show-object-format >actual &&
> + test_cmp expect actual
> +'
> +
> +test_expect_success 'init.defaultObjectFormat overrides feature.experimental=true' '
> + test_when_finished "rm -rf repo" &&
> + test_config_global feature.experimental true &&
> + test_config_global init.defaultObjectFormat sha1 &&
> + (
> + sane_unset GIT_DEFAULT_HASH &&
> + git init repo
> + ) &&
> + echo sha1 >expect &&
> + git -C repo rev-parse --show-object-format >actual &&
> + test_cmp expect actual
> +'
> +
> +test_expect_success 'GIT_DEFAULT_HASH overrides feature.experimental=true' '
> + test_when_finished "rm -rf repo" &&
> + test_config_global feature.experimental true &&
> + GIT_DEFAULT_HASH=sha1 git init repo &&
> + echo sha1 >expect &&
> + git -C repo rev-parse --show-object-format >actual &&
> + test_cmp expect actual
> +'
We could also verify that "--object-format=sha256" overrides
"feature.experimental", but eventually it becomes excessive.
Another thing we might want to test is whether git-clone(1) works as
expected with "feature.experimental" set when cloning a SHA1 repo. But
I'm somewhat sure that our test suite would probably catch such an issue
if it didn't.
So overall this looks good to me, thanks!
Patrick
next prev parent reply other threads:[~2026-12-01 7:59 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-01 6:47 [PATCH] setup: use SHA-256 when experimental features are enabled Toon Claes
2026-12-01 7:59 ` Patrick Steinhardt [this message]
2026-12-01 8:04 ` Patrick Steinhardt
2026-12-01 23:19 ` brian m. carlson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aw5-RGeiG-axDxX2@pks.im \
--to=ps@pks.im \
--cc=git@vger.kernel.org \
--cc=sandals@crustytoothpaste.net \
--cc=toon@iotcl.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.