Skip to content

Commit cfb0f37

Browse files
committed
Merge branch 'es/config-hooks' into seen
The "hooks defined in config" topic. * es/config-hooks: hook: add 'run' subcommand parse-options: parse into argv_array hook: add --porcelain to list command hook: add list command hook: scaffolding for git-hook subcommand doc: propose hooks managed by the config
2 parents 50b124c + c45caa8 commit cfb0f37

File tree

14 files changed

+820
-0
lines changed

14 files changed

+820
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
/git-grep
7676
/git-hash-object
7777
/git-help
78+
/git-hook
7879
/git-http-backend
7980
/git-http-fetch
8081
/git-http-push

Documentation/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ SP_ARTICLES += $(API_DOCS)
8181
TECH_DOCS += MyFirstContribution
8282
TECH_DOCS += MyFirstObjectWalk
8383
TECH_DOCS += SubmittingPatches
84+
TECH_DOCS += technical/config-based-hooks
8485
TECH_DOCS += technical/hash-function-transition
8586
TECH_DOCS += technical/http-protocol
8687
TECH_DOCS += technical/index-format

Documentation/git-hook.txt

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
git-hook(1)
2+
===========
3+
4+
NAME
5+
----
6+
git-hook - Manage configured hooks
7+
8+
SYNOPSIS
9+
--------
10+
[verse]
11+
'git hook' list [--porcelain] <hook-name>
12+
13+
DESCRIPTION
14+
-----------
15+
You can list, add, and modify hooks with this command.
16+
17+
This command parses the default configuration files for sections "hook" and
18+
"hookcmd". "hook" is used to describe the commands which will be run during a
19+
particular hook event; commands are run in config order. "hookcmd" is used to
20+
describe attributes of a specific command. If additional attributes don't need
21+
to be specified, a command to run can be specified directly in the "hook"
22+
section; if a "hookcmd" by that name isn't found, Git will attempt to run the
23+
provided value directly. For example:
24+
25+
Global config
26+
----
27+
[hook "post-commit"]
28+
command = "linter"
29+
command = "~/typocheck.sh"
30+
31+
[hookcmd "linter"]
32+
command = "/bin/linter --c"
33+
----
34+
35+
Local config
36+
----
37+
[hook "prepare-commit-msg"]
38+
command = "linter"
39+
[hook "post-commit"]
40+
command = "python ~/run-test-suite.py"
41+
----
42+
43+
COMMANDS
44+
--------
45+
46+
list [--porcelain] <hook-name>::
47+
48+
List the hooks which have been configured for <hook-name>. Hooks appear
49+
in the order they should be run, and note the config scope where the relevant
50+
`hook.<hook-name>.command` was specified, not the `hookcmd` (if applicable).
51+
+
52+
If `--porcelain` is specified, instead print the commands alone, separated by
53+
newlines, for easy parsing by a script.
54+
55+
OPTIONS
56+
-------
57+
--porcelain::
58+
With `list`, print the commands in the order they should be run,
59+
separated by newlines, for easy parsing by a script.
60+
61+
GIT
62+
---
63+
Part of the linkgit:git[1] suite

Documentation/technical/api-parse-options.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,11 @@ There are some macros to easily define options:
173173
The string argument is stored as an element in `string_list`.
174174
Use of `--no-option` will clear the list of preceding values.
175175

176+
`OPT_STRVEC(short, long, &struct strvec, arg_str, description)`::
177+
Introduce an option with a string argument.
178+
The string argument is stored as an element in `strvec`.
179+
Use of `--no-option` will clear the list of preceding values.
180+
176181
`OPT_INTEGER(short, long, &int_var, description)`::
177182
Introduce an option with integer argument.
178183
The integer is put into `int_var`.

0 commit comments

Comments
 (0)