From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=91.218.175.97 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796194987; b=PRt6Lok7May0vI7PIJwxHgCFkgHm3Vx4+97TSFS1Q0gUkRvDO1uqtoEAIMY/SDzKT8va SXMh3uouKZOAZJeiPQJ1WklKvwy8FEoqTqHa36HlcbmG5wmbI0T2JqmM43uerWckRSjOv ws4Iacjo9dlF2q+CPxM9Na3EjG2Y2l+FXvc8PqBlJMzC+e7/6jEN2p5or6lUyadqzP0TX parQgB3c1BWvrAeSVOOxUuCWddW7v8lEP++L6K00XGgitScO5D/zVE86AlEcpGBJn07DE Pyz3DfNp9LIGsC+uq1d7T7CXbmValjc3iOAH7fHvP5kKQI1UUC3bBe81AX/STM91UPA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796194987; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:From:To:Cc:Subject:In-Reply-To: References:Date:Message-ID:MIME-Version:Content-Type; bh=RlG2suHh4ydUboPsuWAzjqHysra8wUMsWzIBpdI425Y=; b=mmDXXkqlifJOlojeS3bVOtd6EovfPvd6CMr9ska1UWhQyeec+3rgXuzNtbEMFc1pd2wp 9kIgwuXj4dP+fWCAgFp9SmGKi8i5R8PudYY4XyTDgw+5AVsIMCYSR1O/hL/6PrgsWxxt+ 24u/D8Bxu6gNUoiTORdraWtgHIS3w1UsNUV+1NKxwRqqVojYttb8itzl30W7FW4PCN7os I62FE/ZXiDbHL8y/GHv8CkCsZYW1CFflXUpGzDuSAQm836IWlDt7/Pl594/CkayIhmzon 1VgDh91qvCrCy4JHkY8HuyUuCeOo9zu4WC0THA6rsQKqjH2UF2dPetAFlhBsP1jDblw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=iotcl.com; spf=fail smtp.mailfrom=iotcl.com; dkim=pass header.d=iotcl.com header.i=@iotcl.com header.a=rsa-sha256 header.s=key1 header.b=nUafei99; arc=none smtp.remote-ip=91.218.175.97 Received: from mta0.migadu.com (out-97.mta0.migadu.com [91.218.175.97]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DA3A0606A31A for ; Wed, 2 Dec 2026 07:03:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org DA3A0606A31A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=iotcl.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=iotcl.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=iotcl.com header.i=@iotcl.com header.a=rsa-sha256 header.s=key1 header.b=nUafei99 X-Envelope-To: git@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=xAi41A7hOZOTyY1OvUcNvdhDPXWLeQjFw2A6wG0jiJk=; c=simple/simple; d=iotcl.com; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1796194983; v=1; x=1796799783; b=nUafei99uH/Fv2m92+5akd8zCR5HurMHYvMAPcCFBy8fyjugdtBqT2PvsedH1++Dpu8o+4os wiG+JIgnt/qr+hcCSoqrZ7lS6g0x0ToGWIzq+KPht1uc7ZvIf2yyA9mKboo50KXQBmApsFFjJfM lEcyF+B+TywuStdBXcOiGXOY= X-Envelope-To: git@vger.kernel.org Received: by mta11.migadu.com with ESMTPS id edabfddc0df8f41f; Wed, 02 Dec 2026 07:03:03 +0000 X-Mizu-Trace-ID: edabfddc0df8f41f X-Migadu-Flow: FLOW_OUT From: Toon Claes To: Patrick Steinhardt Cc: git@vger.kernel.org, "brian m. carlson" Subject: Re: [PATCH] setup: use SHA-256 when experimental features are enabled In-Reply-To: References: <20261201-toon-init-experimental-sha256-v1-1-eecd8454be9e@iotcl.com> Date: Wed, 02 Dec 2026 08:02:56 +0100 Message-ID: <87ld68qi5b.fsf@dev.null.iotcl.com.invalid> X-Mailing-List: git@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain Patrick Steinhardt writes: > 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! Well yes, I was surprised as well. >> 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. I'm not convinced there is any value in adding such test. > 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. Euhm, that's actually not a bad idea, because test-lib.sh sets GIT_DEFAULT_HASH, so I'm not sure such test case already exists. -- Laters, Toon