All of lore.kernel.org
 help / color / mirror / Atom feed
From: Patrick Steinhardt <ps@pks.im>
To: Karthik Nayak <karthik.188@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] hook: introduce the report hook for git-receive-pack(1)
Date: Wed, 19 Aug 2026 15:20:03 +0200	[thread overview]
Message-ID: <aoWtgz8wWsb3v6du@pks.im> (raw)
In-Reply-To: <CAOLa=ZTtOJLXkfZ8jKpuA9REg5CP_xxD8+kDxPAYLeRz_xR1Wg@mail.gmail.com>

On Wed, Aug 19, 2026 at 03:13:50PM +0200, Karthik Nayak wrote:
> Patrick Steinhardt <ps@pks.im> writes:
> 
> > On Tue, Aug 18, 2026 at 09:55:55AM +0200, Karthik Nayak wrote:
> >> When running 'git-receive-pack(1)', there is currently no way for the
> >> server to intercept and modify the status report before it is sent back
> >> to the client. This is useful for servers with custom logic that need
> >> to transform or gate the report based on the outcome of external logic
> >> post reference updates.
> >>
> >> Introduce a new 'report' hook which receives the pkt-line encoded
> >> status report on stdin and whose stdout replaces the report sent to the
> >> client. A non-zero exit status causes `receive-pack` to die and the
> >> client to treat the push as failed.
> >
> > I think it would have been useful to add context why none of the
> > preexisting hooks work for us:
> >
> >   - The pre-receive hook runs too early, as we haven't updated
> >     references at that point yet and we need to have the full view of
> >     all resulting updates (both objects and references).
> >
> >   - The update hook is too inefficient as it runs once per reference,
> >     and we cannot trivially determine the last update.
> >
> >   - The reference-transaction hook cannot be used by us because we care
> >     about the phase where it was committed already. And while the hook
> >     fires in that phase, it does not allow the caller to modify the
> >     result in any capacity.
> >
> >   - The post-receive and post-update hooks cannot be used as they run
> >     too late, at the point where we have already reported success to the
> >     client.
> >
> 
> Yeah, this is worthwhile mentioning, I already have made the commit
> message a lot more descriptive, so it does become bloated. I think it is
> justified though, since more information is always more useful than less.

Well. Until it isn't anymore :) Just look at the walls of text that AI
is prone to generate, where one is essentially drowning in information.
And it's the worst kind of information, too: plausibly looking but
inherently dubious.

Anyway, I digress. I think in this context it's good to have the context
indeed, and I trust your information more than the one generated by AI.

> >> diff --git a/Documentation/githooks.adoc b/Documentation/githooks.adoc
> >> index ed045940d1..7e6643ad89 100644
> >> --- a/Documentation/githooks.adoc
> >> +++ b/Documentation/githooks.adoc
> >> @@ -527,6 +527,29 @@ The exit status of the hook is ignored for any state except for the
> >> To reject individual ref updates, rewrite the corresponding
> >> +`ok` lines to `ng` lines in the output report (with an explanatory
> >> +error string) and exit zero; standard error can accompany this to
> >> +provide a human-readable explanation. A non-zero exit status causes
> >> +`receive-pack` to die.
> >
> > We should probably document that we expect the hook to never return
> > non-zero, even if it rejects reference updates, and that doing so
> > indicates a bug. This is mostly because git-receive-pack(1) shouldn't
> > ever just die on the client without giving it a proper status.
> >
> 
> Yeah, this is a part I was thinking about but wasn't sure if it should
> be added in because, we could also do an implementation where we simply
> ignore the exit code of the hook.

There could be cases where just making the whole operation explode is
the only remaining option. So I don't think it's necessarily bad to have
it as the nuclear option.

Patrick

  reply	other threads:[~2026-08-19 13:20 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-18  7:55 [PATCH] hook: introduce the report hook for git-receive-pack(1) Karthik Nayak
2026-08-18 20:54 ` Junio C Hamano
2026-08-19  7:03 ` Kristoffer Haugsbakk
2026-08-19 12:11   ` Karthik Nayak
2026-08-19 14:47     ` Kristoffer Haugsbakk
2026-08-19  7:39 ` Patrick Steinhardt
2026-08-19 13:13   ` Karthik Nayak
2026-08-19 13:20     ` Patrick Steinhardt [this message]
2026-08-19 13:24       ` Karthik Nayak
2026-08-20  9:50 ` Phillip Wood
2026-08-20 15:43   ` Junio C Hamano
2026-08-21 12:51   ` Karthik Nayak
2026-08-21 13:34 ` [PATCH v2] " Karthik Nayak
2026-08-21 13:49   ` Patrick Steinhardt
2026-08-21 16:08     ` Karthik Nayak
2026-08-21 16:55     ` Junio C Hamano

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=aoWtgz8wWsb3v6du@pks.im \
    --to=ps@pks.im \
    --cc=git@vger.kernel.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.