Expand description
The hook dispatcher entered by a transaction’s hook entry name, under the hook lock.
What:
The hook dispatcher: a native entry started by a preparation hook name inside a transaction’s
hooks directory, which runs the repository’s hooks for that event under the hook lock.
Why:
Git starts the entry through core.hooksPath; the start name selects the event.
The incumbent’s dispatch.mjs (src/hook-dispatch/hook-dispatch-program.ts) does the same work,
and both take the hook lock at <common>/cli-git/hook.lock, so they serialize on one lock.
Any other start name, including post-commit or a hook name outside a transaction, behaves as git.
In TS you’d write (pseudocode):
await dispatch(event, process.argv.slice(2));Structs§
- Dispatch
Target - What: One recognized dispatch: the event the entry is named after and its transaction’s hooks directory. Why: The dispatcher needs both, and the start name is the only proof that Git started this entry.
Functions§
- dispatch_
environment - What:
The environment the dispatched Git sees: the caller’s variables with the plan’s three overrides.
Why:
The incumbent’s dispatcher restores
GIT_CONFIG_PARAMETERS(or removes it), exports the worktree root and the preparation lease; nothing else changes. - dispatch_
target_ for_ start_ name - What:
Recognize a start name inside a transaction’s
hooksdirectory beside aplan.json. Why: The incumbent’s dispatcher runs from<transaction>/hooks; recognizing any other name would turn ordinary Git invocations into dispatches. The name is read lexically, and the file system is touched only after every name matches. - run_
executable - What: Dispatch when the start name names a transaction’s entry, otherwise run the wrapper. Why: The executable calls this with its own start name first; every other start name, and an absent one, reaches the ordinary path unchanged.
- run_
hook_ dispatch - What:
Run the real Git hook runner for one event under the plan’s lock, and return its status.
Why:
The incumbent’s
dispatch: a disabled event exits 0 untouched, the lock is taken unless the plan skips it, Git runshook run --ignore-missing <event>with the repository’s hooks path, a signal or a failure to report a status is exit 1, and the lock is released afterwards.