Re: [PATCH v3] var: add GIT_DEFAULT_BRANCH variable

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Nov 3, 2021 at 2:53 PM Thomas Weißschuh <thomas@xxxxxxxx> 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 <thomas@xxxxxxxx>
> ---
> 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
> +       )
> +'



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux