git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 7/7] docs: document multiple hooks

From
brian m. carlson <sandals@crustytoothpaste.net>
Date
May 14, 2019, 00:23 UTC
Message-ID
<20190514002332.121089-9-sandals@crustytoothpaste.net>
In-Reply-To
<20190514002332.121089-1-sandals@crustytoothpaste.net>

Document the semantics and behavior of multiple hooks, including the configuration options and requirements for them to be run.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
 Documentation/config.txt      |  2 ++
 Documentation/config/hook.txt | 19 +++++++++++++++++++
 Documentation/githooks.txt    |  9 +++++++++
 3 files changed, 30 insertions(+)
 create mode 100644 Documentation/config/hook.txt
diff --git a/Documentation/config.txt b/Documentation/config.txt
index d87846faa6..f62b8ce494 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -350,6 +350,8 @@ include::config/guitool.txt[]
 
 include::config/help.txt[]
 
+include::config/hook.txt[]
+
 include::config/http.txt[]
 
 include::config/i18n.txt[]
diff --git a/Documentation/config/hook.txt b/Documentation/config/hook.txt
new file mode 100644
index 0000000000..4585cc7f55
--- /dev/null
+++ b/Documentation/config/hook.txt
@@ -0,0 +1,19 @@
+hook.<name>.errorBehavior::
+  Control the error behavior when using multiple hooks.
++
+--
+* `stop-on-first` - If a hook fails, do not execute further hooks, even if the
+  command normally ignores whether hooks succeed or fail, and return its exit
+  code as the exit code of the hook set. If all hooks succeed, the exit code is 0.
+  This is the default.
+* `report-any-error` - Always execute all hooks, but return the exit code of the
+  first failing hook as the exit code of the hook set. If all hooks succeed, the
+  exit code of the hook set is 0.
+* `report-any-success` - Always execute all hooks, and if any hook succeeds,
+  return 0 as the exit code of the hook set. If all hooks fail, the exit code of
+  the hook set is 1.
+--
++
+If the exit code of the hook set is zero, then the hooks are considered to have
+succeeded; otherwise, they are considered to have failed. Note that the success
+or failure of some hooks is ignored (see linkgit:githooks[5] for more).
diff --git a/Documentation/githooks.txt b/Documentation/githooks.txt
index 786e778ab8..c680e575b3 100644
--- a/Documentation/githooks.txt
+++ b/Documentation/githooks.txt
@@ -31,6 +31,15 @@ Hooks can get their arguments via the environment, command-line
 arguments, and stdin. See the documentation for each hook below for
 details.
 
+It is possible to provide multiple hooks for a single function. If the
+main hook file is absent, hooks are additionally looked for in a
+directory with the name of the main hook file with a `.d` appended.
+(That is, if `post-receive` is missing, `post-receive.d` is inspected
+for any hooks that might be present.) Each of these hooks is executed in order,
+sorted by file name. By default, if a hook fails, additional hooks are not
+executed, but this can be controlled with the `hook.*.errorBehavior` setting
+(see linkgit:git-config[1]).
+
 `git init` may copy hooks to the new repository, depending on its
 configuration. See the "TEMPLATE DIRECTORY" section in
 linkgit:git-init[1] for details. When the rest of this document refers
Previous: Jeff KingNext: Duy Nguyen
Message 26 of 34 in “Multiple hook support”
  1. 0/7 Multiple hook supportbrian m. carlson, May 14, 2019
  2. 1/7 run-command: add preliminary support for multiple hooksbrian m. carlson, May 14, 2019
  3. Duy NguyenMay 14, 2019
  4. brian m. carlsonMay 15, 2019
  5. brian m. carlsonMay 29, 2019
  6. Johannes SchindelinMay 14, 2019
  7. brian m. carlsonMay 15, 2019
  8. Johannes SixtMay 16, 2019
  9. Johannes SchindelinMay 17, 2019
  10. 2/7 builtin/receive-pack: add support for multiple hooksbrian m. carlson, May 14, 2019
  11. 3/7 rebase: add support for multiple hooksbrian m. carlson, May 14, 2019
  12. Duy NguyenMay 14, 2019
  13. Johannes SixtMay 14, 2019
  14. brian m. carlsonMay 15, 2019
  15. Duy NguyenMay 16, 2019
  16. 3/7 sequencer: add support for multiple hooksbrian m. carlson, May 14, 2019
  17. 4/7 builtin/worktree: add support for multiple post-checkout hooksbrian m. carlson, May 14, 2019
  18. 5/7 transport: add support for multiple pre-push hooksbrian m. carlson, May 14, 2019
  19. 6/7 config: allow configuration of multiple hook error behaviorbrian m. carlson, May 14, 2019
  20. Duy NguyenMay 14, 2019
  21. brian m. carlsonMay 15, 2019
  22. Jeff KingMay 16, 2019
  23. Jeff KingMay 16, 2019
  24. brian m. carlsonMay 16, 2019
  25. Jeff KingMay 16, 2019
  26. 7/7 docs: document multiple hooksbrian m. carlson, May 14, 2019
  27. Duy NguyenMay 14, 2019
  28. Jonathan NiederMay 14, 2019
  29. brian m. carlsonMay 14, 2019
  30. Jonathan NiederMay 14, 2019
  31. brian m. carlsonMay 16, 2019
  32. Jonathan NiederMay 16, 2019
  33. Jeff KingMay 16, 2019
  34. Duy NguyenMay 14, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.