Re: [PATCH v2] hook: introduce the report hook for git-receive-pack(1)
- From
Patrick Steinhardt <ps@pks.im>
- Date
- Aug 24, 2026, 05:32 UTC
- Message-ID
- <aovXcPHCiBPxlLXo@pks.im>
- In-Reply-To
- <CAOLa=ZTkW14coLA4st-m6B6P-9pUr+Yzh7Ph6nb0ohXJSbTk4A@mail.gmail.com>
On Fri, Aug 21, 2026 at 09:08:12AM -0700, Karthik Nayak wrote:
> Patrick Steinhardt <ps@pks.im> writes: > > On Fri, Aug 21, 2026 at 03:34:58PM +0200, Karthik Nayak wrote:
[snip]
Show 31 quoted lines
> >> +repository, but before the pkt-line encoded status report is sent back > >> +to the client. > >> + > >> +The hook receives the complete pkt-line encoded status report on > >> +standard input. The report begins with an `unpack` line indicating > >> +whether the object transfer succeeded (`unpack ok` or > >> +`unpack <error>`), followed by one `ok <refname>` or > >> +`ng <refname> <reason>` line per ref that was pushed, and is > >> +terminated by a flush packet. > >> + > >> +The hook's standard output entirely replaces the report that is sent > >> +to the client. The hook must write a valid pkt-line encoded report in > >> +the same format it received. The hook's stdout is fully buffered by > >> +`receive-pack` before any data is sent to the client, so the hook's > >> +exit status is known before the client receives anything. > >> + > >> +There are two distinct ways the hook can affect the push outcome: > >> + > >> +* To reject individual ref updates while keeping `receive-pack` alive, > >> + rewrite the corresponding `ok <refname>` lines to > >> + `ng <refname> <reason>` lines in the output and exit with status 0. > > > > It's `ng <refname>[ <reason>]`, right? I think the reason itself is > > optional. We might also want to clarify whether there should be a > > trailing newline or not. > > > > You're right, since 'send-pack' will default to 'failed' if there is no > reason. > > We do say 'terminated by a flush packed'.
We only send the flush packet once donce with all refs though, right? I was wondering about each individual reference line: are they supposed to end with a newline or not?
Patrick