commit 78caff98cb8783be4d83da7279e407d4ccd1f187 from: Stefan Sperling date: Thu Sep 30 08:24:01 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 - 5d8cbca3b331d9f20dc4ee509342988c82e11656 commit + 78caff98cb8783be4d83da7279e407d4ccd1f187 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()