summaryrefslogtreecommitdiff
path: root/content/forge/internals/hookc.md
blob: 3c270fcd21e99659642ef65c3084ea126ac97215 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40

---
title: hookc
---

`hookc` is a helper binary for Git server-side hooks that relays the hook's
context to a persistent daemon via a UNIX domain socket and communicates back
any relevant responses.

It is intended to be invoked by `git-receive-pack` for hooks such as
`pre-receive`, `update`, and `post-receive`.

## Environment variables

- `LINDENII_FORGE_HOOKS_SOCKET_PATH`:
  Absolute path to the UNIX domain socket on which the daemon is listening.
- `LINDENII_FORGE_HOOKS_COOKIE`:
  64-character authentication cookie used to validate the hook client to the
  daemon.

## Operation

lindenii-forge-hookc collects the following information and sends it to
the daemon:

- All command-line arguments
- All `GIT_*` environment variables
- The raw hook stdin (e.g., old/new ref triplets for pre-receive)

After sending this data, it waits for a one-byte status code from the daemon,
which becomes `hookc`'s own exit status.

If the daemon sends any output afterward, it is forwarded to standard error and
will appear as `remote:` output to the user.

## Known issues

- The status byte from the daemon currently must be sent before any
  stderr output.
- Currently assumes stdin and stderr are pipes, which is not guaranteed
  in future versions of Git.