Subject: Re: [PATCH v5 4/4] init: provide useful advice about init.defaultBranch

From: SZEDER Gábor <[email-masked]>
Date: Tue, 2 Feb 2021 22:24:51 +0100

On Fri, Dec 11, 2020 at 11:36:57AM +0000, Johannes Schindelin via GitGitGadget wrote:
> From: Johannes Schindelin <[email-masked]>
> 
> To give ample warning for users wishing to override Git's the fall-back
> for an unconfigured `init.defaultBranch` (in case we decide to change it
> in a future Git version), let's introduce some advice that is shown upon
> `git init` when that value is not set.
> 
> Note: two test cases in Git's test suite want to verify that the
> `stderr` output of `git init` is empty. It is now necessary to suppress
> the advice, we now do that via the `init.defaultBranch` setting. While
> not strictly necessary, we also set this to `false` in
> `test_create_repo()`.
> 
> Signed-off-by: Johannes Schindelin <[email-masked]>
> ---

> diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
> index 59bbf75e832..9910102ae1f 100644
> --- a/t/test-lib-functions.sh
> +++ b/t/test-lib-functions.sh
> @@ -1202,7 +1202,9 @@ test_create_repo () {
>  	mkdir -p "$repo"
>  	(
>  		cd "$repo" || error "Cannot setup test environment"
> -		"${GIT_TEST_INSTALLED:-$GIT_EXEC_PATH}/git$X" init \
> +		"${GIT_TEST_INSTALLED:-$GIT_EXEC_PATH}/git$X" -c \
> +			init.defaultBranch="${GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME-master}" \
> +			init \
>  			"--template=$GIT_BUILD_DIR/templates/blt/" >&3 2>&4 ||

This breaks GIT_TEST_INSTALLED when the given Git version doesn't yet
contain 8b1fa77867 (Allow passing of configuration parameters in the
command line, 2010-03-26):

  $ GIT_TEST_INSTALLED=.../v1.6.0/bin/ ./t9999-test.sh -x
  Unknown option: -c
  usage: git [--version] [--exec-path[=GIT_EXEC_PATH]] [-p|--paginate|--no-pager] [--bare] [--git-dir=GIT_DIR] [--work-tree=GIT_WORK_TREE] [--help] COMMAND [ARGS]
  error: cannot run git init -- have you built things yet?

>  		error "cannot run git init -- have you built things yet?"
>  		mv .git/hooks .git/hooks-disabled
> -- 
> gitgitgadget