Skip to content

Commit be927d5

Browse files
jiangxingitster
authored andcommitted
doc: add documentation for the proc-receive hook
Add documentation for the new "proc-receive" hook. Signed-off-by: Jiang Xin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent aa05409 commit be927d5

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

Documentation/githooks.txt

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,64 @@ The default 'update' hook, when enabled--and with
333333
`hooks.allowunannotated` config option unset or set to false--prevents
334334
unannotated tags to be pushed.
335335

336+
proc-receive
337+
~~~~~~~~~~~~
338+
339+
This hook is invoked by linkgit:git-receive-pack[1]. If the server has
340+
set the multi-valued config variable `receive.procReceiveRefs`, and the
341+
commands sent to 'receive-pack' have matching reference names, these
342+
commands will be executed by this hook, instead of by the internal
343+
`execute_commands()` function. This hook is responsible for updating
344+
the relevant references and reporting the results back to 'receive-pack'.
345+
346+
This hook executes once for the receive operation. It takes no
347+
arguments, but uses a pkt-line format protocol to communicate with
348+
'receive-pack' to read commands, push-options and send results. In the
349+
following example for the protocol, the letter 'S' stands for
350+
'receive-pack' and the letter 'H' stands for this hook.
351+
352+
# Version and features negotiation.
353+
S: PKT-LINE(version=1\0push-options atomic...)
354+
S: flush-pkt
355+
H: PKT-LINE(version=1\0push-options...)
356+
H: flush-pkt
357+
358+
# Send commands from server to the hook.
359+
S: PKT-LINE(<old-oid> <new-oid> <ref>)
360+
S: ... ...
361+
S: flush-pkt
362+
# Send push-options only if the 'push-options' feature is enabled.
363+
S: PKT-LINE(push-option)
364+
S: ... ...
365+
S: flush-pkt
366+
367+
# Receive result from the hook.
368+
# OK, run this command successfully.
369+
H: PKT-LINE(<old-oid> <new-oid> <ref> ok)
370+
# NO, I reject it.
371+
H: PKT-LINE(<old-oid> <new-oid> <ref> ng <reason>)
372+
# Fall through, let 'receive-pack' to execute it.
373+
H: PKT-LINE(<old-oid> <new-oid> <ref> ft)
374+
# OK, but has an alternate reference. The alternate reference name
375+
# and other status are given in key=value pairs after the null
376+
# character.
377+
H: PKT-LINE(<old-oid> <new-oid> <ref> ok\0ref=refs/pull/123/head
378+
forced-update)
379+
H: ... ...
380+
H: flush-pkt
381+
382+
Each command for the 'proc-receive' hook may point to a pseudo-reference
383+
and always has a zero-old as its old-oid, while the 'proc-receive' hook
384+
may update an alternate reference and the alternate reference may exist
385+
already with a non-zero old-oid. For this case, this hook may return
386+
different OID and different reference name as extended status of the
387+
report line.
388+
389+
The report of the commands of this hook should have the same order as
390+
the input. The exit status of the 'proc-receive' hook only determines
391+
the success or failure of the group of commands sent to it, unless
392+
atomic push is in use.
393+
336394
[[post-receive]]
337395
post-receive
338396
~~~~~~~~~~~~

0 commit comments

Comments
 (0)