All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Vsevolod Myalitsin <ub4nal@mail.ru>
Cc: ben.knoble@gmail.com,  git@vger.kernel.org
Subject: Re: [PATCH] advice: use global config for default branch name
Date: Tue, 08 Sep 2026 09:31:20 -0700	[thread overview]
Message-ID: <xmqqik4fyaav.fsf@gitster.g> (raw)
In-Reply-To: <20260908185653.34702-1-ub4nal@mail.ru> (Vsevolod Myalitsin's message of "Tue, 8 Sep 2026 21:56:52 +0300")

Vsevolod Myalitsin <ub4nal@mail.ru> writes:

> I considered using an "is_global(key)" helper, but I think adding
> a field to "advice_setting" is cleaner.
>
> The change is quite small:
>
>  struct advice_setting {
>      const char *key;
> +    int global_hint;
>      enum advice_level level;
>  };

Should it only about "global vs local"?  I am wondering if we ever
want to suggest "system".  In any case, these three things are
called "scope" in "git config --help", so perhaps rename the new
member to "config_scope" or "scope_hint" or something?

> Then the scope is specified directly for the relevant advice:
>
> 	-[ADVICE_DEFAULT_BRANCH_NAME] = { "defaultBranchName" },
> 	+[ADVICE_DEFAULT_BRANCH_NAME] = { "defaultBranchName", 1 },
>
> And used when building the hint:
>
> 	 static void vadvise(const char *advice, int display_instructions,
> 	-                    const char *key, va_list params)
> 	+                    const char *key, int global, va_list params)

Have you considered going in the other direction to narrow the
interface instead of widening?  Instead of passing .level and .key
separately from the caller to this function, I wonder if it makes
it more future-proof to pass &advice_setting[type].  A call in
advise_if_enabled() then would become

	vadvise(advice, &advice_settings[type], params);

and vadvise() is the only thing that needs to know what members are
in the advice_setting struct and how they affect the output.

> 	 {
> 	     ...
>  
> 	     if (display_instructions)
> 	-        strbuf_addf(&buf, turn_off_instructions, key);
> 	+        strbuf_addf(&buf, turn_off_instructions,
> 	+                    global ? "--global" : "", key);
> 	 }
>
> This keeps the information about the intended config scope in "advice_setting", rather than making "vadvise()" depend on specific advice keys.

  parent reply	other threads:[~2026-09-08 16:31 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-07 12:56 [PATCH] advice: use global config for default branch name Vsevolod Myalitsin
2026-09-08 13:35 ` Ben Knoble
2026-09-08 18:56   ` Vsevolod Myalitsin
2026-09-08 14:59     ` Ben Knoble
2026-09-08 19:56       ` R4NC
2026-09-08 16:24         ` D. Ben Knoble
2026-09-08 16:31     ` Junio C Hamano [this message]
2026-09-08 21:38       ` Vsevolod Myalitsin
2026-09-08 18:57         ` Junio C Hamano
2026-09-09  6:49           ` R4NC
2026-09-09 15:54           ` Jeff King
2026-09-09 18:51             ` Junio C Hamano
2026-09-09 19:51               ` Jeff King
2026-09-10  4:23                 ` Junio C Hamano
2026-09-10  4:33                   ` Jeff King
2026-09-10 12:18                     ` Junio C Hamano
2026-09-10 16:31                       ` Jeff King
2026-09-10  4:28                 ` Junio C Hamano
2027-08-29  0:59               ` Vsevolod Myalitsin

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=xmqqik4fyaav.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=ben.knoble@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=ub4nal@mail.ru \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.