Thread View: linux.kernel.git
21 messages
21 total messages
Started by Adam Dinwoodie
Fri, 06 Nov 2026 16:50
Default object format for new repositories in Git v3
Author: Adam Dinwoodie
Date: Fri, 06 Nov 2026 16:50
Date: Fri, 06 Nov 2026 16:50
69 lines
14986 bytes
14986 bytes
--00000000000088b7c7065f9e691f Content-Type: text/plain; charset="UTF-8" Hi folks, As part of preparing for Git v3, in particular for Nixpkgs, I've been running a bunch of tests using Git built with `WITH_BREAKING_CHANGES=1`. Somewhat to my surprise, `git init` seems to still be creating new repositories using sha1 rather than sha256. Is this expected? For reference, I've attached the test script I've produced as a repro that can be run from the root of a Git checkout, although it does require Nix. I've confirmed the behaviour at v2.56.0, next (972d6e3ab651d838b30a8d5d70d8ef6ced05a986) and main (0ffa3e35c7c82ab8d0de226149fb03b3f7674d05). For a simpler repro that doesn't require Nix, build Git with `WITH_BREAKING_CHANGES=1`, then run: ``` git init tmpdir git -C tmpdir rev-parse --show-object-format ``` This will print "sha1", when I'd expect "sha256". --00000000000088b7c7065f9e691f Content-Type: text/x-sh; charset="US-ASCII"; name="test.sh" Content-Disposition: attachment; filename="test.sh" Content-Transfer-Encoding: base64 Content-ID: <f_mw57m6jw0> X-Attachment-Id: f_mw57m6jw0 IyEvdXNyL2Jpbi9lbnYgbml4CiMhbml4IHNoZWxsCiMhbml4IC0tb3ZlcnJpZGUtZmxha2Ugbml4 cGtncyBodHRwczovL3JlbGVhc2VzLm5peG9zLm9yZy9uaXhvcy91bnN0YWJsZS9uaXhvcy0yNi4x MXByZTExMDUwMzcuMWM4OTA4M2U0NTFlL25peGV4cHJzLnRhci56c3QKIyFuaXggLS1pZ25vcmUt ZW52CiMhbml4IG5peHBrZ3MjYmFzaCBuaXhwa2dzI2NvcmV1dGlscyBuaXhwa2dzI25peCBuaXhw a2dzI2ZpbmR1dGlscyBuaXhwa2dzI2dudXNlZCBuaXhwa2dzI2F1dG9jb25mIG5peHBrZ3MjZ251 bWFrZSBuaXhwa2dzI2djYyBuaXhwa2dzI2NhcmdvCiMhbml4IC0tY29tbWFuZCBiYXNoCgpzZXQg LWV1byBwaXBlZmFpbAoKdG1wZGlyPSIkKG1rdGVtcCAtLWRpcikiCnRyYXAgJ3JtIC1yZiAtLSAi JHRtcGRpciInIEVYSVQKCiMgR2V0IHRoZSBwYXRocyB3ZSBuZWVkIGZvciB6bGliLW5nCmV4cG9y dCBOSVhfUEFUSD1uaXhwa2dzPWh0dHBzOi8vcmVsZWFzZXMubml4b3Mub3JnL25peG9zL3Vuc3Rh YmxlL25peG9zLTI2LjExcHJlMTEwNTAzNy4xYzg5MDgzZTQ1MWUvbml4ZXhwcnMudGFyLnpzdApu aXgtYnVpbGQgJzxuaXhwa2dzPicgLUEgemxpYi1uZyAtQSB6bGliLW5nLmRldiAtbyAiJHRtcGRp ciIvemxpYi1uZwp6bGliX2xpYj0iJChyZWFscGF0aCAiJHRtcGRpciIvemxpYi1uZykiCnpsaWJf ZGV2PSIkKHJlYWxwYXRoICIkdG1wZGlyIi96bGliLW5nLWRldikiCgojIFdvcmsgb3V0IGhvdyBt dWNoIHRvIHBhcmFsbGVsaXNlIHRoZSBidWlsZHMKam9icz0iJChucHJvYykiCgojIE1ha2Ugc3Vy ZSB0aGUgYnVpbGQgcHJvY2VzcyBjYW4gZmluZCB6bGliLW5nCmV4cG9ydCBDUFBGTEFHUz0iLWlz eXN0ZW0gJHpsaWJfZGV2L2luY2x1ZGUiIExERkxBR1M9Ii1MJHpsaWJfbGliL2xpYiAtV2wsLXJw YXRoLCR6bGliX2xpYiIKCiMgU2V0IG9wdGlvbnM6IGRpc2FibGUgZmVhdHVyZXMgd2UgZG9uJ3Qg bmVlZCBmb3Igc3BlZWQgb2YgYnVpbGRpbmcsIHVzZQojIHpsaWItbmcsIGVuYWJsZSBicmVha2lu ZyBjaGFuZ2VzLgpleHBvcnQgWkxJQl9ORz0xIFdJVEhfQlJFQUtJTkdfQ0hBTkdFUz0xIE5PX1RD TFRLPTEgTk9fR0VUVEVYVD0xCgojIEJ1aWxkIGdpdAptYWtlIC1qIiRqb2JzIiBjb25maWd1cmUK Li9jb25maWd1cmUKbWFrZSAtaiIkam9icyIKCiMgTWFrZSBzdXJlIEdpdCBjb25maWcgZG9lc24n dCBoYXZlIGFueXRoaW5nIHVuZXhwZWN0ZWQKZXhwb3J0IEdJVF9DT05GSUdfR0xPQkFMPS9kZXYv bnVsbApleHBvcnQgR0lUX0NPTkZJR19TWVNURU09L2Rldi9udWxsCmV4cG9ydCBHSVRfQ09ORklH PS9kZXYvbnVsbApleHBvcnQgR0lUX0NPTkZJR19DT1VOVD0yCmV4cG9ydCBHSVRfQ09ORklHX0tF WV8wPXVzZXIubmFtZSBHSVRfQ09ORklHX1ZBTFVFXzA9QWRhbQpleHBvcnQgR0lUX0NPTkZJR19L RVlfMT11c2VyLmVtYWlsIEdJVF9DT05GSUdfVkFMVUVfMT1hZGFtQGxvY2FsaG9zdApleHBvcnQg R0lUX1BBR0VSPWNhdAoKIyBNYWtlIHN1cmUgY2FsbGluZyBgZ2l0YCBnZXRzIHRoZSByaWdodCBl eGVjdXRhYmxlCmV4cG9ydCBQQVRIPSIkUFdEIjoiJFBBVEgiCgojIFNldCB1cCBhIHNpbXBsZSBy ZXBvc2l0b3J5IHdpdGggYSBzaW5nbGUgY29tbWl0CmdpdCBpbml0ICIkdG1wZGlyIi9yZXBvCmNk ICIkdG1wZGlyIi9yZXBvCnRvdWNoIHRlc3QtZmlsZQpnaXQgYWRkIHRlc3QtZmlsZQpnaXQgY29t bWl0IC1tICdkZW1vIGNvbW1pdCcKCiMgU2hvdyBldmVyeXRoaW5nJ3Mgc2hhMSByYXRoZXIgdGhh biBzaGEyNTYKZ2l0IGxvZyAtLWZvcm1hdD1yYXcKZ2l0IHJldi1wYXJzZSAtLXNob3ctb2JqZWN0 LWZvcm1hdAo= --00000000000088b7c7065f9e691f--
Re: Default object format for new repositories in Git v3
Author: "brian m. carlson"
Date: Fri, 06 Nov 2026 20:46
Date: Fri, 06 Nov 2026 20:46
52 lines
10831 bytes
10831 bytes
--DImmDjSrzffVQ5Eg Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2026-11-06 at 16:50:03, Adam Dinwoodie wrote: > Hi folks, >=20 > As part of preparing for Git v3, in particular for Nixpkgs, I've been > running a bunch of tests using Git built with > `WITH_BREAKING_CHANGES=3D1`. Somewhat to my surprise, `git init` seems > to still be creating new repositories using sha1 rather than sha256. > Is this expected? >=20 > For reference, I've attached the test script I've produced as a repro > that can be run from the root of a Git checkout, although it does > require Nix. I've confirmed the behaviour at v2.56.0, next > (972d6e3ab651d838b30a8d5d70d8ef6ced05a986) and main > (0ffa3e35c7c82ab8d0de226149fb03b3f7674d05). >=20 > For a simpler repro that doesn't require Nix, build Git with > `WITH_BREAKING_CHANGES=3D1`, then run: >=20 > ``` > git init tmpdir > git -C tmpdir rev-parse --show-object-format > ``` >=20 > This will print "sha1", when I'd expect "sha256". This does appear to be broken. I have a patch that should fix it that's running through CI right now. I'll send it once it's green, either later tonight or tomorrow. --=20 brian m. carlson (they/them) Toronto, Ontario, CA Speaking for myself only --DImmDjSrzffVQ5Eg Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- wr0EABYKAG8FgmruPKAJEHwMSWKIh6KBRxQAAAAAAB4AIHNhbHRAbm90YXRpb25z LnNlcXVvaWEtcGdwLm9yZ5pTnswCH8tIiUqjOo9XXyY479zwaKRvSFiv6PDeP7ab FiEECCzmip28ZfuD0cORfAxJYoiHooEAAKHCAP9OtHwzHp45bOU0uqef1dB3i35V iJqerR1FhOmLmMOV1gD7BFQS3uLDvL5trumhfveacjqSTg4x7UUKLmTDeanKtwo= =8FuM -----END PGP SIGNATURE----- --DImmDjSrzffVQ5Eg--
[PATCH] setup: default hash algo to GIT_HASH_DEFAULT
Author: "brian m. carlson"
Date: Sun, 08 Nov 2026 01:16
Date: Sun, 08 Nov 2026 01:16
53 lines
10366 bytes
10366 bytes
When we have no other hash algorithm to choose, we set no hash
algorithm, which ends up with us defaulting to SHA-1. Instead, default
to GIT_HASH_DEFAULT. This means that we will choose SHA-256 in breaking
changes mode and in Git 3.0, which is what we want.
Reported-by: Adam Dinwoodie <adam@dinwoodie.org>
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
setup.c | 2 ++
t/t0001-init.sh | 16 ++++++++++++++++
2 files changed, 18 insertions(+)
diff --git a/setup.c b/setup.c
index 61bcdafe82..4a0dfc8908 100644
--- a/setup.c
+++ b/setup.c
@@ -2830,6 +2830,8 @@ static void repository_format_configure(struct repository_format *repo_fmt,
repo_fmt->hash_algo = env_algo;
} else if (cfg.hash != GIT_HASH_UNKNOWN) {
repo_fmt->hash_algo = cfg.hash;
+ } else {
+ repo_fmt->hash_algo = GIT_HASH_DEFAULT;
}
/*
diff --git a/t/t0001-init.sh b/t/t0001-init.sh
index f1d227f271..98c7562f32 100755
--- a/t/t0001-init.sh
+++ b/t/t0001-init.sh
@@ -516,6 +516,22 @@ test_expect_success 're-init from a linked worktree' '
)
'
+test_expect_success 'git init uses default object format' '
+ test_when_finished "rm -rf repo" &&
+ (
+ sane_unset GIT_DEFAULT_HASH &&
+ git init repo &&
+ if test_have_prereq WITH_BREAKING_CHANGES
+ then
+ echo sha256
+ else
+ echo sha1
+ fi >expect &&
+ git -C repo rev-parse --show-object-format >actual &&
+ test_cmp expect actual
+ )
+'
+
test_expect_success 'init honors GIT_DEFAULT_HASH' '
test_when_finished "rm -rf sha1 sha256" &&
GIT_DEFAULT_HASH=sha1 git init sha1 &&
Re: [PATCH] setup: default hash algo to GIT_HASH_DEFAULT
Author: Junio C Hamano
Date: Sun, 08 Nov 2026 04:42
Date: Sun, 08 Nov 2026 04:42
74 lines
14939 bytes
14939 bytes
"brian m. carlson" <sandals@crustytoothpaste.net> writes:
> When we have no other hash algorithm to choose, we set no hash
> algorithm, which ends up with us defaulting to SHA-1. Instead, default
> to GIT_HASH_DEFAULT. This means that we will choose SHA-256 in breaking
> changes mode and in Git 3.0, which is what we want.
>
> Reported-by: Adam Dinwoodie <adam@dinwoodie.org>
> Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
> ---
> setup.c | 2 ++
> t/t0001-init.sh | 16 ++++++++++++++++
> 2 files changed, 18 insertions(+)
With Git 3.0, we promised that SHA-1/SHA-256 interop will not have
to be ready, and that SHA-256 would become the default. And this
patch would be a good thing to have for the second promise.
But didn't we also discuss "empty/initial repository whose hash
algorithm is undecided can take a push of either SHA-1 or SHA-256
payload and that first push can decide and freeze the hash algorithm
used in the repository" or something along that line?
I am wondering if we want to reserve 'HASH_UNKNOWN' for such a "was
just created, not quite finished initializing yet" state.
The patch looks good for the goal stated in the log message.
Thanks.
> diff --git a/setup.c b/setup.c
> index 61bcdafe82..4a0dfc8908 100644
> --- a/setup.c
> +++ b/setup.c
> @@ -2830,6 +2830,8 @@ static void repository_format_configure(struct repository_format *repo_fmt,
> repo_fmt->hash_algo = env_algo;
> } else if (cfg.hash != GIT_HASH_UNKNOWN) {
> repo_fmt->hash_algo = cfg.hash;
> + } else {
> + repo_fmt->hash_algo = GIT_HASH_DEFAULT;
> }
>
> /*
> diff --git a/t/t0001-init.sh b/t/t0001-init.sh
> index f1d227f271..98c7562f32 100755
> --- a/t/t0001-init.sh
> +++ b/t/t0001-init.sh
> @@ -516,6 +516,22 @@ test_expect_success 're-init from a linked worktree' '
> )
> '
>
> +test_expect_success 'git init uses default object format' '
> + test_when_finished "rm -rf repo" &&
> + (
> + sane_unset GIT_DEFAULT_HASH &&
> + git init repo &&
> + if test_have_prereq WITH_BREAKING_CHANGES
> + then
> + echo sha256
> + else
> + echo sha1
> + fi >expect &&
> + git -C repo rev-parse --show-object-format >actual &&
> + test_cmp expect actual
> + )
> +'
> +
> test_expect_success 'init honors GIT_DEFAULT_HASH' '
> test_when_finished "rm -rf sha1 sha256" &&
> GIT_DEFAULT_HASH=sha1 git init sha1 &&
Re: [PATCH] setup: default hash algo to GIT_HASH_DEFAULT
Author: "brian m. carlson"
Date: Sun, 08 Nov 2026 14:38
Date: Sun, 08 Nov 2026 14:38
65 lines
11835 bytes
11835 bytes
--HklZObr7OUXM4dwr Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2026-11-08 at 04:42:56, Junio C Hamano wrote: > "brian m. carlson" <sandals@crustytoothpaste.net> writes: >=20 > > When we have no other hash algorithm to choose, we set no hash > > algorithm, which ends up with us defaulting to SHA-1. Instead, default > > to GIT_HASH_DEFAULT. This means that we will choose SHA-256 in breaking > > changes mode and in Git 3.0, which is what we want. > > > > Reported-by: Adam Dinwoodie <adam@dinwoodie.org> > > Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> > > --- > > setup.c | 2 ++ > > t/t0001-init.sh | 16 ++++++++++++++++ > > 2 files changed, 18 insertions(+) >=20 > With Git 3.0, we promised that SHA-1/SHA-256 interop will not have > to be ready, and that SHA-256 would become the default. And this > patch would be a good thing to have for the second promise. >=20 > But didn't we also discuss "empty/initial repository whose hash > algorithm is undecided can take a push of either SHA-1 or SHA-256 > payload and that first push can decide and freeze the hash algorithm > used in the repository" or something along that line? We discussed that as a possibility, but it requires protocol changes and nobody has stepped up to implement that. I think Peff was thinking about maybe implementing that, but I don't think anyone came to a decision. > I am wondering if we want to reserve 'HASH_UNKNOWN' for such a "was > just created, not quite finished initializing yet" state. I think we concluded that we'd need to initialize a repository to _some_ hash algorithm even if we had the limbo state because otherwise people could `git init` and then work locally and we need to have some existing hash algorithm for that case. That would be true even with bare repositories. So I think the limbo functionality, if we implemented it, would be a separate option (maybe `extensions.potentialObjectFormat`?) and this patch should go in either way. --=20 brian m. carlson (they/them) Toronto, Ontario, CA Speaking for myself only --HklZObr7OUXM4dwr Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- wr0EABYKAG8FgmrwiWwJEHwMSWKIh6KBRxQAAAAAAB4AIHNhbHRAbm90YXRpb25z LnNlcXVvaWEtcGdwLm9yZ3QhWGgE8/MweIJYSRWEgjkmGv1EzF0/A89QFobSFoc/ FiEECCzmip28ZfuD0cORfAxJYoiHooEAAN9zAP40gpRmFO710rgI/HViVC7jCr3n +Z8qNYWMlqLyKsIIzAD/aHb1BydUWK3jiZUvmfaKrkg0GEHIWAnV5zE0bejvHgw= =MehV -----END PGP SIGNATURE----- --HklZObr7OUXM4dwr--
Re: [PATCH] setup: default hash algo to GIT_HASH_DEFAULT
Author: Junio C Hamano
Date: Sun, 08 Nov 2026 18:22
Date: Sun, 08 Nov 2026 18:22
108 lines
16386 bytes
16386 bytes
"brian m. carlson" <sandals@crustytoothpaste.net> writes:
> When we have no other hash algorithm to choose, we set no hash
> algorithm, which ends up with us defaulting to SHA-1. Instead, default
> to GIT_HASH_DEFAULT. This means that we will choose SHA-256 in breaking
> changes mode and in Git 3.0, which is what we want.
>
> Reported-by: Adam Dinwoodie <adam@dinwoodie.org>
> Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
> ---
> setup.c | 2 ++
> t/t0001-init.sh | 16 ++++++++++++++++
> 2 files changed, 18 insertions(+)
>
> diff --git a/setup.c b/setup.c
> index 61bcdafe82..4a0dfc8908 100644
> --- a/setup.c
> +++ b/setup.c
> @@ -2830,6 +2830,8 @@ static void repository_format_configure(struct repository_format *repo_fmt,
> repo_fmt->hash_algo = env_algo;
> } else if (cfg.hash != GIT_HASH_UNKNOWN) {
> repo_fmt->hash_algo = cfg.hash;
> + } else {
> + repo_fmt->hash_algo = GIT_HASH_DEFAULT;
> }
Hmph, maybe I am not reading the code flow correctly, but does this
not break running "git init" to reinitialize an already initialized
repository? I mimicked the new test in your patch and wrote the
following just immediately after it, which
* figures out our hash and the other hash
* create a new repository with the "other" hash
* run "git init" without specifying any hash
It is debatable what should happen when you run "git init" from Git
3.0 without any specialization in an existing SHA-1 repository.
Possibilities include:
1. turn an existing SHA-1 repository into SHA-256 including format
conversion.
2. notice that the repository is already set up to use the SHA-1
format, and that the user did not explicitly say what format to
use, and behave as if --object-format=sha1 were given with a
notice or warning.
3. notice that the repository is already set up to use the SHA-1
format, but our default format is SHA-256. Because the user did
not countermand via an explicit --object-format=sha1 on the
command line, we should fail loudly, "cannot convert this SHA-1
repository to SHA-256".
I think #1 is impractical, #2 is probably the best, and #3 would
also be reasonable.
But the behaviour I am seeing with
$ make WITH_BREAKING_CHANGES=YesPlease
$ cd t && WITH_BREAKING_CHANGES=YesPlease sh t0001-init.sh -i -v
with the additional patch is different from any of the three (well,
technically, because the repository is empty, we _could_ argue that
we did #1, but ...).
I wonder what the "git init" command does wrt the reference storage
format (Patrick CC'ed for this)? I am sure we do not convert from
reffiles to reftable on the fly at "git init" time.
diff --git i/t/t0001-init.sh w/t/t0001-init.sh
index bc30cf853b..1d48a712ae 100755
--- i/t/t0001-init.sh
+++ w/t/t0001-init.sh
@@ -532,6 +532,31 @@ test_expect_success 'git init uses default object format' '
)
'
+test_expect_success 'git (re)init does not clobber object format' '
+ test_when_finished "rm -rf repo" &&
+ (
+ sane_unset GIT_DEFAULT_HASH &&
+ if test_have_prereq WITH_BREAKING_CHANGES
+ then
+ ours=sha256 opposite=sha1
+ else
+ ours=sha1 opposite=sha256
+ fi &&
+
+ # initialize to non-default format
+ git init --object-format=$opposite repo &&
+ git -C repo rev-parse --show-object-format >actual &&
+ echo "$opposite" >expect &&
+ test_cmp expect actual &&
+
+ # reinitialize without configuration
+ git init repo &&
+ git -C repo rev-parse --show-object-format >actual &&
+ echo "$opposite" >expect &&
+ test_cmp expect actual
+ )
+'
+
test_expect_success 'init honors GIT_DEFAULT_HASH' '
test_when_finished "rm -rf sha1 sha256" &&
GIT_DEFAULT_HASH=sha1 git init sha1 &&
Re: [PATCH] setup: default hash algo to GIT_HASH_DEFAULT
Author: Junio C Hamano
Date: Mon, 09 Nov 2026 02:21
Date: Mon, 09 Nov 2026 02:21
43 lines
14337 bytes
14337 bytes
Junio C Hamano <gitster@pobox.com> writes:
> I wonder what the "git init" command does wrt the reference storage
> format (Patrick CC'ed for this)? I am sure we do not convert from
> reffiles to reftable on the fly at "git init" time.
I looked at setup.c:repository_format_configure() and found why
your patch regresses, as well as a latent bug in the existing code.
First, REPOSITORY_FORMAT_INIT sets .hash_algo = GIT_HASH_DEFAULT,
but read_repository_format() forces it to GIT_HASH_SHA1_LEGACY
when version == -1 (no config yet), which is why new repositories
kept getting SHA-1.
Second, unlike the ref-storage block right below it, which checks
"else if (repo_fmt->version >= 0)" once between the explicit
overrides and all default sources, the hash-algo block guards only
the GIT_DEFAULT_HASH branch (repo_fmt->version < 0), leaving "else
if (cfg.hash != GIT_HASH_UNKNOWN)" unguarded.
So init.defaultObjectFormat in ~/.gitconfig already corrupts an
existing repository on re-init, and an unguarded "else" for
GIT_HASH_DEFAULT falls into the same trap even without config.
Instead of starting the if/else if cascade like this:
if (repo_fmt->version >= 0 &&
hash != GIT_HASH_UNKNOWN &&
hash != repo_fmt->hash_algo)
die(_("attempt to reinitialize repository with different hash"));
we should have started it like so:
if (repo_fmt->version >= 0) {
if (hash != GIT_HASH_UNKNOWN && hash != repo_fmt->hash_algo)
die(_("attempt to reinitialize repository with different hash"));
/* otherwise happy */
} else if ...
so that all the "set a new value from different sources like command
line, environment, ~/.gitconfig, or the built-in default" would
happen only when (repo_fmt->version < 0), probably?
[PATCH v2] setup: fix hash algorithm detection
Author: "brian m. carlson"
Date: Fri, 13 Nov 2026 22:17
Date: Fri, 13 Nov 2026 22:17
156 lines
14157 bytes
14157 bytes
Our current hash algorithm selection code has a few different problems.
First, we do not actually default to GIT_HASH_DEFAULT. Second, if we
have an algorithm chosen by init.defaultObjectFormat and we re-init a
repository, we will change the hash algorithm, which is very much not
desired.
Let's restructure this code slightly. First, if an algorithm was
selected on the command line, assume that's what the user wanted.
Otherwise, the other options should only be chosen if our repository
doesn't exist (that is, repo_fmt->version is -1) or it's specifically
detected as having no hash algorithm. In that case, first use the
environment, then the config, and finally, the default algorithm.
Then, if the algorithm does not match the repository, complain loudly
and refuse to reinitialize the repository with a different hash
algorithm.
With this change, we will choose SHA-256 in breaking changes mode and in
Git 3.0, which is what we want. Add several tests to cover this case
and several others discovered along the way.
Reported-by: Adam Dinwoodie <adam@dinwoodie.org>
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
setup.c | 22 +++++++++++--------
t/t0001-init.sh | 58 +++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 71 insertions(+), 9 deletions(-)
diff --git a/setup.c b/setup.c
index 61bcdafe82..14c6e1a67d 100644
--- a/setup.c
+++ b/setup.c
@@ -2817,19 +2817,20 @@ static void repository_format_configure(struct repository_format *repo_fmt,
* Otherwise, if the user has specified one on the command line, use it.
*/
env = getenv(GIT_DEFAULT_HASH_ENVIRONMENT);
- if (repo_fmt->version >= 0 && hash != GIT_HASH_UNKNOWN && hash != repo_fmt->hash_algo)
- die(_("attempt to reinitialize repository with different hash"));
- else if (hash != GIT_HASH_UNKNOWN)
- repo_fmt->hash_algo = hash;
- else if (env) {
+ if (hash != GIT_HASH_UNKNOWN) {
+ /* nothing to do */
+ } else if (repo_fmt->version >= 0 &&
+ repo_fmt->hash_algo != GIT_HASH_UNKNOWN) {
+ hash = repo_fmt->hash_algo;
+ } else if (env) {
int env_algo = hash_algo_by_name(env);
if (env_algo == GIT_HASH_UNKNOWN)
die(_("unknown hash algorithm '%s'"), env);
- if (repo_fmt->version < 0 ||
- repo_fmt->hash_algo == GIT_HASH_UNKNOWN)
- repo_fmt->hash_algo = env_algo;
+ hash = env_algo;
} else if (cfg.hash != GIT_HASH_UNKNOWN) {
- repo_fmt->hash_algo = cfg.hash;
+ hash = cfg.hash;
+ } else {
+ hash = GIT_HASH_DEFAULT;
}
/*
@@ -2899,6 +2900,8 @@ static void repository_format_configure(struct repository_format *repo_fmt,
* current ref storage format does not change.
*/
if (repo_fmt->version >= 0) {
+ if (hash != repo_fmt->hash_algo)
+ die(_("attempt to reinitialize repository with different hash"));
if (ref_storage_format != repo_fmt->ref_storage_format)
die(_("attempt to reinitialize repository with different reference storage format"));
if ((ref_storage_payload || repo_fmt->ref_storage_payload) &&
@@ -2908,6 +2911,7 @@ static void repository_format_configure(struct repository_format *repo_fmt,
}
free(repo_fmt->ref_storage_payload);
+ repo_fmt->hash_algo = hash;
repo_fmt->ref_storage_format = ref_storage_format;
repo_fmt->ref_storage_payload = ref_storage_payload;
}
diff --git a/t/t0001-init.sh b/t/t0001-init.sh
index f1d227f271..d8244a2dec 100755
--- a/t/t0001-init.sh
+++ b/t/t0001-init.sh
@@ -516,6 +516,22 @@ test_expect_success 're-init from a linked worktree' '
)
'
+test_expect_success 'git init uses default object format' '
+ test_when_finished "rm -rf repo" &&
+ (
+ sane_unset GIT_DEFAULT_HASH &&
+ git init repo &&
+ if test_have_prereq WITH_BREAKING_CHANGES
+ then
+ echo sha256
+ else
+ echo sha1
+ fi >expect &&
+ git -C repo rev-parse --show-object-format >actual &&
+ test_cmp expect actual
+ )
+'
+
test_expect_success 'init honors GIT_DEFAULT_HASH' '
test_when_finished "rm -rf sha1 sha256" &&
GIT_DEFAULT_HASH=sha1 git init sha1 &&
@@ -602,6 +618,48 @@ do
'
done
+test_expect_success 'init refuses to reinitialize with different hash' '
+ test_when_finished "rm -rf repo" &&
+ sane_unset GIT_DEFAULT_HASH &&
+ for algo in sha1 sha256
+ do
+ if test "$algo" = sha1
+ then
+ other=sha256
+ else
+ other=sha1
+ fi &&
+ git init --object-format="$algo" repo &&
+ cat >expect <<-EOF &&
+ fatal: attempt to reinitialize repository with different hash
+ EOF
+ test_must_fail git init --object-format="$other" repo 2>err &&
+ test_cmp expect err &&
+ rm -fr repo || return 1
+ done
+'
+
+test_expect_success 're-init does not modify hash from config' '
+ test_when_finished "rm -rf repo" &&
+ sane_unset GIT_DEFAULT_HASH &&
+ for algo in sha1 sha256
+ do
+ if test "$algo" = sha1
+ then
+ other=sha256
+ else
+ other=sha1
+ fi &&
+ git init --object-format="$algo" repo &&
+ test_config_global init.defaultObjectFormat "$other" &&
+ git init repo &&
+ echo "$algo" >expect &&
+ git -C repo rev-parse --show-object-format >actual &&
+ test_cmp expect actual &&
+ rm -fr repo || return 1
+ done
+'
+
test_expect_success 'extensions.objectFormat is not allowed with repo version 0' '
test_when_finished "rm -rf explicit-v0" &&
git init --object-format=sha256 explicit-v0 &&
Re: [PATCH v2] setup: fix hash algorithm detection
Author: Junio C Hamano
Date: Sat, 14 Nov 2026 00:16
Date: Sat, 14 Nov 2026 00:16
45 lines
14511 bytes
14511 bytes
"brian m. carlson" <sandals@crustytoothpaste.net> writes: > Our current hash algorithm selection code has a few different problems. > First, we do not actually default to GIT_HASH_DEFAULT. Second, if we > have an algorithm chosen by init.defaultObjectFormat and we re-init a > repository, we will change the hash algorithm, which is very much not > desired. > > Let's restructure this code slightly. First, if an algorithm was > selected on the command line, assume that's what the user wanted. > Otherwise, the other options should only be chosen if our repository > doesn't exist (that is, repo_fmt->version is -1) or it's specifically > detected as having no hash algorithm. In that case, first use the > environment, then the config, and finally, the default algorithm. > > Then, if the algorithm does not match the repository, complain loudly > and refuse to reinitialize the repository with a different hash > algorithm. > > With this change, we will choose SHA-256 in breaking changes mode and in > Git 3.0, which is what we want. Add several tests to cover this case > and several others discovered along the way. > > Reported-by: Adam Dinwoodie <adam@dinwoodie.org> > Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> > --- > setup.c | 22 +++++++++++-------- > t/t0001-init.sh | 58 +++++++++++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 71 insertions(+), 9 deletions(-) I was somehow expecting a patch that would apply cleanly both to the maintenance track and to the 2.98 but that is totally unnecessary, as it does not make any sense to build and use the maintenance track with the WITH_BREAKING_CHANGES option ;-) The point of the WITH_BREAKING_CHANGES option is to make sure we have a test vehicle to try out something that is close enough to "Git 3.0" long before we release one. And the updated code structure looks much simpler and more straightforward. Will replace. Thanks.
[PATCH v3] setup: fix hash algorithm detection
Author: "brian m. carlson"
Date: Thu, 19 Nov 2026 01:06
Date: Thu, 19 Nov 2026 01:06
162 lines
14461 bytes
14461 bytes
Our current hash algorithm selection code has a few different problems.
First, we do not actually default to GIT_HASH_DEFAULT. Second, if we
have an algorithm chosen by init.defaultObjectFormat and we re-init a
repository, we will change the hash algorithm, which is very much not
desired.
Let's restructure this code slightly. First, if an algorithm was
selected on the command line, assume that's what the user wanted.
Otherwise, the other options should only be chosen if our repository
doesn't exist (that is, repo_fmt->version is -1) or it's specifically
detected as having no hash algorithm. In that case, first use the
environment, then the config, and finally, the default algorithm.
Then, if the algorithm does not match the repository, complain loudly
and refuse to reinitialize the repository with a different hash
algorithm.
With this change, we will choose SHA-256 in breaking changes mode and in
Git 3.0, which is what we want. Add several tests to cover this case
and several others discovered along the way. Remove the now-inaccurate
comment.
Reported-by: Adam Dinwoodie <adam@dinwoodie.org>
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
Changes since v2:
* Remove comment.
* Use `$GIT_TEST_BUILTIN_HASH`.
setup.c | 27 ++++++++++++-------------
t/t0001-init.sh | 53 +++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 66 insertions(+), 14 deletions(-)
diff --git a/setup.c b/setup.c
index cedc031c54..5d7e8d590e 100644
--- a/setup.c
+++ b/setup.c
@@ -2887,25 +2887,21 @@ static void repository_format_configure(struct repository_format *repo_fmt,
config_with_options(read_default_format_config, &cfg, NULL, NULL, &opts);
- /*
- * If we already have an initialized repo, don't allow the user to
- * specify a different algorithm, as that could cause corruption.
- * Otherwise, if the user has specified one on the command line, use it.
- */
env = getenv(GIT_DEFAULT_HASH_ENVIRONMENT);
- if (repo_fmt->version >= 0 && hash != GIT_HASH_UNKNOWN && hash != repo_fmt->hash_algo)
- die(_("attempt to reinitialize repository with different hash"));
- else if (hash != GIT_HASH_UNKNOWN)
- repo_fmt->hash_algo = hash;
- else if (env) {
+ if (hash != GIT_HASH_UNKNOWN) {
+ /* nothing to do */
+ } else if (repo_fmt->version >= 0 &&
+ repo_fmt->hash_algo != GIT_HASH_UNKNOWN) {
+ hash = repo_fmt->hash_algo;
+ } else if (env) {
int env_algo = hash_algo_by_name(env);
if (env_algo == GIT_HASH_UNKNOWN)
die(_("unknown hash algorithm '%s'"), env);
- if (repo_fmt->version < 0 ||
- repo_fmt->hash_algo == GIT_HASH_UNKNOWN)
- repo_fmt->hash_algo = env_algo;
+ hash = env_algo;
} else if (cfg.hash != GIT_HASH_UNKNOWN) {
- repo_fmt->hash_algo = cfg.hash;
+ hash = cfg.hash;
+ } else {
+ hash = GIT_HASH_DEFAULT;
}
/*
@@ -3022,6 +3018,8 @@ static void repository_format_configure(struct repository_format *repo_fmt,
* current storage formats do not change.
*/
if (repo_fmt->version >= 0) {
+ if (hash != repo_fmt->hash_algo)
+ die(_("attempt to reinitialize repository with different hash"));
if (ref_storage_format != repo_fmt->ref_storage_format)
die(_("attempt to reinitialize repository with different reference storage format"));
if ((ref_storage_payload || repo_fmt->ref_storage_payload) &&
@@ -3038,6 +3036,7 @@ static void repository_format_configure(struct repository_format *repo_fmt,
free(cfg.ref_storage_payload);
free(repo_fmt->ref_storage_payload);
+ repo_fmt->hash_algo = hash;
repo_fmt->ref_storage_format = ref_storage_format;
repo_fmt->ref_storage_payload = ref_storage_payload;
diff --git a/t/t0001-init.sh b/t/t0001-init.sh
index 9e57a06cea..d89f60bab9 100755
--- a/t/t0001-init.sh
+++ b/t/t0001-init.sh
@@ -516,6 +516,17 @@ test_expect_success 're-init from a linked worktree' '
)
'
+test_expect_success 'git init uses default object format' '
+ test_when_finished "rm -rf repo" &&
+ (
+ sane_unset GIT_DEFAULT_HASH &&
+ git init repo &&
+ echo "$GIT_TEST_BUILTIN_HASH" >expect &&
+ git -C repo rev-parse --show-object-format >actual &&
+ test_cmp expect actual
+ )
+'
+
test_expect_success 'init honors GIT_DEFAULT_HASH' '
test_when_finished "rm -rf sha1 sha256" &&
GIT_DEFAULT_HASH=sha1 git init sha1 &&
@@ -602,6 +613,48 @@ do
'
done
+test_expect_success 'init refuses to reinitialize with different hash' '
+ test_when_finished "rm -rf repo" &&
+ sane_unset GIT_DEFAULT_HASH &&
+ for algo in sha1 sha256
+ do
+ if test "$algo" = sha1
+ then
+ other=sha256
+ else
+ other=sha1
+ fi &&
+ git init --object-format="$algo" repo &&
+ cat >expect <<-EOF &&
+ fatal: attempt to reinitialize repository with different hash
+ EOF
+ test_must_fail git init --object-format="$other" repo 2>err &&
+ test_cmp expect err &&
+ rm -fr repo || return 1
+ done
+'
+
+test_expect_success 're-init does not modify hash from config' '
+ test_when_finished "rm -rf repo" &&
+ sane_unset GIT_DEFAULT_HASH &&
+ for algo in sha1 sha256
+ do
+ if test "$algo" = sha1
+ then
+ other=sha256
+ else
+ other=sha1
+ fi &&
+ git init --object-format="$algo" repo &&
+ test_config_global init.defaultObjectFormat "$other" &&
+ git init repo &&
+ echo "$algo" >expect &&
+ git -C repo rev-parse --show-object-format >actual &&
+ test_cmp expect actual &&
+ rm -fr repo || return 1
+ done
+'
+
test_expect_success 'extensions.objectFormat is not allowed with repo version 0' '
test_when_finished "rm -rf explicit-v0" &&
git init --object-format=sha256 explicit-v0 &&
Re: [PATCH v3] setup: fix hash algorithm detection
Author: Junio C Hamano
Date: Thu, 19 Nov 2026 16:26
Date: Thu, 19 Nov 2026 16:26
112 lines
15789 bytes
15789 bytes
"brian m. carlson" <sandals@crustytoothpaste.net> writes: > diff --git a/t/t0001-init.sh b/t/t0001-init.sh > index 9e57a06cea..d89f60bab9 100755 > --- a/t/t0001-init.sh > +++ b/t/t0001-init.sh > @@ -516,6 +516,17 @@ test_expect_success 're-init from a linked worktree' ' > ) > ' > > +test_expect_success 'git init uses default object format' ' > + test_when_finished "rm -rf repo" && > + ( > + sane_unset GIT_DEFAULT_HASH && > + git init repo && In this subshell, we discard GIT_DEFAULT_HASH that was set up by t/test-lib.sh (either from the GIT_TEST_DEFAULT_HASH exported by the CI framework or from the GIT_TEST_BUILTIN_HASH to match the running binary). "git init repo" will create a repository using the binary built-in default. > + echo "$GIT_TEST_BUILTIN_HASH" >expect && > + git -C repo rev-parse --show-object-format >actual && And we have to see the same TEST_BUILTIN_HASH as the result. > + test_cmp expect actual > + ) > +' Very good. > +test_expect_success 'init refuses to reinitialize with different hash' ' > + test_when_finished "rm -rf repo" && > + sane_unset GIT_DEFAULT_HASH && Here, we permanently discard GIT_DEFAULT_HASH from t/test-lib.sh without saving what it was. Would it cause issues to later tests that we do not see in post context of this patch? > + for algo in sha1 sha256 > + do > + if test "$algo" = sha1 > + then > + other=sha256 > + else > + other=sha1 > + fi && > + git init --object-format="$algo" repo && We create in one format and then ... > + cat >expect <<-EOF && > + fatal: attempt to reinitialize repository with different hash > + EOF > + test_must_fail git init --object-format="$other" repo 2>err && ... try reinitializing to the other format. Expected is a failure with a message. > + test_cmp expect err && > + rm -fr repo || return 1 > + done > +' OK. > +test_expect_success 're-init does not modify hash from config' ' > + test_when_finished "rm -rf repo" && > + sane_unset GIT_DEFAULT_HASH && Here, we discard GIT_DEFAULT_HASH again, correctly assumig that the previous one can be skipped. > + for algo in sha1 sha256 > + do > + if test "$algo" = sha1 > + then > + other=sha256 > + else > + other=sha1 > + fi && > + git init --object-format="$algo" repo && Again, we create in one format and then ... > + test_config_global init.defaultObjectFormat "$other" && > + git init repo && > + echo "$algo" >expect && ... we do not want the configuration to cause reinitialization to touch the format. > + git -C repo rev-parse --show-object-format >actual && > + test_cmp expect actual && > + rm -fr repo || return 1 > + done > +' Looks good. > test_expect_success 'extensions.objectFormat is not allowed with repo version 0' ' > test_when_finished "rm -rf explicit-v0" && > git init --object-format=sha256 explicit-v0 && My earlier question was about this one. A format is explicitly given to this one, so the environment variables would not affect this particular one, but if we have "git init" in later tests that used to rely on the GIT_DEFAULT_HASH setting left by t/test-lib.sh may we get in a trobule?
Re: [PATCH v3] setup: fix hash algorithm detection
Author: Junio C Hamano
Date: Thu, 19 Nov 2026 16:38
Date: Thu, 19 Nov 2026 16:38
55 lines
15040 bytes
15040 bytes
"brian m. carlson" <sandals@crustytoothpaste.net> writes: > Our current hash algorithm selection code has a few different problems. > First, we do not actually default to GIT_HASH_DEFAULT. Second, if we > have an algorithm chosen by init.defaultObjectFormat and we re-init a > repository, we will change the hash algorithm, which is very much not > desired. Can we end the "first" sentence with a reason? We do not actually default to GIT_HASH_DEFAULT because we initialize a variable to SHA1_LEGACY and we do not consider it as "nowhere the user specifies which algorithm they want", or something? > Let's restructure this code slightly. First, if an algorithm was > selected on the command line, assume that's what the user wanted. > Otherwise, the other options should only be chosen if our repository > doesn't exist (that is, repo_fmt->version is -1) or it's specifically > detected as having no hash algorithm. In that case, first use the > environment, then the config, and finally, the default algorithm. In the current code, does "it's specifically having no hash algorithm" ever happen? Or is it our wish in near future to have such a state to allow "the first use determines the hash algorithm used" mode? > Then, if the algorithm does not match the repository, complain loudly > and refuse to reinitialize the repository with a different hash > algorithm. > > With this change, we will choose SHA-256 in breaking changes mode and in > Git 3.0, which is what we want. Add several tests to cover this case > and several others discovered along the way. Remove the now-inaccurate > comment. Is the comment "now inaccurate"? > - /* > - * If we already have an initialized repo, don't allow the user to > - * specify a different algorithm, as that could cause corruption. > - * Otherwise, if the user has specified one on the command line, use it. > - */ I think the first two lines is still relevant and serves as a caution to whoever will be mucking with this function in the future. The last sentence is not quite right in that following the user's wish is not limited to the command line instruction (if they tell us via an environment variable, we would honor it). Oh, it just occured to me while I was writing the above parenthesized comment. If I have ~/.gitconfig that was modified via "git config set --global init.defaultObjectFormat sha256", would that count as "the user has specified"? Thanks.
Re: [PATCH v3] setup: fix hash algorithm detection
Author: "brian m. carlson"
Date: Thu, 19 Nov 2026 22:20
Date: Thu, 19 Nov 2026 22:20
80 lines
12618 bytes
12618 bytes
--uyU3TFZMAbItIAIF Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2026-11-19 at 16:38:13, Junio C Hamano wrote: > "brian m. carlson" <sandals@crustytoothpaste.net> writes: >=20 > > Our current hash algorithm selection code has a few different problems. > > First, we do not actually default to GIT_HASH_DEFAULT. Second, if we > > have an algorithm chosen by init.defaultObjectFormat and we re-init a > > repository, we will change the hash algorithm, which is very much not > > desired. >=20 > Can we end the "first" sentence with a reason? We do not actually > default to GIT_HASH_DEFAULT because we initialize a variable to > SHA1_LEGACY and we do not consider it as "nowhere the user specifies > which algorithm they want", or something? I can expand on that. > > Let's restructure this code slightly. First, if an algorithm was > > selected on the command line, assume that's what the user wanted. > > Otherwise, the other options should only be chosen if our repository > > doesn't exist (that is, repo_fmt->version is -1) or it's specifically > > detected as having no hash algorithm. In that case, first use the > > environment, then the config, and finally, the default algorithm. >=20 > In the current code, does "it's specifically having no hash > algorithm" ever happen? Or is it our wish in near future to have > such a state to allow "the first use determines the hash algorithm > used" mode? It should not as far as I can tell, but we have a bunch of different cases, including the clone case, and I'm not 100% sure if that actually ever happens. > > - /* > > - * If we already have an initialized repo, don't allow the user to > > - * specify a different algorithm, as that could cause corruption. > > - * Otherwise, if the user has specified one on the command line, use = it. > > - */ >=20 > I think the first two lines is still relevant and serves as a > caution to whoever will be mucking with this function in the future. > The last sentence is not quite right in that following the user's > wish is not limited to the command line instruction (if they tell us > via an environment variable, we would honor it). >=20 > Oh, it just occured to me while I was writing the above > parenthesized comment. If I have ~/.gitconfig that was modified via > "git config set --global init.defaultObjectFormat sha256", would > that count as "the user has specified"? I'll rewrite the comment. The "user has specified one on the command line" means with `--object-format`, but the user could specify one with `init.defaultObjectFormat`. The difference is we scream if the former mismatches with the repository, whereas if the repository is already initialized, we ignore `GIT_DEFAULT_HASH` and `init.defaultObjectFormat`. --=20 brian m. carlson (they/them) Toronto, Ontario, CA Speaking for myself only --uyU3TFZMAbItIAIF Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- wr0EABYKAG8Fgmr/dioJEHwMSWKIh6KBRxQAAAAAAB4AIHNhbHRAbm90YXRpb25z LnNlcXVvaWEtcGdwLm9yZ5s7RZPUtMuqQgBB51EjUvS0H5jliPx+7OfxEMMY7MVw FiEECCzmip28ZfuD0cORfAxJYoiHooEAAFQAAQC4uJbXJg38coCFkoa4yHrCQDnB NsSbkoBmS5rp9YKBZwEAp9SbY0VIkQ5R30X8l6nDxFPg1nqahhEErieqlSf/7wU= =HBtc -----END PGP SIGNATURE----- --uyU3TFZMAbItIAIF--
Re: [PATCH v3] setup: fix hash algorithm detection
Author: Junio C Hamano
Date: Thu, 19 Nov 2026 23:06
Date: Thu, 19 Nov 2026 23:06
9 lines
12920 bytes
12920 bytes
"brian m. carlson" <sandals@crustytoothpaste.net> writes: > ... The difference is we scream if the former > mismatches with the repository, whereas if the repository is already > initialized, we ignore `GIT_DEFAULT_HASH` and > `init.defaultObjectFormat`. That makes perfect sense. Thanks.
[PATCH v4] setup: fix hash algorithm detection
Author: "brian m. carlson"
Date: Mon, 23 Nov 2026 01:14
Date: Mon, 23 Nov 2026 01:14
179 lines
15214 bytes
15214 bytes
Our current hash algorithm selection code has a few different problems.
First, we do not actually default to GIT_HASH_DEFAULT because, due to a
bug, our code has never considered GIT_HASH_DEFAULT as a default for git
init and if an algorithm is not specified in the config file, we assume
that the repository is SHA-1.
Second, if we have an algorithm chosen by init.defaultObjectFormat and
we re-init a repository, we will change the hash algorithm, which is
very much not desired.
To fix this, let's restructure this code slightly. First, if an
algorithm was selected on the command line, assume that's what the user
wanted. Otherwise, the other options should only be chosen if our
repository doesn't exist (that is, repo_fmt->version is -1) or it's
specifically detected as having no hash algorithm. This latter case
should not occur, but we preserve it just in case. In those cases,
first use the environment, then the config, and finally, the default
algorithm.
Then, if the algorithm does not match the repository, complain loudly
and refuse to reinitialize the repository with a different hash
algorithm.
With this change, we will choose SHA-256 in breaking changes mode and in
Git 3.0, which is what we want. Add several tests to cover this case
and several others discovered along the way. Update the comment to
better describe the situation.
Reported-by: Adam Dinwoodie <adam@dinwoodie.org>
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
Changes from v3:
* Update commit message.
* Update comment.
* Place `sane_unset` in subshells.
setup.c | 32 ++++++++++++++++-----------
t/t0001-init.sh | 57 +++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 77 insertions(+), 12 deletions(-)
diff --git a/setup.c b/setup.c
index cedc031c54..c2a56b997a 100644
--- a/setup.c
+++ b/setup.c
@@ -2888,24 +2888,29 @@ static void repository_format_configure(struct repository_format *repo_fmt,
config_with_options(read_default_format_config, &cfg, NULL, NULL, &opts);
/*
- * If we already have an initialized repo, don't allow the user to
- * specify a different algorithm, as that could cause corruption.
- * Otherwise, if the user has specified one on the command line, use it.
+ * If the user specified a hash algorithm on the command line, then use
+ * that. Otherwise, if the repository exists, use that algorithm; if
+ * not, choose the environment variable or config option in that order,
+ * and then fall back to the default.
+ *
+ * If the repository is already initialized and we pick a different
+ * algorithm than the current one, we will reject that below.
*/
env = getenv(GIT_DEFAULT_HASH_ENVIRONMENT);
- if (repo_fmt->version >= 0 && hash != GIT_HASH_UNKNOWN && hash != repo_fmt->hash_algo)
- die(_("attempt to reinitialize repository with different hash"));
- else if (hash != GIT_HASH_UNKNOWN)
- repo_fmt->hash_algo = hash;
- else if (env) {
+ if (hash != GIT_HASH_UNKNOWN) {
+ /* nothing to do */
+ } else if (repo_fmt->version >= 0 &&
+ repo_fmt->hash_algo != GIT_HASH_UNKNOWN) {
+ hash = repo_fmt->hash_algo;
+ } else if (env) {
int env_algo = hash_algo_by_name(env);
if (env_algo == GIT_HASH_UNKNOWN)
die(_("unknown hash algorithm '%s'"), env);
- if (repo_fmt->version < 0 ||
- repo_fmt->hash_algo == GIT_HASH_UNKNOWN)
- repo_fmt->hash_algo = env_algo;
+ hash = env_algo;
} else if (cfg.hash != GIT_HASH_UNKNOWN) {
- repo_fmt->hash_algo = cfg.hash;
+ hash = cfg.hash;
+ } else {
+ hash = GIT_HASH_DEFAULT;
}
/*
@@ -3022,6 +3027,8 @@ static void repository_format_configure(struct repository_format *repo_fmt,
* current storage formats do not change.
*/
if (repo_fmt->version >= 0) {
+ if (hash != repo_fmt->hash_algo)
+ die(_("attempt to reinitialize repository with different hash"));
if (ref_storage_format != repo_fmt->ref_storage_format)
die(_("attempt to reinitialize repository with different reference storage format"));
if ((ref_storage_payload || repo_fmt->ref_storage_payload) &&
@@ -3038,6 +3045,7 @@ static void repository_format_configure(struct repository_format *repo_fmt,
free(cfg.ref_storage_payload);
free(repo_fmt->ref_storage_payload);
+ repo_fmt->hash_algo = hash;
repo_fmt->ref_storage_format = ref_storage_format;
repo_fmt->ref_storage_payload = ref_storage_payload;
diff --git a/t/t0001-init.sh b/t/t0001-init.sh
index 9e57a06cea..d4bbe72db3 100755
--- a/t/t0001-init.sh
+++ b/t/t0001-init.sh
@@ -516,6 +516,17 @@ test_expect_success 're-init from a linked worktree' '
)
'
+test_expect_success 'git init uses default object format' '
+ test_when_finished "rm -rf repo" &&
+ (
+ sane_unset GIT_DEFAULT_HASH &&
+ git init repo &&
+ echo "$GIT_TEST_BUILTIN_HASH" >expect &&
+ git -C repo rev-parse --show-object-format >actual &&
+ test_cmp expect actual
+ )
+'
+
test_expect_success 'init honors GIT_DEFAULT_HASH' '
test_when_finished "rm -rf sha1 sha256" &&
GIT_DEFAULT_HASH=sha1 git init sha1 &&
@@ -602,6 +613,52 @@ do
'
done
+test_expect_success 'init refuses to reinitialize with different hash' '
+ test_when_finished "rm -rf repo" &&
+ (
+ sane_unset GIT_DEFAULT_HASH &&
+ for algo in sha1 sha256
+ do
+ if test "$algo" = sha1
+ then
+ other=sha256
+ else
+ other=sha1
+ fi &&
+ git init --object-format="$algo" repo &&
+ cat >expect <<-EOF &&
+ fatal: attempt to reinitialize repository with different hash
+ EOF
+ test_must_fail git init --object-format="$other" repo 2>err &&
+ test_cmp expect err &&
+ rm -fr repo || exit 1
+ done
+ )
+'
+
+test_expect_success 're-init does not modify hash from config' '
+ test_when_finished "rm -rf repo" &&
+ (
+ sane_unset GIT_DEFAULT_HASH &&
+ for algo in sha1 sha256
+ do
+ if test "$algo" = sha1
+ then
+ other=sha256
+ else
+ other=sha1
+ fi &&
+ git init --object-format="$algo" repo &&
+ test_config_global init.defaultObjectFormat "$other" &&
+ git init repo &&
+ echo "$algo" >expect &&
+ git -C repo rev-parse --show-object-format >actual &&
+ test_cmp expect actual &&
+ rm -fr repo || exit 1
+ done
+ )
+'
+
test_expect_success 'extensions.objectFormat is not allowed with repo version 0' '
test_when_finished "rm -rf explicit-v0" &&
git init --object-format=sha256 explicit-v0 &&
Re: [PATCH v4] setup: fix hash algorithm detection
Author: Junio C Hamano
Date: Mon, 23 Nov 2026 02:29
Date: Mon, 23 Nov 2026 02:29
38 lines
14261 bytes
14261 bytes
"brian m. carlson" <sandals@crustytoothpaste.net> writes: > Our current hash algorithm selection code has a few different problems. > First, we do not actually default to GIT_HASH_DEFAULT because, due to a > bug, our code has never considered GIT_HASH_DEFAULT as a default for git > init and if an algorithm is not specified in the config file, we assume > that the repository is SHA-1. > > Second, if we have an algorithm chosen by init.defaultObjectFormat and > we re-init a repository, we will change the hash algorithm, which is > very much not desired. > > To fix this, let's restructure this code slightly. First, if an > algorithm was selected on the command line, assume that's what the user > wanted. Otherwise, the other options should only be chosen if our > repository doesn't exist (that is, repo_fmt->version is -1) or it's > specifically detected as having no hash algorithm. This latter case > should not occur, but we preserve it just in case. In those cases, > first use the environment, then the config, and finally, the default > algorithm. > > Then, if the algorithm does not match the repository, complain loudly > and refuse to reinitialize the repository with a different hash > algorithm. > > With this change, we will choose SHA-256 in breaking changes mode and in > Git 3.0, which is what we want. Add several tests to cover this case > and several others discovered along the way. Update the comment to > better describe the situation. ;-) > * Update comment. > * Place `sane_unset` in subshells. Changes relative to the previous round all look good to me, and I've read the previous round fairly thoroughly, so everything looks good.
Re: [PATCH v4] setup: fix hash algorithm detection
Author: Junio C Hamano
Date: Mon, 23 Nov 2026 16:14
Date: Mon, 23 Nov 2026 16:14
97 lines
16958 bytes
16958 bytes
"brian m. carlson" <sandals@crustytoothpaste.net> writes:
> Our current hash algorithm selection code has a few different problems.
> First, we do not actually default to GIT_HASH_DEFAULT because, due to a
> bug, our code has never considered GIT_HASH_DEFAULT as a default for git
> init and if an algorithm is not specified in the config file, we assume
> that the repository is SHA-1.
REPOSITORY_FORMAT_INIT does set .hash_algo to GIT_HASH_DEFAULT, but
create_repository() calls read_repository_format() early, and that
overwrites .hash_algo to GIT_HASH_SHA1_LEGACY when version is -1 (e.g.,
a new repository). So indeed, DEFAULT is not honoured in the code path.
> diff --git a/setup.c b/setup.c
> index cedc031c54..c2a56b997a 100644
> --- a/setup.c
> +++ b/setup.c
> @@ -2888,24 +2888,29 @@ static void repository_format_configure(struct repository_format *repo_fmt,
> config_with_options(read_default_format_config, &cfg, NULL, NULL, &opts);
>
> /*
> - * If we already have an initialized repo, don't allow the user to
> - * specify a different algorithm, as that could cause corruption.
> - * Otherwise, if the user has specified one on the command line, use it.
> + * If the user specified a hash algorithm on the command line, then use
> + * that. Otherwise, if the repository exists, use that algorithm; if
> + * not, choose the environment variable or config option in that order,
> + * and then fall back to the default.
> + *
> + * If the repository is already initialized and we pick a different
> + * algorithm than the current one, we will reject that below.
> */
> env = getenv(GIT_DEFAULT_HASH_ENVIRONMENT);
> - if (repo_fmt->version >= 0 && hash != GIT_HASH_UNKNOWN && hash != repo_fmt->hash_algo)
> - die(_("attempt to reinitialize repository with different hash"));
> - else if (hash != GIT_HASH_UNKNOWN)
> - repo_fmt->hash_algo = hash;
> - else if (env) {
> + if (hash != GIT_HASH_UNKNOWN) {
> + /* nothing to do */
> + } else if (repo_fmt->version >= 0 &&
> + repo_fmt->hash_algo != GIT_HASH_UNKNOWN) {
> + hash = repo_fmt->hash_algo;
I was comparing what is done to hash (here), ref-format (below), and
obj-format (further down), and noticed that the latter two only check
"else if (repo_fmt->version >= 0)" at the corresponding place. I was
confused by the extra check to ensure '.hash_algo' here is not
UNKNOWN.
I know the proposed commit log message did say "should not occur", but
the code makes readers wonder why the impossible case is sitting
there, and it will be even more so after the code becomes part of our
history and somebody is reading this code in a few months. They do
not always go back to the log message.
Before control reaches here, create_repository() would have called
read_and_verify_repository_format(), which in turn would have called
read_repository_format(), which in turn uses check_repo_format().
check_repo_format() is the only place core.repositoryformatversion is
read and the '.version' member is set to a value to give us
"repo_fmt->version >= 0" (after REPOSITORY_FORMAT_INIT initializes the
member to -1). The function also parses "extensions." and calls
handle_extension(). It rejects GIT_HASH_UNKNOWN, so the '.hash_algo'
member cannot be set to GIT_HASH_UNKNOWN by it. Again, aside from the
initialization done in read_repository_format() to
GIT_HASH_SHA1_LEGACY, this is the only place the '.hash_algo' member
is assigned to.
Therefore, if the '.version' member is >= 0, the '.hash_algo' member
can never be GIT_HASH_UNKNOWN, so I think it is pointless (and
confusing) to have the check to ensure '.hash_algo' is not UNKNOWN
here. Simplifying the condition to
} else if (repo_fmt->version >= 0) {
may save readers from the confusion I had. And that is what the
ref_storage_format and object_storage_format sides of the code do in
the same function, I think.
> + } else if (env) {
> int env_algo = hash_algo_by_name(env);
> if (env_algo == GIT_HASH_UNKNOWN)
> die(_("unknown hash algorithm '%s'"), env);
> - if (repo_fmt->version < 0 ||
> - repo_fmt->hash_algo == GIT_HASH_UNKNOWN)
> - repo_fmt->hash_algo = env_algo;
> + hash = env_algo;
> } else if (cfg.hash != GIT_HASH_UNKNOWN) {
> - repo_fmt->hash_algo = cfg.hash;
> + hash = cfg.hash;
> + } else {
> + hash = GIT_HASH_DEFAULT;
> }
Re: [PATCH v4] setup: fix hash algorithm detection
Author: Junio C Hamano
Date: Mon, 23 Nov 2026 16:25
Date: Mon, 23 Nov 2026 16:25
56 lines
14423 bytes
14423 bytes
"brian m. carlson" <sandals@crustytoothpaste.net> writes: > +test_expect_success 're-init does not modify hash from config' ' > + test_when_finished "rm -rf repo" && > + ( > + sane_unset GIT_DEFAULT_HASH && > + for algo in sha1 sha256 > + do > + if test "$algo" = sha1 > + then > + other=sha256 > + else > + other=sha1 > + fi && > + git init --object-format="$algo" repo && > + test_config_global init.defaultObjectFormat "$other" && > + git init repo && > + echo "$algo" >expect && > + git -C repo rev-parse --show-object-format >actual && > + test_cmp expect actual && > + rm -fr repo || exit 1 > + done > + ) > +' error: bug in the test script: test_when_finished does nothing in a subshell not ok 62 - re-init does not modify hash from config I think it is test_config_global that is getting complained. Perhaps something along this line would fix it. t/t0001-init.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git c/t/t0001-init.sh w/t/t0001-init.sh index 5def3f98b7..58271c8fac 100755 --- c/t/t0001-init.sh +++ w/t/t0001-init.sh @@ -638,6 +638,7 @@ test_expect_success 'init refuses to reinitialize with different hash' ' test_expect_success 're-init does not modify hash from config' ' test_when_finished "rm -rf repo" && + test_when_finished "test_unconfig --global init.defaultObjectFormat" && ( sane_unset GIT_DEFAULT_HASH && for algo in sha1 sha256 @@ -649,7 +650,7 @@ test_expect_success 're-init does not modify hash from config' ' other=sha1 fi && git init --object-format="$algo" repo && - test_config_global init.defaultObjectFormat "$other" && + git config --global init.defaultObjectFormat "$other" && git init repo && echo "$algo" >expect && git -C repo rev-parse --show-object-format >actual &&
Re: [PATCH v4] setup: fix hash algorithm detection
Author: "brian m. carlson"
Date: Mon, 23 Nov 2026 22:13
Date: Mon, 23 Nov 2026 22:13
58 lines
10980 bytes
10980 bytes
--G2dlVaWPApdAnWQk Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2026-11-23 at 16:25:16, Junio C Hamano wrote: > "brian m. carlson" <sandals@crustytoothpaste.net> writes: >=20 > > +test_expect_success 're-init does not modify hash from config' ' > > + test_when_finished "rm -rf repo" && > > + ( > > + sane_unset GIT_DEFAULT_HASH && > > + for algo in sha1 sha256 > > + do > > + if test "$algo" =3D sha1 > > + then > > + other=3Dsha256 > > + else > > + other=3Dsha1 > > + fi && > > + git init --object-format=3D"$algo" repo && > > + test_config_global init.defaultObjectFormat "$other" && > > + git init repo && > > + echo "$algo" >expect && > > + git -C repo rev-parse --show-object-format >actual && > > + test_cmp expect actual && > > + rm -fr repo || exit 1 > > + done > > + ) > > +' >=20 > error: bug in the test script: test_when_finished does nothing in a subsh= ell > not ok 62 - re-init does not modify hash from config >=20 > I think it is test_config_global that is getting complained. Perhaps > something along this line would fix it. I'll do a reroll. That only triggers on bash and I use dash as /bin/sh. --=20 brian m. carlson (they/them) Toronto, Ontario, CA Speaking for myself only --G2dlVaWPApdAnWQk Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- wr0EABYKAG8FgmsEunYJEHwMSWKIh6KBRxQAAAAAAB4AIHNhbHRAbm90YXRpb25z LnNlcXVvaWEtcGdwLm9yZz6XEgLcTZ4/WAm2BIjsZmDut5Lr+JvIuAV0SuocSCiU FiEECCzmip28ZfuD0cORfAxJYoiHooEAAI1JAQDyfsAcIuVLNswwUhLuGSEsTMh0 vJnuxKoL9s7l089NfQEAwj9CPEL8wKSZTYBNBR6JrnIPGDdWosLR6beDcchZpgU= =9MHj -----END PGP SIGNATURE----- --G2dlVaWPApdAnWQk--
Re: [PATCH v4] setup: fix hash algorithm detection
Author: Junio C Hamano
Date: Tue, 24 Nov 2026 00:01
Date: Tue, 24 Nov 2026 00:01
51 lines
14507 bytes
14507 bytes
"brian m. carlson" <sandals@crustytoothpaste.net> writes: >> I think it is test_config_global that is getting complained. Perhaps >> something along this line would fix it. > > I'll do a reroll. That only triggers on bash and I use dash as /bin/sh. Yeah, I run my tests under both shells exactly for that reason. Running tests with dash can (sometimes) catch unintended and unnoticed bashisms in the test scripts, and running tests with bash would allow some optional test lint features that are only available under bash. Thanks. If this is the only thing that the reroll would change, I already have a fix-up commit on top of the topic branch, so you can tell me to squash it in. Thanks. From 0064676b1a1b4263a45c168443849be4520b2ae3 Mon Sep 17 00:00:00 2001 From: Junio C Hamano <gitster@pobox.com> Date: Mon, 23 Nov 2026 08:23:38 -0800 Subject: [PATCH] SQUASH??? --- t/t0001-init.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/t/t0001-init.sh b/t/t0001-init.sh index 5def3f98b7..58271c8fac 100755 --- a/t/t0001-init.sh +++ b/t/t0001-init.sh @@ -638,6 +638,7 @@ test_expect_success 'init refuses to reinitialize with different hash' ' test_expect_success 're-init does not modify hash from config' ' test_when_finished "rm -rf repo" && + test_when_finished "test_unconfig --global init.defaultObjectFormat" && ( sane_unset GIT_DEFAULT_HASH && for algo in sha1 sha256 @@ -649,7 +650,7 @@ test_expect_success 're-init does not modify hash from config' ' other=sha1 fi && git init --object-format="$algo" repo && - test_config_global init.defaultObjectFormat "$other" && + git config --global init.defaultObjectFormat "$other" && git init repo && echo "$algo" >expect && git -C repo rev-parse --show-object-format >actual && -- 2.56.1-774-g531cf23297
[PATCH v5] setup: fix hash algorithm detection
Author: "brian m. carlson"
Date: Tue, 24 Nov 2026 22:59
Date: Tue, 24 Nov 2026 22:59
176 lines
15081 bytes
15081 bytes
Our current hash algorithm selection code has a few different problems.
First, we do not actually default to GIT_HASH_DEFAULT because, due to a
bug, our code has never considered GIT_HASH_DEFAULT as a default for git
init and if an algorithm is not specified in the config file, we assume
that the repository is SHA-1.
Second, if we have an algorithm chosen by init.defaultObjectFormat and
we re-init a repository, we will change the hash algorithm, which is
very much not desired.
To fix this, let's restructure this code slightly. First, if an
algorithm was selected on the command line, assume that's what the user
wanted. Otherwise, the other options should only be chosen if our
repository doesn't exist (that is, repo_fmt->version is -1). In those
cases, first use the environment, then the config, and finally, the
default algorithm.
Then, if the algorithm does not match the repository, complain loudly
and refuse to reinitialize the repository with a different hash
algorithm.
With this change, we will choose SHA-256 in breaking changes mode and in
Git 3.0, which is what we want. Add several tests to cover this case
and several others discovered along the way. Update the comment to
better describe the situation.
Reported-by: Adam Dinwoodie <adam@dinwoodie.org>
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
Changes since v4:
* Remove extra check for `GIT_HASH_UNKNOWN` and commit message text.
* Fix tests to not call `test_config_global` in a subshell.
setup.c | 31 ++++++++++++++++----------
t/t0001-init.sh | 58 +++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 77 insertions(+), 12 deletions(-)
diff --git a/setup.c b/setup.c
index cedc031c54..e2236d3481 100644
--- a/setup.c
+++ b/setup.c
@@ -2888,24 +2888,28 @@ static void repository_format_configure(struct repository_format *repo_fmt,
config_with_options(read_default_format_config, &cfg, NULL, NULL, &opts);
/*
- * If we already have an initialized repo, don't allow the user to
- * specify a different algorithm, as that could cause corruption.
- * Otherwise, if the user has specified one on the command line, use it.
+ * If the user specified a hash algorithm on the command line, then use
+ * that. Otherwise, if the repository exists, use that algorithm; if
+ * not, choose the environment variable or config option in that order,
+ * and then fall back to the default.
+ *
+ * If the repository is already initialized and we pick a different
+ * algorithm than the current one, we will reject that below.
*/
env = getenv(GIT_DEFAULT_HASH_ENVIRONMENT);
- if (repo_fmt->version >= 0 && hash != GIT_HASH_UNKNOWN && hash != repo_fmt->hash_algo)
- die(_("attempt to reinitialize repository with different hash"));
- else if (hash != GIT_HASH_UNKNOWN)
- repo_fmt->hash_algo = hash;
- else if (env) {
+ if (hash != GIT_HASH_UNKNOWN) {
+ /* nothing to do */
+ } else if (repo_fmt->version >= 0) {
+ hash = repo_fmt->hash_algo;
+ } else if (env) {
int env_algo = hash_algo_by_name(env);
if (env_algo == GIT_HASH_UNKNOWN)
die(_("unknown hash algorithm '%s'"), env);
- if (repo_fmt->version < 0 ||
- repo_fmt->hash_algo == GIT_HASH_UNKNOWN)
- repo_fmt->hash_algo = env_algo;
+ hash = env_algo;
} else if (cfg.hash != GIT_HASH_UNKNOWN) {
- repo_fmt->hash_algo = cfg.hash;
+ hash = cfg.hash;
+ } else {
+ hash = GIT_HASH_DEFAULT;
}
/*
@@ -3022,6 +3026,8 @@ static void repository_format_configure(struct repository_format *repo_fmt,
* current storage formats do not change.
*/
if (repo_fmt->version >= 0) {
+ if (hash != repo_fmt->hash_algo)
+ die(_("attempt to reinitialize repository with different hash"));
if (ref_storage_format != repo_fmt->ref_storage_format)
die(_("attempt to reinitialize repository with different reference storage format"));
if ((ref_storage_payload || repo_fmt->ref_storage_payload) &&
@@ -3038,6 +3044,7 @@ static void repository_format_configure(struct repository_format *repo_fmt,
free(cfg.ref_storage_payload);
free(repo_fmt->ref_storage_payload);
+ repo_fmt->hash_algo = hash;
repo_fmt->ref_storage_format = ref_storage_format;
repo_fmt->ref_storage_payload = ref_storage_payload;
diff --git a/t/t0001-init.sh b/t/t0001-init.sh
index 9e57a06cea..55b5a1d247 100755
--- a/t/t0001-init.sh
+++ b/t/t0001-init.sh
@@ -516,6 +516,17 @@ test_expect_success 're-init from a linked worktree' '
)
'
+test_expect_success 'git init uses default object format' '
+ test_when_finished "rm -rf repo" &&
+ (
+ sane_unset GIT_DEFAULT_HASH &&
+ git init repo &&
+ echo "$GIT_TEST_BUILTIN_HASH" >expect &&
+ git -C repo rev-parse --show-object-format >actual &&
+ test_cmp expect actual
+ )
+'
+
test_expect_success 'init honors GIT_DEFAULT_HASH' '
test_when_finished "rm -rf sha1 sha256" &&
GIT_DEFAULT_HASH=sha1 git init sha1 &&
@@ -602,6 +613,53 @@ do
'
done
+test_expect_success 'init refuses to reinitialize with different hash' '
+ test_when_finished "rm -rf repo" &&
+ (
+ sane_unset GIT_DEFAULT_HASH &&
+ for algo in sha1 sha256
+ do
+ if test "$algo" = sha1
+ then
+ other=sha256
+ else
+ other=sha1
+ fi &&
+ git init --object-format="$algo" repo &&
+ cat >expect <<-EOF &&
+ fatal: attempt to reinitialize repository with different hash
+ EOF
+ test_must_fail git init --object-format="$other" repo 2>err &&
+ test_cmp expect err &&
+ rm -fr repo || exit 1
+ done
+ )
+'
+
+test_expect_success 're-init does not modify hash from config' '
+ test_when_finished "rm -rf repo" &&
+ test_when_finished "test_unconfig --global init.defaultObjectFormat" &&
+ (
+ sane_unset GIT_DEFAULT_HASH &&
+ for algo in sha1 sha256
+ do
+ if test "$algo" = sha1
+ then
+ other=sha256
+ else
+ other=sha1
+ fi &&
+ git init --object-format="$algo" repo &&
+ git config --global init.defaultObjectFormat "$other" &&
+ git init repo &&
+ echo "$algo" >expect &&
+ git -C repo rev-parse --show-object-format >actual &&
+ test_cmp expect actual &&
+ rm -fr repo || exit 1
+ done
+ )
+'
+
test_expect_success 'extensions.objectFormat is not allowed with repo version 0' '
test_when_finished "rm -rf explicit-v0" &&
git init --object-format=sha256 explicit-v0 &&
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