# git init still creates SHA-1 repositories in builds with breaking changes enabled

_A Nixpkgs packager found that WITH_BREAKING_CHANGES=1 does not yet make SHA-256 the default object format, and a patch to the hash selection logic is now out._

Section: Bugs. Edition of 2026-11-19. 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 has been testing Git built with WITH_BREAKING_CHANGES=1 as part of preparing Nixpkgs for Git v3. He was surprised that git init still creates new repositories using SHA-1 rather than SHA-256. He asked whether this is expected, and said he confirmed it at v2.56.0, next and main. He attached a Nix-based reproduction script and a simpler recipe that only needs a build with the flag set.

brian m. carlson responded with a patch. He says the current hash algorithm selection code has two problems. First, it does not actually default to GIT_HASH_DEFAULT. Second, if init.defaultObjectFormat selects an algorithm and a repository is re-initialized, the hash algorithm changes, which he says is not desired.

The patch restructures the logic. An algorithm given on the command line is taken as what the user wanted. Otherwise the other sources apply only when the repository does not exist (repo_fmt->version is -1) or has been detected as having no hash algorithm. In that case the environment is consulted first, then the config, and finally the default algorithm.

The excerpts include no review of the patch yet.
