git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2] setup: fix hash algorithm detection

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 14, 2026, 00:16 UTC
Message-ID
<xmqqh5hk8dyv.fsf@gitster.g>
In-Reply-To
<20261113221753.3408862-1-sandals@crustytoothpaste.net>
"brian m. carlson" <sandals@crustytoothpaste.net> writes:
Show 27 quoted lines
> 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.
Previous: brian m. carlsonNext: Patrick Steinhardt
Message 10 of 11 in “Default object format for new repositories in Git v3”
  1. Adam DinwoodieNov 6, 2026
  2. brian m. carlsonNov 6, 2026
  3. setup: default hash algo to GIT_HASH_DEFAULTbrian m. carlson, Nov 8, 2026
  4. Junio C HamanoNov 8, 2026
  5. brian m. carlsonNov 8, 2026
  6. Junio C HamanoNov 8, 2026
  7. Junio C HamanoNov 9, 2026
  8. Patrick SteinhardtNov 9, 2026
  9. setup: fix hash algorithm detectionbrian m. carlson, Nov 13, 2026
  10. Junio C HamanoNov 14, 2026
  11. Patrick SteinhardtNov 16, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.