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 v4] setup: fix hash algorithm detection
Date: Sun, 22 Nov 2026 18:29:01 -0800 [thread overview]
Message-ID: <xmqqmrr0gu1e.fsf@gitster.g> (raw)
In-Reply-To: <20261123011403.720209-1-sandals@crustytoothpaste.net> (brian m. carlson's message of "Mon, 23 Nov 2026 01:14:03 +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 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.
next prev parent reply other threads:[~2026-11-23 2:29 UTC|newest]
Thread overview: 25+ 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
2026-11-16 6:22 ` Patrick Steinhardt
2026-11-19 1:06 ` [PATCH v3] " brian m. carlson
2026-11-19 9:52 ` Patrick Steinhardt
2026-11-19 16:26 ` Junio C Hamano
2026-11-19 16:38 ` Junio C Hamano
2026-11-19 22:20 ` brian m. carlson
2026-11-19 23:06 ` Junio C Hamano
2026-11-23 1:14 ` [PATCH v4] " brian m. carlson
2026-11-23 2:29 ` Junio C Hamano [this message]
2026-11-23 16:14 ` Junio C Hamano
2026-11-23 16:25 ` Junio C Hamano
2026-11-23 22:13 ` brian m. carlson
2026-11-24 0:01 ` Junio C Hamano
2026-11-24 22:59 ` [PATCH v5] " brian m. carlson
2026-12-01 8:10 ` Patrick Steinhardt
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=xmqqmrr0gu1e.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.