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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Junio

On 01/10/2021 22:08, Junio C Hamano wrote:
"Phillip Wood via GitGitGadget" <gitgitgadget@xxxxxxxxx> writes:

From: Phillip Wood <phillip.wood@xxxxxxxxxxxxx>

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.

That would be a change for the good, but it is not what this patch does.
If oid == &head_oid then it means that the caller did not give us a tree to checkout so HEAD will not change unless we are switching branches. Using a pointer comparison rather than calling oidcmp() was a deliberate choice to avoid any user visible changes as there are no callers that try to run the checkout-hook without passing an oid or branch. The aim here is to avoid having to pass default_reflog when it is not needed without making any user visible changes.

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

I'm not sure what we could test

Best Wishes

Phillip

Thanks.





[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux