From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: "Thomas Weißschuh" <thomas@t-8ch.de>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] builtin: add git-default-branch command
Date: Sat, 30 Oct 2021 19:18:26 +0200 [thread overview]
Message-ID: <211030.86ilxe4edm.gmgdl@evledraar.gmail.com> (raw)
In-Reply-To: <20211030140112.834650-1-thomas@t-8ch.de>
On Sat, Oct 30 2021, Thomas Weißschuh wrote:
> Introduce command `default-branch` which allows to retrieve the branch
> that will be used by git-init.
>
> Currently this command is equivalent to
> git config init.defaultbranch || 'master'
>
> This however will break if at one point the default branch is changed as
> indicated by `default_branch_name_advice` in `refs.c`.
>
> By providing this command ahead of time users of git can make their
> code forward-compatible.
Recently there was a discussion on a similar topic, i.e. to have git
explicitly aware of "default config" as far as "git config -l" etc. go:
https://lore.kernel.org/git/87czvoowg2.fsf@evledraar.gmail.com/
I'd much rather see as add this as some mode of git-config, even if it's
a new --get-or-git-default switch:
git config --get-or-git-default init.defaultBranch
That would just currently die if you fed it any other value than
init.defaultBranch, i.e. that (or similar) would be a generic enough
interface that we could expand on it.
Whereas having a new-built in just for this one config variable...
> +test_expect_success 'without configuration' '
> + b=$(git default-branch) &&
> + verbose test "$b" = master
> +'
> +
> +test_expect_success 'with configuration' '
> + git config init.defaultbranch foo &&
> + b=$(git default-branch) &&
> + echo $b &&
> + verbose test "$b" = foo
> +'
> +
Should lose the echo, and these comparisons should be using test_cmp,
also use "test_config" not "git config" unless in a sub-repo or similar.
next prev parent reply other threads:[~2021-10-30 17:22 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 [this message]
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
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=211030.86ilxe4edm.gmgdl@evledraar.gmail.com \
--to=avarab@gmail.com \
--cc=git@vger.kernel.org \
--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).