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

Re: [PATCH] setup: default hash algo to GIT_HASH_DEFAULT

From
brian m. carlson <sandals@crustytoothpaste.net>
Date
Nov 8, 2026, 14:38 UTC
Message-ID
<avCJbJE7mx_Z2zLY@fruit.crustytoothpaste.net>
In-Reply-To
<xmqqtsls53xr.fsf@gitster.g>
On 2026-11-08 at 04:42:56, Junio C Hamano wrote:
Show 22 quoted lines
> "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?

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.

-- 
brian m. carlson (they/them)
Toronto, Ontario, CA
Speaking for myself only
Previous: Junio C HamanoNext: Junio C Hamano
Message 5 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.