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@xxxxxxxxxxxxxxxxxxx/ 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.