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

Re: [PATCH v2 1/1] advice: add --no-advice global option

From
James Liu <james@jamesliu.io>
Date
Apr 29, 2024, 05:01 UTC
Message-ID
<D0WCCOLSMM9K.24BIGLR6EEJI8@jamesliu.io>
In-Reply-To
<37512328b1f3db4e8075bdb4beeb8929@manjaro.org>
Thanks for the feedback Dragan!
Show 8 quoted lines
> After having a more detailed look at the Git documentation,
> I think that adding support for "--advice" at the same time
> would be the right thing to do.  That option would override
> all "advice.<hint>" options that may exist in the configuration
> (and would override the GIT_NO_ADVICE environment variable,
> if we end up supporting it), similarly to how "--paginate"
> overrides all "pager.<cmd>" in the configuration, which would
> be both consistent and rather useful in some situations.

I think this makes sense from a UX consistenty perspective, but I'm not sure if we should increase the scope of this patch. It's also much easier to re-enable previously silenced advice hints, so I'm unsure whether an --advice option makes sense. We can also avoid the decision of what to do if the user supplies --advice and --no-advice simultaneously if we only have one option.

Show 31 quoted lines
> > diff --git a/advice.c b/advice.c
> > index 75111191ad..f6282c3bde 100644
> > --- a/advice.c
> > +++ b/advice.c
> > @@ -2,6 +2,7 @@
> >  #include "advice.h"
> >  #include "config.h"
> >  #include "color.h"
> > +#include "environment.h"
> >  #include "gettext.h"
> >  #include "help.h"
> >  #include "string-list.h"
> > @@ -126,7 +127,12 @@ void advise(const char *advice, ...)
> > 
> >  int advice_enabled(enum advice_type type)
> >  {
> > -	int enabled = advice_setting[type].level != ADVICE_LEVEL_DISABLED;
> > +	int enabled;
> > +
> > +	if (getenv(GIT_NO_ADVICE))
> > +		return 0;
>
> Huh, I was under impression that having an environment
> variable to control this behavior was frowned upon by
> Junio? [1]  To me, supporting such a variable would be
> a somewhat acceptable risk, [2] but of course it's the
> maintainer's opinion that matters most.
>
> [1] https://lore.kernel.org/git/xmqqfrva3k9j.fsf@gitster.g/
> [2] 
> https://lore.kernel.org/git/462de4ec1fb1896fa7f26b3515deca57@manjaro.org/

You're correct. I saw this pattern for a few of the other global CLI options and followed it. I'm unsure what the best alternative for passing this configuration down to the `advice_enabled()` function is. I'd appreciate some guidance here.

Cheers, James

Previous: Dragan SimicNext: Dragan Simic
Message 21 of 67 in “advice: add "all" option to disable all hints”
  1. 0/2 advice: add "all" option to disable all hintsJames Liu, Apr 24, 2024
  2. 1/2 advice: allow advice type to be provided in testsJames Liu, Apr 24, 2024
  3. Patrick SteinhardtApr 24, 2024
  4. 2/2 advice: add "all" option to disable all hintsJames Liu, Apr 24, 2024
  5. Patrick SteinhardtApr 24, 2024
  6. Junio C HamanoApr 24, 2024
  7. Patrick SteinhardtApr 24, 2024
  8. Phillip WoodApr 24, 2024
  9. Patrick SteinhardtApr 24, 2024
  10. Junio C HamanoApr 24, 2024
  11. Patrick SteinhardtApr 25, 2024
  12. Junio C HamanoApr 25, 2024
  13. Dragan SimicApr 24, 2024
  14. Dragan SimicApr 24, 2024
  15. Junio C HamanoApr 24, 2024
  16. Patrick SteinhardtApr 25, 2024
  17. Dragan SimicApr 24, 2024
  18. 0/1 advice: add --no-advice global optionJames Liu, Apr 29, 2024
  19. 1/1 advice: add --no-advice global optionJames Liu, Apr 29, 2024
  20. Dragan SimicApr 29, 2024
  21. James LiuApr 29, 2024
  22. Dragan SimicApr 29, 2024
  23. Dragan SimicApr 29, 2024
  24. Eric SunshineApr 29, 2024
  25. Dragan SimicApr 29, 2024
  26. Jeff KingApr 29, 2024
  27. Dragan SimicApr 29, 2024
  28. Junio C HamanoApr 29, 2024
  29. James LiuApr 30, 2024
  30. Junio C HamanoApr 29, 2024
  31. Rubén JustoApr 29, 2024
  32. Dragan SimicApr 29, 2024
  33. 0/1 advice: add --no-advice global optionJames Liu, Apr 30, 2024
  34. 1/1 advice: add --no-advice global optionJames Liu, Apr 30, 2024
  35. Patrick SteinhardtApr 30, 2024
  36. Dragan SimicApr 30, 2024
  37. Junio C HamanoApr 30, 2024
  38. 0/3 advice: add "all" option to disable all hintsJames Liu, May 3, 2024
  39. 1/3 doc: clean up usage documentation for --no-* optsJames Liu, May 3, 2024
  40. Junio C HamanoMay 3, 2024
  41. James LiuMay 6, 2024
  42. 2/3 doc: add spacing around paginate optionsJames Liu, May 3, 2024
  43. Karthik NayakMay 3, 2024
  44. Junio C HamanoMay 3, 2024
  45. 3/3 advice: add --no-advice global optionJames Liu, May 3, 2024
  46. 4/3 t0018: two small fixesJunio C Hamano, May 8, 2024
  47. Dragan SimicMay 3, 2024
  48. Re* [PATCH v4 0/3] advice: add "all" option to disable all hintsJunio C Hamano, May 3, 2024
  49. Eric SunshineMay 3, 2024
  50. Junio C HamanoMay 3, 2024
  51. Junio C HamanoMay 3, 2024
  52. Eric SunshineMay 3, 2024
  53. Johannes SchindelinMay 5, 2024
  54. Re* Re* [PATCH v4 0/3] advice: add "all" option to disable all hintsJunio C Hamano, May 6, 2024
  55. Dragan SimicMay 7, 2024
  56. Junio C HamanoMay 7, 2024
  57. Dragan SimicMay 7, 2024
  58. Dragan SimicMay 7, 2024
  59. Karthik NayakMay 3, 2024
  60. James LiuMay 5, 2024
  61. Junio C HamanoMay 3, 2024
  62. James LiuMay 5, 2024
  63. James LiuMay 6, 2024
  64. Junio C HamanoMay 6, 2024
  65. James LiuMay 6, 2024
  66. Karthik NayakMay 7, 2024
  67. Junio C HamanoMay 6, 2024

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.