🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.git
1 messages
1 total messages Started by "brian m. carlson" Tue, 01 Dec 2026 23:19
Re: [PATCH] setup: use SHA-256 when experimental features are enabled
#4235
Author: "brian m. carlson"
Date: Tue, 01 Dec 2026 23:19
85 lines
12607 bytes
--dfekXErJUD9RThE/
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On 2026-12-01 at 06:47:09, 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.
>=20
> 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=3D".
>=20
> Signed-off-by: Toon Claes <toon@iotcl.com>
> ---
> With the release of Git 3.0 being planned, I noticed SHA-256 isn't
> default-selected when "feature.experimental" is set. This small patch
> fixes that.
>=20
> This follows what Patrick did for the reftable backend in [1], which
> made "feature.experimental" select the reftable format for new
> repositories.
>=20
> There is a related topic in flight, bc/setup-default-hash-algo [2],
> which fixes the default hash algorithm not being applied by git-init(1)
> in WITH_BREAKING_CHANGES builds. It touches the same area of setup.c,
> but this patch does not depend on it and both merge cleanly together.

This seems like a sensible patch and a sensible default.  It looks good
to me.

> 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,
>  	}
> =20
>  	/*
> -	 * 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 =3D=3D REF_STORAGE_FORMAT_UNKNOWN &&
>  	    git_config_bool(key, value)) {
> -		cfg->ref_storage_format =3D REF_STORAGE_FORMAT_REFTABLE;
> +		if (cfg->ref_storage_format =3D=3D REF_STORAGE_FORMAT_UNKNOWN)
> +			cfg->ref_storage_format =3D REF_STORAGE_FORMAT_REFTABLE;
> +		if (cfg->hash =3D=3D GIT_HASH_UNKNOWN)
> +			cfg->hash =3D GIT_HASH_SHA256;

I was curious as to whether this would actually ever be set to
`GIT_HASH_UNKNOWN` and therefore whether this would actually work, given
the conversation I recently had with Junio, but the tests you wrote
answered that question for me, so thank you for those.
--=20
brian m. carlson (they/them)
Toronto, Ontario, CA
Speaking for myself only

--dfekXErJUD9RThE/
Content-Type: application/pgp-signature; name=signature.asc

-----BEGIN PGP SIGNATURE-----

wr0EABYKAG8FgmsPVfsJEHwMSWKIh6KBRxQAAAAAAB4AIHNhbHRAbm90YXRpb25z
LnNlcXVvaWEtcGdwLm9yZ1DOjAcs/2ObYfyhUpsjdexgMgIQZq8v3xTeLBfuHB2o
FiEECCzmip28ZfuD0cORfAxJYoiHooEAAGV9AQCQWHq9Ezbvky8g6a7e+WAUwOar
FZcLz/VAEfhFNPj2owEAwYfYiL3KuQP9kYUSS5/Eh7gz3DIcgCQTbLN1Za/MlQY=
=0p8B
-----END PGP SIGNATURE-----

--dfekXErJUD9RThE/--
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads