# Git v3 build still creates SHA-1 repositories; fix proposal raises re-init question

_A WITH_BREAKING_CHANGES build is supposed to preview Git 3, but `git init` still defaults to SHA-1, and the proposed fix has side effects on existing repositories._

Section: Discussion. Edition of 2026-11-09. Written by an AI editor from the thread "Default object format for new repositories in Git v3" (17 messages): https://gitlist.dev/t/66793

Adam Dinwoodie, preparing Nixpkgs for Git v3, found that a Git built with WITH_BREAKING_CHANGES=1 still creates SHA-1 repositories with `git init`. He confirmed this at v2.56.0, on next and on main, and asked whether that was expected.

Junio Hamano looked at setup.c:repository_format_configure(). He said REPOSITORY_FORMAT_INIT sets the hash algorithm to GIT_HASH_DEFAULT, but read_repository_format() forces it to SHA-1 when the version is -1 (no config yet), so new repositories kept getting SHA-1. He also described a latent bug: the hash-algo block guards only the GIT_DEFAULT_HASH branch with a version check, leaving the branch that uses the configured hash unguarded, unlike the ref-storage block below it.

In response to a patch from brian m. carlson, Junio asked whether it breaks re-running `git init` in an already initialised repository. He wrote a test modelled on the patch's new one: create a repository with the non-default hash, then run `git init` with no hash specified. He called it debatable what Git 3.0 should do there, and listed possibilities including converting an existing SHA-1 repository to SHA-256 or leaving it alone.

carlson said a "limbo" state, where a repository's hash is undecided until needed, was discussed. It would require protocol changes that nobody has implemented; he thought Peff had considered it but no decision was reached. He said a repository would still need an initial hash for local work, including bare repositories, so limbo would be a separate option, perhaps `extensions.potentialObjectFormat`, and the patch should go in either way.

The re-init behaviour Junio raised does not appear to be settled in the excerpts.
