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

From:
Thomas Adam <thomas@xteddy.org>
Subject:
regress: unset HOME for 'git init'
To:
gameoftrees@openbsd.org
Date:
Fri, 15 Aug 2025 13:04:34 +0100

Download raw body.

Thread
Hi,

When running regress, there's a potential that the "git init" command could
implicitly use ~/.gitconfig -- this has consequences for us, since this file
could affect the created git repo.

Specifically though, it's possible that the default branch name could be
anything, rather than what we want it to be -- which should be to match the
default for git(1).  Although this is still marked as a TODO item in
regress/cmdline/common.sh -- I think for now, explicitly making git(1) think
there's no ~/.gitconfig is the way to go -- we can address any specific git
issues we want to set (such as the default branch name) at a later date.

OK?

diff /home/n6tadam/p/gt/got-testing
path + /home/n6tadam/p/gt/got-testing
commit - a0923235a9fef33971f7e2428bcb156b02c85bec
blob - b17caad2195bf8f03071162075d2c331a52f4894
file + regress/cmdline/common.sh
--- regress/cmdline/common.sh
+++ regress/cmdline/common.sh
@@ -40,7 +40,11 @@ fi
 
 git_init()
 {
-	git init -q --object-format=${GOT_TEST_ALGO} "$1"
+	# Unset $HOME when creating a git repo.  We do this so that git
+	# doesn't try and use ~/.gitconfig which could affect the default
+	# branch name (as well as other settings), which will break
+	# assumptions with the tests being run.
+	(HOME= git init -q --object-format=${GOT_TEST_ALGO} "$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.
commit - a0923235a9fef33971f7e2428bcb156b02c85bec
blob - 9d3971a3148f13aa50c0b1e2ec9a992d1f859e29
file + regress/cmdline/send.sh
--- regress/cmdline/send.sh
+++ regress/cmdline/send.sh
@@ -1568,7 +1568,11 @@ test_send_gitconfig() {
 	local testurl=ssh://127.0.0.1/$testroot
 	local commit_id=`git_show_head $testroot/repo`
 
-	git init -q --bare $testroot/upstream-repo
+	# Unset $HOME when creating a git repo.  We do this so that git
+	# doesn't try and use ~/.gitconfig which could affect the default
+	# branch name (as well as other settings), which will break
+	# assumptions with the tests being run.
+	(HOME= git init -q --bare $testroot/upstream-repo)
 	ret=$?
 	if [ $ret -ne 0 ]; then
 		echo "git init failed unexpectedly" >&2

-- Thomas Adam