From: Vsevolod Myalitsin <ub4nal@mail.ru>
To: git@vger.kernel.org
Cc: Vsevolod Myalitsin <ub4nal@mail.ru>
Subject: [PATCH v2] advice: use global config for default branch name
Date: Wed, 9 Sep 2026 00:14:44 +0300 [thread overview]
Message-ID: <20260908211445.37516-1-ub4nal@mail.ru> (raw)
The advice for configuring the default branch name
suggests disabling it with "git config set
advice.defaultBranchName false". This setting is
useless because it neither affects the current
repository nor newly created repositories.
Suggest using "git config set --global" instead.
To implement this, add a "global_hint" field to the
advice_setting struct and explicitly set it to true
for defaultBranchName to indicate that the advice
should recommend a global configuration. This field
can also be used for other advice settings if needed.
Signed-off-by: Vsevolod Myalitsin <ub4nal@mail.ru>
---
advice.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/advice.c b/advice.c
index 63bf8b0c5f..c3955eeebe 100644
--- a/advice.c
+++ b/advice.c
@@ -42,6 +42,7 @@ enum advice_level {
static struct {
const char *key;
+ bool global_hint;
enum advice_level level;
} advice_setting[] = {
[ADVICE_ADD_EMBEDDED_REPO] = { "addEmbeddedRepo" },
@@ -51,7 +52,7 @@ static struct {
[ADVICE_AM_WORK_DIR] = { "amWorkDir" },
[ADVICE_CHECKOUT_AMBIGUOUS_REMOTE_BRANCH_NAME] = { "checkoutAmbiguousRemoteBranchName" },
[ADVICE_COMMIT_BEFORE_MERGE] = { "commitBeforeMerge" },
- [ADVICE_DEFAULT_BRANCH_NAME] = { "defaultBranchName" },
+ [ADVICE_DEFAULT_BRANCH_NAME] = { "defaultBranchName", true },
[ADVICE_DETACHED_HEAD] = { "detachedHead" },
[ADVICE_DIVERGING] = { "diverging" },
[ADVICE_FETCH_SET_HEAD_WARN] = { "fetchRemoteHEADWarn" },
@@ -96,10 +97,10 @@ static struct {
static const char turn_off_instructions[] =
N_("\n"
- "Disable this message with \"git config set advice.%s false\"");
+ "Disable this message with \"git config set%s advice.%s false\"");
static void vadvise(const char *advice, int display_instructions,
- const char *key, va_list params)
+ const char *key, bool global_hint, va_list params)
{
struct strbuf buf = STRBUF_INIT;
const char *cp, *np;
@@ -107,7 +108,8 @@ static void vadvise(const char *advice, int display_instructions,
strbuf_vaddf(&buf, advice, params);
if (display_instructions)
- strbuf_addf(&buf, turn_off_instructions, key);
+ strbuf_addf(&buf, turn_off_instructions, global_hint ?
+ " --global" : "", key);
for (cp = buf.buf; *cp; cp = np) {
np = strchrnul(cp, '\n');
@@ -126,7 +128,7 @@ void advise(const char *advice, ...)
{
va_list params;
va_start(params, advice);
- vadvise(advice, 0, "", params);
+ vadvise(advice, 0, "", false, params);
va_end(params);
}
@@ -156,7 +158,7 @@ void advise_if_enabled(enum advice_type type, const char *advice, ...)
va_start(params, advice);
vadvise(advice, !advice_setting[type].level, advice_setting[type].key,
- params);
+ advice_setting[type].global_hint, params);
va_end(params);
}
--
2.50.1
reply other threads:[~2026-09-08 17:25 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20260908211445.37516-1-ub4nal@mail.ru \
--to=ub4nal@mail.ru \
--cc=git@vger.kernel.org \
/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