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

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

From
Jeff King <peff@peff.net>
Date
Sep 9, 2026, 19:51 UTC
Message-ID
<20260909195132.GA182066@coredump.intra.peff.net>
In-Reply-To
<xmqqv78eqmw8.fsf@gitster.g>
On Wed, Sep 09, 2026 at 11:51:03AM -0700, Junio C Hamano wrote:
Show 11 quoted lines
> > will. So there are many missed opportunities for offering the turn-off
> > instructions. Nobody seems to have complained, which makes me wonder if
> > the turn-off instructions would be annoyingly chatty if we printed them
> > all the time. Most of those calls predate the addition if the turn-off
> > instructions and advise_if_enabled(), which was added in 2020. I wonder
> > how people would feel if we converted them all and started printing the
> > turn-off instructions everywhere.
> 
> Depends on how we do so, I guess.  Do you mean we should rewrite
> advise() call above to advice_if_enabled(), even though the check
> for ADVICE_FOO token appear redundant?
I mean we could mechanically rewrite:
  if (advice_enabled(ADVICE_FOO))
	advise(...);
to:
  advise_if_enabled(ADVICE_FOO, ...);

So the check wouldn't be redundant, but rather folded into the helper function. The code becomes shorter, and the user-visible behavior changes to produce the extra "turn-off" message.

Show 18 quoted lines
> > Anyway, UI philosophizing aside, another obvious pattern for advise()
> > is:
> >
> >   if (advice_is_enabled(ADVICE_FOO)) {
> > 	/* do lots of work */
> > 	advise("try %s", results_of_work);
> >   }
> 
> Yes, checking with is-enabled primarily for the purpose of skipping
> "do lots of work" is a very typical use.  I do not know why you
> assume ...
> 
> >
> > which _wouldn't_ want to convert to advise_if_enabled().
> 
> ... this "try X" is something the users would not want to learn how
> to disable, but assuming it is not, the existing code above as-is
> should be what we want.

I meant only that they would not want the same mechanical conversion above, because that would lose the ability to avoid the extra work.

Show 11 quoted lines
> > I guess the caller could just do:
> >
> >   advise_if_enabled(ADVICE_FOO, ...);
> >
> > inside the block. We know that it's enabled, but it's not like the check
> > is expensive.
> 
> Yes, I think we already have some callers that do so, in a pattern
> where they want to skip the "do lots of work" part.  Or at least I
> think I suggested the pattern in the past for somebody who wanted to
> do that.
I think we do the same thing with trace_want() in a few spots.
-Peff
Previous: Junio C HamanoNext: Junio C Hamano
Message 13 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.