Subject: Re: [PATCH 06/11] reset_head(): make default_reflog_action optional

From: Junio C Hamano <[email-masked]>
Date: Fri, 01 Oct 2021 14:08:29 -0700

"Phillip Wood via GitGitGadget" <[email-masked]> writes:

> From: Phillip Wood <[email-masked]>
>
> This parameter is only needed when a ref is going to be updated and
> the caller does not pass an explicit reflog message. Callers that are
> just discarding changes in the working tree like create_autostash() do
> not update any refs so should not have to worry about passing this
> parameter.

This only talks about internal implementation details of passing a
parameter that may not be used, but ...

> -	ret = update_refs(oid, switch_to_branch, reflog_head, reflog_orig_head,
> -			  default_reflog_action, flags);
> +	if (oid != &head_oid || update_orig_head || switch_to_branch)
> +		ret = update_refs(oid, switch_to_branch, reflog_head,
> +				  reflog_orig_head, default_reflog_action,
> +				  flags);

... doesn't this have a more significant behaviour change?

I am not sure if comparison between oid and head_oid can safely
cheat like the patch does, or if it is necessary to do a proper oid
comparison, but either way, this would stop calling update_refs(),
which in turn means it would have an externally visible effect, like
a hook no longer getting called, doesn't it?

It would be a change for the good---calling post-checkout hook when
you did "git checkout (no other arguments)" feels wasteful, but it
deserves to be told to end users, I would think.

Again, a new test to protect the change would go well in the same
patch.

Thanks.