From: Patrick Steinhardt <ps@pks.im>
To: Junio C Hamano <gitster@pobox.com>
Cc: Karthik Nayak <karthik.188@gmail.com>, git@vger.kernel.org
Subject: Re: [PATCH] refs: don't invoke reference-transaction hook for reflogs
Date: Fri, 15 Nov 2024 08:01:09 +0100 [thread overview]
Message-ID: <ZzbxrU2SdUDqPJiF@pks.im> (raw)
In-Reply-To: <xmqqldxl5qdf.fsf@gitster.g>
On Fri, Nov 15, 2024 at 08:48:12AM +0900, Junio C Hamano wrote:
> Karthik Nayak <karthik.188@gmail.com> writes:
>
> > The reference-transaction hook is invoked whenever there is a reference
> > update being performed. For each state of the transaction, we iterate
> > over the updates present and pass this information to the hook.
> >
> > The `ref_update` structure is used to hold these updates within a
> > `transaction`. We use the same structure for holding reflog updates too.
> > Which means that the reference transaction hook is also obtaining
> > information about a reflog update. This is a bug, since:
>
> Yeah, the transaction hook is deciding how the values of refs should
> (or should not) change, and its decisions should be sufficient to
> determine what should happen to corresponding reflog updates. If an
> update to the 'main' branch is let through, that update should result
> in a new reflog record for that branch. If such an update is blocked,
> there is no update to the branch, and a reflog record would not be
> created for such an update that did not happen.
>
> One thing that the above argument does not capture is "stash",
> especially "stash drop". The way the subsystem abuses reflog
> disconnects ref updates from reflog updates, so there _is_ a use
> case for hooks to interfere with reflog updates.
>
> However, the existing ref update transaction hook does not have to
> be the mechanism to vet "git stash" operation. If we really needed
> to, we could add reflog transaction hook for that later, outside the
> scope of this fix.
Indeed, I'm also happy to declare this a bug and change the behaviour
retroactively to skip over reflogs. I highly doubt that anybody uses
this in a sensible way to handle reflog updates: they have no way to
distinguish a ref update from a reflog update, so they would have to
essentially guess what is what.
So this patch looks good to me, thanks!
Patrick
prev parent reply other threads:[~2024-11-15 7:01 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-14 9:58 [PATCH] refs: don't invoke reference-transaction hook for reflogs Karthik Nayak
2024-11-14 23:48 ` Junio C Hamano
2024-11-15 7:01 ` Patrick Steinhardt [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZzbxrU2SdUDqPJiF@pks.im \
--to=ps@pks.im \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=karthik.188@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox