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.