interplane.Get Omega
Read in your language

git

[Ported from github.com/git/git] Sync with Git 2.56.1

Brought by drakestapleton

branch master Branches Tags History

git / Documentation / config / hook.adoc

108 lines · 5183 bytes Raw Blame History
1ifdef::git-hook[]
2:see-git-hook:
3endif::git-hook[]
4ifndef::git-hook[]
5:see-git-hook: See linkgit:git-hook[1].
6endif::git-hook[]
7
8hook.<friendly-name>.command::
9 The command to execute for `hook.<friendly-name>`. `<friendly-name>`
10 is a unique name that identifies this hook. The hook events that
11 trigger the command are configured with `hook.<friendly-name>.event`.
12 The value can be an executable path or a shell oneliner. If more than
13 one value is specified for the same `<friendly-name>`, only the last
14 value parsed is used. {see-git-hook}
15
16hook.<friendly-name>.event::
17 The hook events that trigger `hook.<friendly-name>`. The value is the
18 name of a hook event, like "pre-commit" or "update". (See
19 linkgit:githooks[5] for a complete list of hook events.) On the
20 specified event, the associated `hook.<friendly-name>.command` is executed.
21 This is a multi-valued key. To run `hook.<friendly-name>` on multiple
22 events, specify the key more than once. An empty value resets
23 the list of events, clearing any previously defined events for
24 `hook.<friendly-name>`. {see-git-hook}
25+
26The `<friendly-name>` must not be the same as a known hook event name
27(e.g. do not use `hook.pre-commit.event`). Using a known event name as
28a friendly-name is a fatal error because it creates an ambiguity with
29`hook.<event>.enabled` and `hook.<event>.jobs`. For unknown event names,
30a warning is issued when `<friendly-name>` matches the event value.
31
32hook.<friendly-name>.enabled::
33 Whether the hook `hook.<friendly-name>` is enabled. Defaults to `true`.
34 Set to `false` to disable the hook without removing its
35 configuration. This is particularly useful when a hook is defined
36 in a system or global config file and needs to be disabled for a
37 specific repository. {see-git-hook}
38
39hook.<friendly-name>.parallel::
40 Whether the hook `hook.<friendly-name>` may run in parallel with other hooks
41 for the same event. Defaults to `false`. Set to `true` only when the
42 hook script is safe to run concurrently with other hooks for the same
43 event. If any hook for an event does not have this set to `true`,
44 all hooks for that event run sequentially regardless of `hook.jobs`.
45 Only configured (named) hooks need to declare this. Traditional hooks
46 found in the hooks directory do not need to, and run in parallel when
47 the effective job count is greater than 1. {see-git-hook}
48
49hook.<event>.enabled::
50 Switch to enable or disable all hooks for the `<event>` hook event,
51 configured hooks and the traditional hook in the hooks directory alike.
52 When set to `false`, no hooks fire for that event, regardless of any
53 per-hook `hook.<friendly-name>.enabled` settings. Defaults to `true`.
54 {see-git-hook}
55+
56Note on naming: `<event>` must be the event name (e.g. `pre-commit`),
57not a hook friendly-name. Since using a known event name as a
58friendly-name is disallowed (see `hook.<friendly-name>.event` above),
59there is no ambiguity between event-level and per-hook `.enabled`
60settings for known events. For unknown events, if a friendly-name
61matches the event name despite the warning, `.enabled` is treated
62as per-hook only.
63
64hook.<event>.jobs::
65 Specifies how many hooks can be run simultaneously for the `<event>`
66 hook event (e.g. `hook.post-receive.jobs = 4`). Overrides `hook.jobs`
67 for this specific event. The same parallelism restrictions apply: this
68 setting has no effect unless all configured hooks for the event have
69 `hook.<friendly-name>.parallel` set to `true`. Set to `-1` to use the
70 number of available CPU cores. Must be a positive integer or `-1`;
71 zero is rejected with a warning. {see-git-hook}
72+
73Note on naming: although this key resembles `hook.<friendly-name>.*`
74(a per-hook setting), `<event>` must be the event name, not a hook
75friendly name. The key component is stored literally and looked up by
76event name at runtime with no translation between the two namespaces.
77A key like `hook.my-hook.jobs` is stored under `"my-hook"` but the
78lookup at runtime uses the event name (e.g. `"post-receive"`), so
79`hook.my-hook.jobs` is silently ignored even when `my-hook` is
80registered for that event. Use `hook.post-receive.jobs` or any other
81valid event name when setting `hook.<event>.jobs`.
82
83hook.jobs::
84 Specifies how many hooks can be run simultaneously during parallelized
85 hook execution. If unspecified, defaults to 1 (serial execution).
86 Set to `-1` to use the number of available CPU cores.
87 Can be overridden on a per-event basis with `hook.<event>.jobs`.
88 Some hooks always run sequentially regardless of this setting because
89 they operate on shared data and cannot safely be parallelized:
90+
91--
92`applypatch-msg`;;
93`prepare-commit-msg`;;
94`commit-msg`;;
95 Receive a commit message file and may rewrite it in place.
96`pre-commit`;;
97`post-checkout`;;
98`push-to-checkout`;;
99`post-commit`;;
100 Access the working tree, index, or repository state.
101--
102+
103This setting has no effect unless all configured hooks for the event have
104`hook.<friendly-name>.parallel` set to `true`.
105+
106For `pre-push` hooks, which normally keep stdout and stderr separate,
107setting this to a value greater than 1 (or passing `-j`) will merge stdout
108into stderr to allow correct de-interleaving of parallel output.