Re: [PATCH 06/11] reset_head(): make default_reflog_action optional
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Oct 1, 2021, 21:08 UTC
- Message-ID
- <xmqqczoo5u7m.fsf@gitster.g>
- In-Reply-To
- <4503defe5912aecc4e6a50ac82a31aa7b230456b.1633082702.git.gitgitgadget@gmail.com>
"Phillip Wood via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 7 quoted lines
> From: Phillip Wood <phillip.wood@dunelm.org.uk> > > 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 ...
Show 6 quoted lines
> - 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.