Subject: Re: [PATCH v2 4/5] reset: suppress '--no-refresh' advice if logging is silenced

From: Junio C Hamano <[email-masked]>
Date: Mon, 14 Mar 2022 19:38:27 +0000

"Victoria Dye via GitGitGadget" <[email-masked]> writes:

> From: Victoria Dye <[email-masked]>
>
> If using '--quiet' or 'reset.quiet=true', do not print the 'resetnoRefresh'
> advice string. For applications that rely on '--quiet' disabling all
> non-error logs, the advice message should be suppressed accordingly.

Funny, but it is true that we would want to squelch advice messages
under 'quiet' mode.

But why did we even spend 2 seconds to refresh the index if --quiet
is given in the first place?  Isn't it because an explicit --refresh
or reset.refresh=yes was in effect?  IOW, the user wanted the
command to be quiet but still wanted it to refresh the index.

So it would be yet another reason why we do not want to show the
message: the user knows what they are doing and explicitly asked
us to spend cycles to refresh.

> Signed-off-by: Victoria Dye <[email-masked]>
> ---
>  builtin/reset.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/builtin/reset.c b/builtin/reset.c
> index feab85e03de..c8a356ec5b0 100644
> --- a/builtin/reset.c
> +++ b/builtin/reset.c
> @@ -535,7 +535,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
>  				refresh_index(&the_index, flags, NULL, NULL,
>  					      _("Unstaged changes after reset:"));
>  				t_delta_in_ms = (getnanotime() - t_begin) / 1000000;
> -				if (advice_enabled(ADVICE_RESET_NO_REFRESH_WARNING) && t_delta_in_ms > REFRESH_INDEX_DELAY_WARNING_IN_MS) {
> +				if (!quiet && advice_enabled(ADVICE_RESET_NO_REFRESH_WARNING) && t_delta_in_ms > REFRESH_INDEX_DELAY_WARNING_IN_MS) {
>  					advise(_("It took %.2f seconds to refresh the index after reset.  You can use\n"
>  						 "'--no-refresh' to avoid this.  Set the config setting reset.refresh to false\n"
>  						 "to make this the default."), t_delta_in_ms / 1000.0);