diff mbox series

[11/16] test-lib: do not show advice about init.defaultBranch under --verbose

Message ID patch-11.16-cdbff4df362-20210412T110456Z-avarab@gmail.com (mailing list archive)
State Superseded
Headers show
Series test-lib.sh: new test_commit args, simplification & fixes | expand

Commit Message

Ævar Arnfjörð Bjarmason April 12, 2021, 11:09 a.m. UTC
Arrange for the advice about naming the initial branch not to be shown
in the --verbose output of the test suite.

Since 675704c74dd (init: provide useful advice about
init.defaultBranch, 2020-12-11) some tests have been very chatty with
repeated occurrences of this multi-line advice. Having it be this
verbose isn't helpful for anyone in the context of git's own test
suite, and it makes debugging tests that use their own "git init"
invocations needlessly distracting.

By setting the GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME variable early in
test-lib.sh itself we'll squash the warning not only for
test_create_repo(), as 675704c74dd explicitly intended, but also for
other "git init" invocations.

And once we'd like to have this configuration set for all "git init"
invocations in the test suite we can get rid of the init.defaultBranch
configuration setting in test_create_repo(), as
repo_default_branch_name() in refs.c will take the GIT_TEST_* variable
over it being set.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 t/test-lib-functions.sh | 1 -
 t/test-lib.sh           | 5 +++++
 2 files changed, 5 insertions(+), 1 deletion(-)

Comments

SZEDER Gábor April 15, 2021, 7:07 p.m. UTC | #1
On Mon, Apr 12, 2021 at 01:09:00PM +0200, Ævar Arnfjörð Bjarmason wrote:
> diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
> index 674b865a20d..c81726acb9e 100644
> --- a/t/test-lib-functions.sh
> +++ b/t/test-lib-functions.sh
> @@ -1259,7 +1259,6 @@ test_create_repo () {
>  	(
>  		cd "$repo" || error "Cannot setup test environment"
>  		"${GIT_TEST_INSTALLED:-$GIT_EXEC_PATH}/git$X" \
> -			-c init.defaultBranch="${GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME-master}" \
>  			init \

This change got my hopes up that

  GIT_TEST_INSTALLED=/.../v1.6.0/bin ./t9999-foo.sh

will work again (it didn't yet support 'git init -c <...>'), but,
alas, already the next patch will turn this into 'git init ...
<trash-dir>', and v1.6.0 didn't support that, either, so it will
remain broken...  Oh, well.

>  			"--template=$GIT_BUILD_DIR/templates/blt/" >&3 2>&4 ||
>  		error "cannot run git init -- have you built things yet?"
> diff --git a/t/test-lib.sh b/t/test-lib.sh
> index a8869eee58f..0057dfa69d0 100644
> --- a/t/test-lib.sh
> +++ b/t/test-lib.sh
> @@ -64,6 +64,11 @@ then
>  	export GIT_TEST_DISALLOW_ABBREVIATED_OPTIONS
>  fi
>  
> +# Explicitly set the default branch name for testing, to avoid the
> +# transitory "git init" warning under --verbose.
> +: ${GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME:=master}
> +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
> +
>  ################################################################
>  # It appears that people try to run tests without building...
>  "${GIT_TEST_INSTALLED:-$GIT_BUILD_DIR}/git$X" >/dev/null
> -- 
> 2.31.1.634.gb41287a30b0
>
diff mbox series

Patch

diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
index 674b865a20d..c81726acb9e 100644
--- a/t/test-lib-functions.sh
+++ b/t/test-lib-functions.sh
@@ -1259,7 +1259,6 @@  test_create_repo () {
 	(
 		cd "$repo" || error "Cannot setup test environment"
 		"${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 ||
 		error "cannot run git init -- have you built things yet?"
diff --git a/t/test-lib.sh b/t/test-lib.sh
index a8869eee58f..0057dfa69d0 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -64,6 +64,11 @@  then
 	export GIT_TEST_DISALLOW_ABBREVIATED_OPTIONS
 fi
 
+# Explicitly set the default branch name for testing, to avoid the
+# transitory "git init" warning under --verbose.
+: ${GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME:=master}
+export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
+
 ################################################################
 # It appears that people try to run tests without building...
 "${GIT_TEST_INSTALLED:-$GIT_BUILD_DIR}/git$X" >/dev/null