commit f60607c885e6c72e0bd0647907573da3c9acbc43 from: Stefan Sperling via: Thomas Adam date: Thu Sep 30 20:53:21 2021 UTC explicitly set the default branch name after 'git init' in regress tests We need to do this because newer versions of Git support an arbitrary default branch name which can be set by users. We don't want tests to fail when this option is used. pointed out by Thomas Adam commit - ccd081e7f1f2b65ac6191c78813dcd622b559dd0 commit + f60607c885e6c72e0bd0647907573da3c9acbc43 blob - 260f6406dd2eba1355d668e2c054b7f09f9f1ee5 blob + c0b2732f4fd9fd4cc10cc8964d7e255b1341f13b --- regress/cmdline/common.sh +++ regress/cmdline/common.sh @@ -29,6 +29,17 @@ export MALLOC_OPTIONS=S git_init() { git init -q "$1" + + # Switch the default branch to match our test expectations if needed. + # Only need to change HEAD since 'git init' did not create any refs. + # Relying on implementation details of 'git init' is no problem for us. + # We want to be alerted when Git changes fundamental assumptions such + # as what an empty repository looks like and where the default branch + # is set. In such cases Got's own tooling might well need to change + # its behaviour, too, and our tests should fail. + # TODO: Update all tests to assume 'main' instead of 'master' and + # switch to main here, to match Got's own default. + echo "ref: refs/heads/master" > "$1/.git/HEAD" } maybe_pack_repo()