On Mon, Apr 29, 2024 at 11:09:25AM +1000, James Liu wrote: > 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; > + > + enabled = advice_setting[type].level != ADVICE_LEVEL_DISABLED; > All hints are set to a default visibility value: "none", which means implicitly enabled. Maybe we can get this "no-advice" knob by making this default value configurable: diff --git a/advice.c b/advice.c index 75111191ad..bc67b99ba7 100644 --- a/advice.c +++ b/advice.c @@ -39,6 +39,8 @@ enum advice_level { ADVICE_LEVEL_ENABLED, }; +static enum advice_level advice_default_level; + static struct { const char *key; enum advice_level level; @@ -126,7 +128,19 @@ void advise(const char *advice, ...) int advice_enabled(enum advice_type type) { - int enabled = advice_setting[type].level != ADVICE_LEVEL_DISABLED; + static int once = 0; + int enabled; + + if (!once++) { + const char* level = getenv("GIT_ADVICE_LEVEL"); + + if (level && !strcmp(level, "disable")) + advice_default_level = ADVICE_LEVEL_DISABLED; + } + + enabled = (advice_setting[type].level + ? advice_setting[type].level + : advice_default_level) != ADVICE_LEVEL_DISABLED; if (type == ADVICE_PUSH_UPDATE_REJECTED) return enabled &&