Commit Diff


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()