Skip to main content

Module hook_dispatch_plan

Module hook_dispatch_plan 

Source
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§

HookDispatchPlan
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.
HookPlanInputs
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§

ConfigParameters
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.
HookPlanError
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 hooks directory.
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-commit runs 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 -c values. 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 value false disables 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.hooksPath is unset. Why: The incumbent’s join(commonDir, 'hooks').
encode_hook_dispatch_plan
What: Spell a plan as JSON.stringify writes it, without the trailing newline. Why: The incumbent writes JSON.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 -c option, in order. Why: The incumbent pairs each -c with 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.join and path.resolve do. Why: Recorded paths must match the incumbent’s spelling byte for byte, and PathBuf::join keeps . 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=value entry for Git’s GIT_CONFIG_PARAMETERS. Why: Git’s sq_quote_buf closes the quote around ' and !; the parser accepts that form in every supported version.
resolve_hooks_path
What: The hooks directory a configured core.hooksPath names. Why: A relative value resolves against the worktree root, where Git runs hooks; absolute values stay absolute.