"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Stefan Sperling <stsp@stsp.name>
Subject:
Re: got regress: set inital branch to 'master'
To:
Thomas Adam <thomas@xteddy.org>
Cc:
gameoftrees@openbsd.org
Date:
Thu, 30 Sep 2021 10:27:48 +0200

Download raw body.

Thread
On Wed, Sep 29, 2021 at 09:11:36PM +0100, Thomas Adam wrote:
> On Wed, Sep 29, 2021 at 09:03:56PM +0200, Stefan Sperling wrote:
> > fundamental assumptions Git makes about its own repository format. We
> > can rely on those assumptions, hoping they won't change in a way that
> > would break Got as it has been implemented.
> 
> Either way works for me.
> 
> Kindly,
> Thomas

I realized my sed expression won't work in case users have changed their
global git config to use yet another name, such as 'trunk' or 'devel'.
So we must use an even simpler approach:

diff a659f3773715efc113e49dafdbf7004661fcc88c 3a9ff2603178620aa1e31e55cdac42a879e22dc8
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()