From: Junio C Hamano <gitster@pobox.com>
To: "brian m. carlson" <sandals@crustytoothpaste.net>
Cc: <git@vger.kernel.org>, Patrick Steinhardt <ps@pks.im>,
Adam Dinwoodie <adam@dinwoodie.org>
Subject: Re: [PATCH v2] setup: fix hash algorithm detection
Date: Fri, 13 Nov 2026 16:16:08 -0800 [thread overview]
Message-ID: <xmqqh5hk8dyv.fsf@gitster.g> (raw)
In-Reply-To: <20261113221753.3408862-1-sandals@crustytoothpaste.net> (brian m. carlson's message of "Fri, 13 Nov 2026 22:17:53 +0000")
"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.
prev parent reply other threads:[~2026-11-14 0:16 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-06 16:50 Default object format for new repositories in Git v3 Adam Dinwoodie
2026-11-06 20:46 ` brian m. carlson
2026-11-08 1:16 ` [PATCH] setup: default hash algo to GIT_HASH_DEFAULT brian m. carlson
2026-11-08 4:42 ` Junio C Hamano
2026-11-08 14:38 ` brian m. carlson
2026-11-08 18:22 ` Junio C Hamano
2026-11-09 2:21 ` Junio C Hamano
2026-11-09 9:54 ` Patrick Steinhardt
2026-11-13 22:17 ` [PATCH v2] setup: fix hash algorithm detection brian m. carlson
2026-11-14 0:16 ` Junio C Hamano [this message]
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=xmqqh5hk8dyv.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=adam@dinwoodie.org \
--cc=git@vger.kernel.org \
--cc=ps@pks.im \
--cc=sandals@crustytoothpaste.net \
/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.