git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Sunshine <sunshine@sunshineco.com>
To: "Thomas Weißschuh" <thomas@t-8ch.de>
Cc: "Git List" <git@vger.kernel.org>,
	"Johannes Schindelin" <Johannes.Schindelin@gmx.de>,
	"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
	"Jeff King" <peff@peff.net>, "Junio C Hamano" <gitster@pobox.com>
Subject: Re: [PATCH v3] var: add GIT_DEFAULT_BRANCH variable
Date: Wed, 3 Nov 2021 15:57:27 -0400	[thread overview]
Message-ID: <CAPig+cR0PL-XtfC8v4-u1Taq6yOLO=2HSHsNBnzvzLCyM-whZA@mail.gmail.com> (raw)
In-Reply-To: <20211103185331.599463-1-thomas@t-8ch.de>

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

  reply	other threads:[~2021-11-03 19:57 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-30 14:01 [PATCH] builtin: add git-default-branch command Thomas Weißschuh
2021-10-30 17:18 ` Ævar Arnfjörð Bjarmason
2021-11-02 13:39 ` Johannes Schindelin
2021-11-02 16:44   ` [PATCH v2] var: add GIT_DEFAULT_BRANCH variable Thomas Weißschuh
2021-11-02 16:53     ` Ævar Arnfjörð Bjarmason
2021-11-02 17:35       ` Thomas Weißschuh
2021-11-02 19:14         ` Ævar Arnfjörð Bjarmason
2021-11-02 20:08           ` Thomas Weißschuh
2021-11-03 11:37       ` Jeff King
2021-11-03 16:48         ` Eric Sunshine
2021-11-03 18:21     ` Junio C Hamano
2021-11-03 18:53       ` [PATCH v3] " Thomas Weißschuh
2021-11-03 19:57         ` Eric Sunshine [this message]
2021-11-03 20:04           ` Junio C Hamano
2021-11-03 20:17           ` [PATCH v4] " Thomas Weißschuh
2021-11-03 20:23             ` Junio C Hamano
2021-11-03 17:22   ` [PATCH] builtin: add git-default-branch command Junio C Hamano
2021-11-03 23:44     ` Johannes Schindelin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAPig+cR0PL-XtfC8v4-u1Taq6yOLO=2HSHsNBnzvzLCyM-whZA@mail.gmail.com' \
    --to=sunshine@sunshineco.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=peff@peff.net \
    --cc=thomas@t-8ch.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).