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 21:25:36 +0100 |
commit | e06c9e1df28e04bbf013840c6c50ce1be41b9583 (patch) | |
tree | 0e2c67584cfba601c6d29a4c6981711dba173626 /builtin/var.c | |
parent | Git 2.33.1 (diff) | |
download | git-e06c9e1df28e04bbf013840c6c50ce1be41b9583.tar.xz git-e06c9e1df28e04bbf013840c6c50ce1be41b9583.zip |
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 'builtin/var.c')
-rw-r--r-- | builtin/var.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/builtin/var.c b/builtin/var.c index 6c6f46b4ae..491db27429 100644 --- a/builtin/var.c +++ b/builtin/var.c @@ -5,6 +5,7 @@ */ #include "builtin.h" #include "config.h" +#include "refs.h" static const char var_usage[] = "git var (-l | <variable>)"; @@ -27,6 +28,11 @@ static const char *pager(int flag) return pgm; } +static const char *default_branch(int flag) +{ + return git_default_branch_name(1); +} + struct git_var { const char *name; const char *(*read)(int); @@ -36,6 +42,7 @@ static struct git_var git_vars[] = { { "GIT_AUTHOR_IDENT", git_author_info }, { "GIT_EDITOR", editor }, { "GIT_PAGER", pager }, + { "GIT_DEFAULT_BRANCH", default_branch }, { "", NULL }, }; |