Commit Diff


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