Hi folks,
As part of preparing for Git v3, in particular for Nixpkgs, I've been running a bunch of tests using Git built with `WITH_BREAKING_CHANGES=1`. Somewhat to my surprise, `git init` seems to still be creating new repositories using sha1 rather than sha256. Is this expected?
For reference, I've attached the test script I've produced as a repro that can be run from the root of a Git checkout, although it does require Nix. I've confirmed the behaviour at v2.56.0, next (972d6e3ab651d838b30a8d5d70d8ef6ced05a986) and main (0ffa3e35c7c82ab8d0de226149fb03b3f7674d05).
For a simpler repro that doesn't require Nix, build Git with `WITH_BREAKING_CHANGES=1`, then run:
``` git init tmpdir git -C tmpdir rev-parse --show-object-format ```
This will print "sha1", when I'd expect "sha256".
#!/usr/bin/env nix #!nix shell #!nix --override-flake nixpkgs https://releases.nixos.org/nixos/unstable/nixos-26.11pre1105037.1c89083e451e/nixexprs.tar.zst #!nix --ignore-env #!nix nixpkgs#bash nixpkgs#coreutils nixpkgs#nix nixpkgs#findutils nixpkgs#gnused nixpkgs#autoconf nixpkgs#gnumake nixpkgs#gcc nixpkgs#cargo #!nix --command bash
set -euo pipefail
tmpdir="$(mktemp --dir)" trap 'rm -rf -- "$tmpdir"' EXIT
# Get the paths we need for zlib-ng export NIX_PATH=nixpkgs=https://releases.nixos.org/nixos/unstable/nixos-26.11pre1105037.1c89083e451e/nixexprs.tar.zst nix-build '<nixpkgs>' -A zlib-ng -A zlib-ng.dev -o "$tmpdir"/zlib-ng zlib_lib="$(realpath "$tmpdir"/zlib-ng)" zlib_dev="$(realpath "$tmpdir"/zlib-ng-dev)"
# Work out how much to parallelise the builds jobs="$(nproc)"
# Make sure the build process can find zlib-ng export CPPFLAGS="-isystem $zlib_dev/include" LDFLAGS="-L$zlib_lib/lib -Wl,-rpath,$zlib_lib"
# Set options: disable features we don't need for speed of building, use # zlib-ng, enable breaking changes. export ZLIB_NG=1 WITH_BREAKING_CHANGES=1 NO_TCLTK=1 NO_GETTEXT=1
# Build git make -j"$jobs" configure ./configure make -j"$jobs"
# Make sure Git config doesn't have anything unexpected export GIT_CONFIG_GLOBAL=/dev/null export GIT_CONFIG_SYSTEM=/dev/null export GIT_CONFIG=/dev/null export GIT_CONFIG_COUNT=2 export GIT_CONFIG_KEY_0=user.name GIT_CONFIG_VALUE_0=Adam export GIT_CONFIG_KEY_1=user.email GIT_CONFIG_VALUE_1=adam@localhost export GIT_PAGER=cat
# Make sure calling `git` gets the right executable export PATH="$PWD":"$PATH"
# Set up a simple repository with a single commit git init "$tmpdir"/repo cd "$tmpdir"/repo touch test-file git add test-file git commit -m 'demo commit'
# Show everything's sha1 rather than sha256 git log --format=raw git rev-parse --show-object-format