Re: [PATCH v2] hook: introduce the report hook for git-receive-pack(1)
From: Patrick Steinhardt <hidden>
Date: 2026-08-24 05:32:44
On Fri, Aug 21, 2026 at 09:08:12AM -0700, Karthik Nayak wrote:
Patrick Steinhardt [off-list ref] writes:quoted
On Fri, Aug 21, 2026 at 03:34:58PM +0200, Karthik Nayak wrote:
[snip]
quoted
quoted
+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