* [PATCH v2] advice: use global config for default branch name
@ 2026-09-08 21:14 Vsevolod Myalitsin
0 siblings, 0 replies; only message in thread
From: Vsevolod Myalitsin @ 2026-09-08 21:14 UTC (permalink / raw)
To: git; +Cc: Vsevolod Myalitsin
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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-09-08 17:25 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-08 21:14 [PATCH v2] advice: use global config for default branch name Vsevolod Myalitsin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox