git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] advice: use global config for default branch name

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 8, 2026, 16:31 UTC
Message-ID
<xmqqik4fyaav.fsf@gitster.g>
In-Reply-To
<20260908185653.34702-1-ub4nal@mail.ru>
Vsevolod Myalitsin <ub4nal@mail.ru> writes:
Show 10 quoted lines
> 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?

Show 10 quoted lines
> 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.

Show 10 quoted lines
> 	 {
> 	     ...
>  
> 	     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.
Previous: D. Ben KnobleNext: Vsevolod Myalitsin
Message 7 of 19 in “advice: use global config for default branch name”
  1. advice: use global config for default branch nameVsevolod Myalitsin, Sep 7, 2026
  2. Ben KnobleSep 8, 2026
  3. advice: use global config for default branch nameVsevolod Myalitsin, Sep 8, 2026
  4. Ben KnobleSep 8, 2026
  5. R4NCSep 8, 2026
  6. D. Ben KnobleSep 8, 2026
  7. Junio C HamanoSep 8, 2026
  8. advice: use global config for default branch nameVsevolod Myalitsin, Sep 8, 2026
  9. Junio C HamanoSep 8, 2026
  10. R4NCSep 9, 2026
  11. Jeff KingSep 9, 2026
  12. Junio C HamanoSep 9, 2026
  13. Jeff KingSep 9, 2026
  14. Junio C HamanoSep 10, 2026
  15. Jeff KingSep 10, 2026
  16. Junio C HamanoSep 10, 2026
  17. Jeff KingSep 10, 2026
  18. Junio C HamanoSep 10, 2026
  19. Vsevolod MyalitsinAug 29, 2027

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.