diff options
author | Thomas Weißschuh <thomas@t-8ch.de> | 2021-11-03 21:17:02 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2021-11-03 13:25:36 -0700 |
commit | e06c9e1df28e04bbf013840c6c50ce1be41b9583 (patch) | |
tree | 0e2c67584cfba601c6d29a4c6981711dba173626 /t/t0007-git-var.sh | |
parent | Git 2.33.1 (diff) | |
download | tgif-e06c9e1df28e04bbf013840c6c50ce1be41b9583.tar.xz |
var: add GIT_DEFAULT_BRANCH variable
Introduce the logical variable GIT_DEFAULT_BRANCH which represents the
the default branch name that will be used by "git init".
Currently this variable 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.
Helped-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Helped-by: Eric Sunshine <sunshine@sunshineco.com>
Helped-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t0007-git-var.sh')
-rwxr-xr-x | t/t0007-git-var.sh | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/t/t0007-git-var.sh b/t/t0007-git-var.sh index 88b9ae8158..3d6b71c1e5 100755 --- a/t/t0007-git-var.sh +++ b/t/t0007-git-var.sh @@ -25,6 +25,26 @@ 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 && + 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 + ) +' + # For git var -l, we check only a representative variable; # testing the whole output would make our test too brittle with # respect to unrelated changes in the test suite's environment. |