Expand description
Every real-Git start of the wrapper carries core.hooksPath pointing at a directory that never exists.
What:
Start the real Git with every hook switched off.
Why:
The wrapper supports no external hook program: not a traditional hook (an executable file in
<git-common-dir>/hooks or a core.hooksPath directory; git lfs writes its four shims there again whenever it
cleans a file) and not a hook defined in the configuration (hook.<name>.event with hook.<name>.command).
Every real-Git start of the wrapper therefore carries -c core.hooksPath=<a directory that never exists>, which
finds no hook file, and -c hook.<event>.enabled=false for every hook event Git knows, which switches every
configured hook off whatever its name.
They follow every global option of the caller and precede the subcommand, so no -c or --config-env of the caller
can switch a hook or the hooks path back on.
The options are part of the argument vector, so they add no system call and no process start.
The wrapper injects no hook of its own, so pre-push is switched off like every other event.
In TS you’d write (pseudocode):
spawn(realGit, ['-c', `core.hooksPath=${NO_HOOKS_DIRECTORY}`, ...HOOK_EVENTS.flatMap((e) => ['-c', `hook.${e}.enabled=false`]), ...args]);Constants§
- HOOK_
EVENTS - Every hook event of Git 2.56.0 (
githooks(5)), server-side events included. A configured hook for an event missing here would run, so the controlevery_listed_event_is_a_hook_event_of_real_gitasks the host Git whether each name is one. - NO_
HOOKS_ DIRECTORY - The
core.hooksPathvalue of every start: below/dev/null, which is a device, so nothing can create it.
Functions§
- activate
- What: Switch the hooks-off option on for every real-Git start this process makes from now on. Why: The executable’s entry calls it first, so no production start misses it. The library’s unit controls, which fake Git with scripts that record the exact arguments they receive, leave it off, and the binary-level controls prove the option on the built executable.
- add_
arguments - What:
Add
argumentsto a real-Git command, with the hooks-off options once the process has switched them on. Why: One function serves both builders of real-Git commands, so no start can miss the options. - hooks_
off_ arguments - What:
The arguments a real-Git start gets, with the hooks-off options in front of the subcommand.
Why:
The options follow every global option of the caller (
-c,--config-env,--git-dir), so a caller cannot switch a hook event or the hooks path back on, and they precede the subcommand, so they apply to it. A configuration query gets none, because it must report what the repository configures, and a start that names no subcommand (--version, a help query) has no global options to follow, so it gets them first. - switched_
off_ events - The events a real-Git start of the wrapper switches off: every hook event Git knows.