Expand description
The dispatch plan of one commit transaction, its JSON spelling and the config reads it makes.
What:
The dispatch plan of one commit transaction:
which hooks run, how they run, and under which lock.
Why:
Inside native git commit the hook entries see only the transaction’s overrides,
so the plan is computed by the wrapper from the real repository and the caller’s environment.
The incumbent (src/hook-dispatch/hook-dispatch-plan.ts) and both dispatchers read the same
plan.json, so its field order and spelling are part of the on-disk format.
In TS you’d write (pseudocode):
const plan: HookDispatchPlan = await computeHookDispatchPlan({ gitPath, cwd, globalArgs, commonDir, ... });Structs§
- Hook
Dispatch Plan - What:
The plan written to
<transaction>/hooks/plan.json. Why: Both dispatchers and the lease validator read this one record, so every field keeps the incumbent’s name and meaning. - Hook
Plan Inputs - What: The inputs of one plan computation. Why: Named fields keep the many inputs apart; the context carries the caller’s global options as its global prefix, so every config read sees them.
Enums§
- Config
Parameters - What:
The value the dispatcher restores as
GIT_CONFIG_PARAMETERS, or its absence. Why: Git reads the variable as text; an absent variable must stay absent in hooks. - Hook
Plan Error - What: Why planning or encoding a plan failed. Why: The caller stops the commit with the message; a plan is never partially written.
Constants§
- CONFIG_
PARAMETERS_ VARIABLE - Environment variable that carries Git’s config parameters into hooks.
- PLAN_
FILENAME - Name of the plan inside a transaction’s
hooksdirectory. - PLAN_
LIMIT - Largest plan a dispatcher reads.
- PLAN_
SCHEMA_ VERSION - Plan schema version written and required on read.
- PREPARATION_
HOOK_ EVENTS - Events the shim dispatches during preparation;
post-commitruns once after landing instead. - SILENCED_
HOOK_ EVENTS - Every commit event the transaction silences inside native
git commit. - WORK_
TREE_ VARIABLE - Environment variable naming the worktree root for hooks.
Functions§
- combine_
config_ parameters - What:
Join the inherited parameters and the quoted global
-cvalues. Why: Git hands hooks the inherited entries first, then the command-line options; no entry means the variable is absent. - compute_
hook_ dispatch_ plan - What:
Compute the dispatch plan of one transaction from the real repository.
Why:
The incumbent’s
computeHookDispatchPlan: the hooks path, the event switches (only the exact valuefalsedisables an event), the combined config parameters, the lock path and whether the lock is skipped. - default_
hooks_ directory - What:
The hooks directory Git uses when
core.hooksPathis unset. Why: The incumbent’sjoin(commonDir, 'hooks'). - encode_
hook_ dispatch_ plan - What:
Spell a plan as
JSON.stringifywrites it, without the trailing newline. Why: The incumbent writesJSON.stringify(plan)followed by one newline, and both dispatchers and the lease validator read the same bytes. - global_
config_ overrides - What:
Collect the value of every global
-coption, in order. Why: The incumbent pairs each-cwith the token after it, even when that token is itself-c. A non-UTF-8 value cannot be recorded, so it is refused. - hook_
lock_ directory - What:
The hook lock directory under the common Git directory.
Why:
The incumbent’s
join(commonDir, 'cli-git', 'hook.lock'); the same lock serializes both wrappers. - inherited_
config_ parameters - What:
Read the caller’s inherited
GIT_CONFIG_PARAMETERS, last entry winning. Why: An empty value counts as none, as the incumbent’s?? ''and the joining rule do. - new_
preparation_ lease - What:
A fresh preparation lease for one transaction directory.
Why:
The incumbent’s
formatPreparationLease({ directory, token })with an unguessable token. - normalized_
path - What:
Normalize a path lexically, the way Node’s
path.joinandpath.resolvedo. Why: Recorded paths must match the incumbent’s spelling byte for byte, andPathBuf::joinkeeps.and... - parse_
hook_ dispatch_ plan - What: Read a plan from its JSON text, refusing any other shape. Why: The dispatcher and the lease validator must agree on what a plan is; an unknown event or schema makes the plan unusable.
- quote_
config_ parameter - What:
Quote one
key=valueentry for Git’sGIT_CONFIG_PARAMETERS. Why: Git’ssq_quote_bufcloses the quote around'and!; the parser accepts that form in every supported version. - resolve_
hooks_ path - What:
The hooks directory a configured
core.hooksPathnames. Why: A relative value resolves against the worktree root, where Git runs hooks; absolute values stay absolute.