aboutsummaryrefslogtreecommitdiff
path: root/Documentation
diff options
context:
space:
mode:
Diffstat (limited to 'Documentation')
-rw-r--r--Documentation/config/hook.adoc30
-rw-r--r--Documentation/git-hook.adoc27
2 files changed, 35 insertions, 22 deletions
diff --git a/Documentation/config/hook.adoc b/Documentation/config/hook.adoc
index 64e845a260..9e78f26439 100644
--- a/Documentation/config/hook.adoc
+++ b/Documentation/config/hook.adoc
@@ -1,23 +1,23 @@
-hook.<name>.command::
- The command to execute for `hook.<name>`. `<name>` is a unique
- "friendly" name that identifies this hook. (The hook events that
- trigger the command are configured with `hook.<name>.event`.) The
- value can be an executable path or a shell oneliner. If more than
- one value is specified for the same `<name>`, only the last value
- parsed is used. See linkgit:git-hook[1].
+hook.<friendly-name>.command::
+ The command to execute for `hook.<friendly-name>`. `<friendly-name>`
+ is a unique name that identifies this hook. The hook events that
+ trigger the command are configured with `hook.<friendly-name>.event`.
+ The value can be an executable path or a shell oneliner. If more than
+ one value is specified for the same `<friendly-name>`, only the last
+ value parsed is used. See linkgit:git-hook[1].
-hook.<name>.event::
- The hook events that trigger `hook.<name>`. The value is the name
- of a hook event, like "pre-commit" or "update". (See
+hook.<friendly-name>.event::
+ The hook events that trigger `hook.<friendly-name>`. The value is the
+ name of a hook event, like "pre-commit" or "update". (See
linkgit:githooks[5] for a complete list of hook events.) On the
- specified event, the associated `hook.<name>.command` is executed.
- This is a multi-valued key. To run `hook.<name>` on multiple
+ specified event, the associated `hook.<friendly-name>.command` is executed.
+ This is a multi-valued key. To run `hook.<friendly-name>` on multiple
events, specify the key more than once. An empty value resets
the list of events, clearing any previously defined events for
- `hook.<name>`. See linkgit:git-hook[1].
+ `hook.<friendly-name>`. See linkgit:git-hook[1].
-hook.<name>.enabled::
- Whether the hook `hook.<name>` is enabled. Defaults to `true`.
+hook.<friendly-name>.enabled::
+ Whether the hook `hook.<friendly-name>` is enabled. Defaults to `true`.
Set to `false` to disable the hook without removing its
configuration. This is particularly useful when a hook is defined
in a system or global config file and needs to be disabled for a
diff --git a/Documentation/git-hook.adoc b/Documentation/git-hook.adoc
index 12d2701b52..318c637bd8 100644
--- a/Documentation/git-hook.adoc
+++ b/Documentation/git-hook.adoc
@@ -8,8 +8,8 @@ git-hook - Run git hooks
SYNOPSIS
--------
[verse]
-'git hook' run [--ignore-missing] [--to-stdin=<path>] <hook-name> [-- <hook-args>]
-'git hook' list [-z] <hook-name>
+'git hook' run [--allow-unknown-hook-name] [--ignore-missing] [--to-stdin=<path>] <hook-name> [-- <hook-args>]
+'git hook' list [--allow-unknown-hook-name] [-z] [--show-scope] <hook-name>
DESCRIPTION
-----------
@@ -44,7 +44,7 @@ event`), and then `~/bin/spellchecker` will have a chance to check your commit
message (during the `commit-msg` hook event).
Commands are run in the order Git encounters their associated
-`hook.<name>.event` configs during the configuration parse (see
+`hook.<friendly-name>.event` configs during the configuration parse (see
linkgit:git-config[1]). Although multiple `hook.linter.event` configs can be
added, only one `hook.linter.command` event is valid - Git uses "last-one-wins"
to determine which command to run.
@@ -76,10 +76,10 @@ first start `~/bin/linter --cpp20` and second start `~/bin/leak-detector`. It
would evaluate the output of each when deciding whether to proceed with the
commit.
-For a full list of hook events which you can set your `hook.<name>.event` to,
+For a full list of hook events which you can set your `hook.<friendly-name>.event` to,
and how hooks are invoked during those events, see linkgit:githooks[5].
-Git will ignore any `hook.<name>.event` that specifies an event it doesn't
+Git will ignore any `hook.<friendly-name>.event` that specifies an event it doesn't
recognize. This is intended so that tools which wrap Git can use the hook
infrastructure to run their own hooks; see "WRAPPERS" for more guidance.
@@ -113,7 +113,7 @@ Any positional arguments to the hook should be passed after a
mandatory `--` (or `--end-of-options`, see linkgit:gitcli[7]). See
linkgit:githooks[5] for arguments hooks might expect (if any).
-list [-z]::
+list [-z] [--show-scope]::
Print a list of hooks which will be run on `<hook-name>` event. If no
hooks are configured for that event, print a warning and return 1.
Use `-z` to terminate output lines with NUL instead of newlines.
@@ -121,6 +121,13 @@ list [-z]::
OPTIONS
-------
+--allow-unknown-hook-name::
+ By default `git hook run` and `git hook list` will bail out when
+ `<hook-name>` is not a hook event known to Git (see linkgit:githooks[5]
+ for the list of known hooks). This is meant to help catch typos
+ such as `prereceive` when `pre-receive` was intended. Pass this
+ flag to allow unknown hook names.
+
--to-stdin::
For "run"; specify a file which will be streamed into the
hook's stdin. The hook will receive the entire file from
@@ -134,6 +141,12 @@ OPTIONS
-z::
Terminate "list" output lines with NUL instead of newlines.
+--show-scope::
+ For "list"; prefix each configured hook's friendly name with a
+ tab-separated config scope (e.g. `local`, `global`, `system`),
+ mirroring the output style of `git config --show-scope`. Traditional
+ hooks from the hookdir are unaffected.
+
WRAPPERS
--------
@@ -153,7 +166,7 @@ Then, in your 'mywrapper' tool, you can invoke any users' configured hooks by
running:
----
-git hook run mywrapper-start-tests \
+git hook run --allow-unknown-hook-name mywrapper-start-tests \
# providing something to stdin
--stdin some-tempfile-123 \
# execute hooks in serial