Hi brian, On Thu, 11 Jun 2020, brian m. carlson wrote: > On 2020-06-11 at 23:14:46, Junio C Hamano wrote: > > Alban Gruin <alban.gruin@xxxxxxxxx> writes: > > > > > Why adding yet another environment variable instead of relying only on a > > > config option? I understand it's for the tests, but can't we add a > > > shell function in test-lib.sh (and friends) that tries to read > > > `GIT_TEST_DEFAULT_BRANCH_NAME', and, if it exists, sets > > > `core.defaultBranchName'? > > > > Can you produce such a patch that does it cleanly? My knee jerk > > reaction is that I would suspect that you end up having to touch > > many places in the t/ scripts, but if you prove otherwise, that > > would certainly be appreciated. > > > > And no, > > > > git () { command git -c core.defaultBranchName=master "$@" } > > > > is not an acceptable solution. > > I would also be delighted to see such a solution, but my experience with > the SHA-256 work tells me there's unlikely to be one. We do a lot of > "git init" operations in random places in the test suite and as a > consequence it's very hard to make a change without touching a large > number of tests. That's a valid point, indeed. > If we were writing things today, perhaps we would use a function (e.g., > test_init_repo or such) to wrap this case, but we unfortunately didn't > think about that and we're stuck with what we have now unless someone > retrofits the test suite. There is actually `test_create_repo` (see https://github.com/git/git/blob/v2.27.0/t/test-lib-functions.sh#L1145-L1159): # Most tests can use the created repository, but some may need to create # more. # Usage: test_create_repo <directory> test_create_repo () { test "$#" = 1 || BUG "not 1 parameter to test-create-repo" repo="$1" mkdir -p "$repo" ( cd "$repo" || error "Cannot setup test environment" "${GIT_TEST_INSTALLED:-$GIT_EXEC_PATH}/git$X" init \ "--template=$GIT_BUILD_DIR/templates/blt/" >&3 2>&4 || error "cannot run git init -- have you built things yet?" mv .git/hooks .git/hooks-disabled ) || exit } But I agree that few test scripts use it: $ git grep 'git init' v2.27.0 -- t/ | wc -l 765 $ git grep 'test_create_repo' v2.27.0 -- t/ | wc -l 296 Ciao, Dscho