summaryrefslogtreecommitdiff
path: root/refs.c
diff options
context:
space:
mode:
authorLibravatar Jiang Xin <worldhello.net@gmail.com>2020-12-21 07:10:19 +0800
committerLibravatar Jiang Xin <worldhello.net@gmail.com>2020-12-21 07:10:19 +0800
commit3104153d5ea3bd0e68166e02ec847a895f9a76e6 (patch)
tree8b65383c203c550fab3f6ffea51cd474168ac34b /refs.c
parentl10n: Update Catalan translation (diff)
parentGit 2.30-rc1 (diff)
downloadtgif-3104153d5ea3bd0e68166e02ec847a895f9a76e6.tar.xz
Merge remote-tracking branch 'github/master' into git-po-master
* github/master: (42 commits) Git 2.30-rc1 git-gui: use gray background for inactive text widgets Another batch before 2.30-rc1 git-gui: Fix selected text colors Makefile: conditionally include GIT-VERSION-FILE git-gui: fix colored label backgrounds when using themed widgets config.mak.uname: remove old NonStop compatibility settings diff: correct interaction between --exit-code and -I<pattern> t/perf: fix test_export() failure with BSD `sed` style: do not "break" in switch() after "return" compat-util: pretend that stub setitimer() always succeeds strmap: make callers of strmap_remove() to call it in void context doc: mention Python 3.x supports index-format.txt: document v2 format of file system monitor extension docs: multi-pack-index: remove note about future 'verify' work init: provide useful advice about init.defaultBranch get_default_branch_name(): prepare for showing some advice branch -m: allow renaming a yet-unborn branch init: document `init.defaultBranch` better t7900: use --fixed-value in git-maintenance tests ...
Diffstat (limited to 'refs.c')
-rw-r--r--refs.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/refs.c b/refs.c
index 392f0bbf68..13dc2c3291 100644
--- a/refs.c
+++ b/refs.c
@@ -562,7 +562,20 @@ void expand_ref_prefix(struct strvec *prefixes, const char *prefix)
strvec_pushf(prefixes, *p, len, prefix);
}
-char *repo_default_branch_name(struct repository *r)
+static const char default_branch_name_advice[] = N_(
+"Using '%s' as the name for the initial branch. This default branch name\n"
+"is subject to change. To configure the initial branch name to use in all\n"
+"of your new repositories, which will suppress this warning, call:\n"
+"\n"
+"\tgit config --global init.defaultBranch <name>\n"
+"\n"
+"Names commonly chosen instead of 'master' are 'main', 'trunk' and\n"
+"'development'. The just-created branch can be renamed via this command:\n"
+"\n"
+"\tgit branch -m <name>\n"
+);
+
+char *repo_default_branch_name(struct repository *r, int quiet)
{
const char *config_key = "init.defaultbranch";
const char *config_display_key = "init.defaultBranch";
@@ -574,8 +587,11 @@ char *repo_default_branch_name(struct repository *r)
else if (repo_config_get_string(r, config_key, &ret) < 0)
die(_("could not retrieve `%s`"), config_display_key);
- if (!ret)
+ if (!ret) {
ret = xstrdup("master");
+ if (!quiet)
+ advise(_(default_branch_name_advice), ret);
+ }
full_ref = xstrfmt("refs/heads/%s", ret);
if (check_refname_format(full_ref, 0))
@@ -585,12 +601,12 @@ char *repo_default_branch_name(struct repository *r)
return ret;
}
-const char *git_default_branch_name(void)
+const char *git_default_branch_name(int quiet)
{
static char *ret;
if (!ret)
- ret = repo_default_branch_name(the_repository);
+ ret = repo_default_branch_name(the_repository, quiet);
return ret;
}