From: Eric Sunshine Date: Wed, 03 Nov 2021 19:57:27 GMT Subject: Re: [PATCH v3] var: add GIT_DEFAULT_BRANCH variable Message-ID: In-Reply-To: <20211103185331.599463-1-thomas@t-8ch.de> On Wed, Nov 3, 2021 at 2:53 PM Thomas Weißschuh wrote: > Introduce the logical variable GIT_DEFAULT_BRANCH which represents the > the default branch name that will be used by "git init". > [...] > Signed-off-by: Thomas Weißschuh > --- > diff --git a/t/t0007-git-var.sh b/t/t0007-git-var.sh > @@ -27,6 +27,25 @@ test_expect_success !FAIL_PREREQS,!AUTOIDENT 'requested identities are strict' ' > +test_expect_success 'get GIT_DEFAULT_BRANCH without configuration' ' > + ( > + sane_unset GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME && > + echo master >expect && > + git var GIT_DEFAULT_BRANCH >actual && > + test_cmp expect actual > + ) > +' So that we don't have to worry about this test breaking if the default branch ever is changed, would it make sense to stop hard-coding "master" here and instead employ the trick that Dscho mentioned earlier in the thread (i.e. create a dummy repo and ask it for its default branch)? Something like this (untested): ( sane_unset GIT_TEST_... && git init defbranch && git -C defbranch symbolic-ref --short HEAD >expect && git var GIT_DEFAULT_BRANCH >actual && test_cmp expect actual ) > +test_expect_success 'get GIT_DEFAULT_BRANCH with configuration' ' > + test_config init.defaultbranch foo && > + ( > + sane_unset GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME && > + echo foo >expect && > + git var GIT_DEFAULT_BRANCH >actual && > + test_cmp expect actual > + ) > +'