doc: improve formatting in githooks.txt
Typeset commands and similar things with as `git foo` instead of 'git foo' or 'git-foo' and add linkgit to the commands which run the hooks. Signed-off-by: Andreas Heiduk <asheiduk@gmail.com> Reviewed-by: Martin Ågren <martin.agren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Andreas Heiduk committed
May 3, 2018 at 20:48 UTC
9dba84d81c72fe1275b0d2ed7a7ce2e72b8e9eff
1 file changed
+58
-57
Documentation/githooks.txt
+58
-57
@@ -31,7 +31,7 @@ Hooks can get their arguments via the environment, command-line
31
arguments, and stdin. See the documentation for each hook below for
32
details.
33
34
-'git init' may copy hooks to the new repository, depending on its
34
+`git init` may copy hooks to the new repository, depending on its
35
configuration. See the "TEMPLATE DIRECTORY" section in
36
linkgit:git-init[1] for details. When the rest of this document refers
37
to "default hooks" it's talking about the default template shipped
@@ -45,9 +45,9 @@ HOOKS
45
applypatch-msg
46
~~~~~~~~~~~~~~
47
48
-This hook is invoked by 'git am'. It takes a single
48
+This hook is invoked by linkgit:git-am[1]. It takes a single
49
parameter, the name of the file that holds the proposed commit
50
-log message. Exiting with a non-zero status causes 'git am' to abort
50
+log message. Exiting with a non-zero status causes `git am` to abort
51
before applying the patch.
52
53
The hook is allowed to edit the message file in place, and can
@@ -61,7 +61,7 @@ The default 'applypatch-msg' hook, when enabled, runs the
61
pre-applypatch
62
~~~~~~~~~~~~~~
63
64
-This hook is invoked by 'git am'. It takes no parameter, and is
64
+This hook is invoked by linkgit:git-am[1]. It takes no parameter, and is
65
invoked after the patch is applied, but before a commit is made.
66
67
If it exits with non-zero status, then the working tree will not be
@@ -76,33 +76,33 @@ The default 'pre-applypatch' hook, when enabled, runs the
76
post-applypatch
77
~~~~~~~~~~~~~~~
78
79
-This hook is invoked by 'git am'. It takes no parameter,
79
+This hook is invoked by linkgit:git-am[1]. It takes no parameter,
80
and is invoked after the patch is applied and a commit is made.
81
82
This hook is meant primarily for notification, and cannot affect
83
-the outcome of 'git am'.
83
+the outcome of `git am`.
84
85
pre-commit
86
~~~~~~~~~~
87
88
-This hook is invoked by 'git commit', and can be bypassed
88
+This hook is invoked by linkgit:git-commit[1], and can be bypassed
89
with the `--no-verify` option. It takes no parameters, and is
90
invoked before obtaining the proposed commit log message and
91
making a commit. Exiting with a non-zero status from this script
92
-causes the 'git commit' command to abort before creating a commit.
92
+causes the `git commit` command to abort before creating a commit.
93
94
The default 'pre-commit' hook, when enabled, catches introduction
95
of lines with trailing whitespaces and aborts the commit when
96
such a line is found.
97
98
-All the 'git commit' hooks are invoked with the environment
98
+All the `git commit` hooks are invoked with the environment
99
variable `GIT_EDITOR=:` if the command will not bring up an editor
100
to modify the commit message.
101
102
prepare-commit-msg
103
~~~~~~~~~~~~~~~~~~
104
105
-This hook is invoked by 'git commit' right after preparing the
105
+This hook is invoked by linkgit:git-commit[1] right after preparing the
106
default log message, and before the editor is started.
107
108
It takes one to three parameters. The first is the name of the file
@@ -114,7 +114,7 @@ commit is a merge or a `.git/MERGE_MSG` file exists); `squash`
114
(if a `.git/SQUASH_MSG` file exists); or `commit`, followed by
115
a commit SHA-1 (if a `-c`, `-C` or `--amend` option was given).
116
117
-If the exit status is non-zero, 'git commit' will abort.
117
+If the exit status is non-zero, `git commit` will abort.
118
119
The purpose of the hook is to edit the message file in place, and
120
it is not suppressed by the `--no-verify` option. A non-zero exit
@@ -127,7 +127,7 @@ help message found in the commented portion of the commit template.
127
commit-msg
128
~~~~~~~~~~
129
130
-This hook is invoked by 'git commit' and 'git merge', and can be
130
+This hook is invoked by linkgit:git-commit[1] and linkgit:git-merge[1], and can be
131
bypassed with the `--no-verify` option. It takes a single parameter,
132
the name of the file that holds the proposed commit log message.
133
Exiting with a non-zero status causes the command to abort.
@@ -143,16 +143,16 @@ The default 'commit-msg' hook, when enabled, detects duplicate
143
post-commit
144
~~~~~~~~~~~
145
146
-This hook is invoked by 'git commit'. It takes no parameters, and is
146
+This hook is invoked by linkgit:git-commit[1]. It takes no parameters, and is
147
invoked after a commit is made.
148
149
This hook is meant primarily for notification, and cannot affect
150
-the outcome of 'git commit'.
150
+the outcome of `git commit`.
151
152
pre-rebase
153
~~~~~~~~~~
154
155
-This hook is called by 'git rebase' and can be used to prevent a
155
+This hook is called by linkgit:git-rebase[1] and can be used to prevent a
156
branch from getting rebased. The hook may be called with one or
157
two parameters. The first parameter is the upstream from which
158
the series was forked. The second parameter is the branch being
@@ -161,17 +161,17 @@ rebased, and is not set when rebasing the current branch.
161
post-checkout
162
~~~~~~~~~~~~~
163
164
-This hook is invoked when a 'git checkout' is run after having updated the
164
+This hook is invoked when a linkgit:git-checkout[1] is run after having updated the
165
worktree. The hook is given three parameters: the ref of the previous HEAD,
166
the ref of the new HEAD (which may or may not have changed), and a flag
167
indicating whether the checkout was a branch checkout (changing branches,
168
flag=1) or a file checkout (retrieving a file from the index, flag=0).
169
-This hook cannot affect the outcome of 'git checkout'.
169
+This hook cannot affect the outcome of `git checkout`.
170
171
-It is also run after 'git clone', unless the --no-checkout (-n) option is
171
+It is also run after linkgit:git-clone[1], unless the `--no-checkout` (`-n`) option is
172
used. The first parameter given to the hook is the null-ref, the second the
173
-ref of the new HEAD and the flag is always 1. Likewise for 'git worktree add'
174
-unless --no-checkout is used.
173
+ref of the new HEAD and the flag is always 1. Likewise for `git worktree add`
174
+unless `--no-checkout` is used.
175
176
This hook can be used to perform repository validity checks, auto-display
177
differences from the previous HEAD if different, or set working dir metadata
@@ -180,10 +180,10 @@ properties.
180
post-merge
181
~~~~~~~~~~
182
183
-This hook is invoked by 'git merge', which happens when a 'git pull'
183
+This hook is invoked by linkgit:git-merge[1], which happens when a `git pull`
184
is done on a local repository. The hook takes a single parameter, a status
185
flag specifying whether or not the merge being done was a squash merge.
186
-This hook cannot affect the outcome of 'git merge' and is not executed,
186
+This hook cannot affect the outcome of `git merge` and is not executed,
187
if the merge failed due to conflicts.
188
189
This hook can be used in conjunction with a corresponding pre-commit hook to
@@ -194,10 +194,10 @@ for an example of how to do this.
194
pre-push
195
~~~~~~~~
196
197
-This hook is called by 'git push' and can be used to prevent a push from taking
198
-place. The hook is called with two parameters which provide the name and
199
-location of the destination remote, if a named remote is not being used both
200
-values will be the same.
197
+This hook is called by linkgit:git-push[1] and can be used to prevent
198
+a push from taking place. The hook is called with two parameters
199
+which provide the name and location of the destination remote, if a
200
+named remote is not being used both values will be the same.
201
202
Information about what is to be pushed is provided on the hook's standard
203
input with lines of the form:
@@ -216,7 +216,7 @@ SHA-1>` will be 40 `0`. If the local commit was specified by something other
216
than a name which could be expanded (such as `HEAD~`, or a SHA-1) it will be
217
supplied as it was originally given.
218
219
-If this hook exits with a non-zero status, 'git push' will abort without
219
+If this hook exits with a non-zero status, `git push` will abort without
220
pushing anything. Information about why the push is rejected may be sent
221
to the user by writing to standard error.
222
@@ -224,8 +224,8 @@ to the user by writing to standard error.
224
pre-receive
225
~~~~~~~~~~~
226
227
-This hook is invoked by 'git-receive-pack' when it reacts to
228
-'git push' and updates reference(s) in its repository.
227
+This hook is invoked by linkgit:git-receive-pack[1] when it reacts to
228
+`git push` and updates reference(s) in its repository.
229
Just before starting to update refs on the remote repository, the
230
pre-receive hook is invoked. Its exit status determines the success
231
or failure of the update.
@@ -246,7 +246,7 @@ updated. If the hook exits with zero, updating of individual refs can
246
still be prevented by the <<update,'update'>> hook.
247
248
Both standard output and standard error output are forwarded to
249
-'git send-pack' on the other end, so you can simply `echo` messages
249
+`git send-pack` on the other end, so you can simply `echo` messages
250
for the user.
251
252
The number of push options given on the command line of
@@ -265,8 +265,8 @@ linkgit:git-receive-pack[1] for some caveats.
265
update
266
~~~~~~
267
268
-This hook is invoked by 'git-receive-pack' when it reacts to
269
-'git push' and updates reference(s) in its repository.
268
+This hook is invoked by linkgit:git-receive-pack[1] when it reacts to
269
+`git push` and updates reference(s) in its repository.
270
Just before updating the ref on the remote repository, the update hook
271
is invoked. Its exit status determines the success or failure of
272
the ref update.
@@ -279,7 +279,7 @@ three parameters:
279
- and the new object name to be stored in the ref.
280
281
A zero exit from the update hook allows the ref to be updated.
282
-Exiting with a non-zero status prevents 'git-receive-pack'
282
+Exiting with a non-zero status prevents `git receive-pack`
283
from updating that ref.
284
285
This hook can be used to prevent 'forced' update on certain refs by
@@ -299,7 +299,7 @@ membership. See linkgit:git-shell[1] for how you might use the login
299
shell to restrict the user's access to only git commands.
300
301
Both standard output and standard error output are forwarded to
302
-'git send-pack' on the other end, so you can simply `echo` messages
302
+`git send-pack` on the other end, so you can simply `echo` messages
303
for the user.
304
305
The default 'update' hook, when enabled--and with
@@ -310,8 +310,8 @@ unannotated tags to be pushed.
310
post-receive
311
~~~~~~~~~~~~
312
313
-This hook is invoked by 'git-receive-pack' when it reacts to
314
-'git push' and updates reference(s) in its repository.
313
+This hook is invoked by linkgit:git-receive-pack[1] when it reacts to
314
+`git push` and updates reference(s) in its repository.
315
It executes on the remote repository once after all the refs have
316
been updated.
317
@@ -320,7 +320,7 @@ arguments, but gets the same information as the
320
<<pre-receive,'pre-receive'>>
321
hook does on its standard input.
322
323
-This hook does not affect the outcome of 'git-receive-pack', as it
323
+This hook does not affect the outcome of `git receive-pack`, as it
324
is called after the real work is done.
325
326
This supersedes the <<post-update,'post-update'>> hook in that it gets
@@ -328,7 +328,7 @@ both old and new values of all the refs in addition to their
328
names.
329
330
Both standard output and standard error output are forwarded to
331
-'git send-pack' on the other end, so you can simply `echo` messages
331
+`git send-pack` on the other end, so you can simply `echo` messages
332
for the user.
333
334
The default 'post-receive' hook is empty, but there is
@@ -349,8 +349,8 @@ will be set to zero, `GIT_PUSH_OPTION_COUNT=0`.
349
post-update
350
~~~~~~~~~~~
351
352
-This hook is invoked by 'git-receive-pack' when it reacts to
353
-'git push' and updates reference(s) in its repository.
352
+This hook is invoked by linkgit:git-receive-pack[1] when it reacts to
353
+`git push` and updates reference(s) in its repository.
354
It executes on the remote repository once after all the refs have
355
been updated.
356
@@ -358,7 +358,7 @@ It takes a variable number of parameters, each of which is the
358
name of ref that was actually updated.
359
360
This hook is meant primarily for notification, and cannot affect
361
-the outcome of 'git-receive-pack'.
361
+the outcome of `git receive-pack`.
362
363
The 'post-update' hook can tell what are the heads that were pushed,
364
but it does not know what their original and updated values are,
@@ -368,20 +368,20 @@ updated values of the refs. You might consider it instead if you need
368
them.
369
370
When enabled, the default 'post-update' hook runs
371
-'git update-server-info' to keep the information used by dumb
371
+`git update-server-info` to keep the information used by dumb
372
transports (e.g., HTTP) up to date. If you are publishing
373
a Git repository that is accessible via HTTP, you should
374
probably enable this hook.
375
376
Both standard output and standard error output are forwarded to
377
-'git send-pack' on the other end, so you can simply `echo` messages
377
+`git send-pack` on the other end, so you can simply `echo` messages
378
for the user.
379
380
push-to-checkout
381
~~~~~~~~~~~~~~~~
382
383
-This hook is invoked by 'git-receive-pack' when it reacts to
384
-'git push' and updates reference(s) in its repository, and when
383
+This hook is invoked by linkgit:git-receive-pack[1] when it reacts to
384
+`git push` and updates reference(s) in its repository, and when
385
the push tries to update the branch that is currently checked out
386
and the `receive.denyCurrentBranch` configuration variable is set to
387
`updateInstead`. Such a push by default is refused if the working
@@ -400,8 +400,8 @@ when the tip of the current branch is updated to the new commit, and
400
exit with a zero status.
401
402
For example, the hook can simply run `git read-tree -u -m HEAD "$1"`
403
-in order to emulate 'git fetch' that is run in the reverse direction
404
-with `git push`, as the two-tree form of `read-tree -u -m` is
403
+in order to emulate `git fetch` that is run in the reverse direction
404
+with `git push`, as the two-tree form of `git read-tree -u -m` is
405
essentially the same as `git checkout` that switches branches while
406
keeping the local changes in the working tree that do not interfere
407
with the difference between the branches.
@@ -410,15 +410,16 @@ with the difference between the branches.
410
pre-auto-gc
411
~~~~~~~~~~~
412
413
-This hook is invoked by 'git gc --auto'. It takes no parameter, and
414
-exiting with non-zero status from this script causes the 'git gc --auto'
415
-to abort.
413
+This hook is invoked by `git gc --auto` (see linkgit:git-gc[1]). It
414
+takes no parameter, and exiting with non-zero status from this script
415
+causes the `git gc --auto` to abort.
416
417
post-rewrite
418
~~~~~~~~~~~~
419
420
-This hook is invoked by commands that rewrite commits (`git commit
421
---amend`, 'git-rebase'; currently 'git-filter-branch' does 'not' call
420
+This hook is invoked by commands that rewrite commits
421
+(linkgit:git-commit[1] when called with `--amend` and
422
+linkgit:git-rebase[1]; currently `git filter-branch` does 'not' call
423
it!). Its first argument denotes the command it was invoked by:
424
currently one of `amend` or `rebase`. Further command-dependent
425
arguments may be passed in the future.
@@ -450,16 +451,16 @@ processed by rebase.
451
sendemail-validate
452
~~~~~~~~~~~~~~~~~~
453
453
-This hook is invoked by 'git send-email'. It takes a single parameter,
454
+This hook is invoked by linkgit:git-send-email[1]. It takes a single parameter,
455
the name of the file that holds the e-mail to be sent. Exiting with a
455
-non-zero status causes 'git send-email' to abort before sending any
456
+non-zero status causes `git send-email` to abort before sending any
457
e-mails.
458
459
fsmonitor-watchman
460
~~~~~~~~~~~~~~~~~~
461
461
-This hook is invoked when the configuration option core.fsmonitor is
462
-set to .git/hooks/fsmonitor-watchman. It takes two arguments, a version
462
+This hook is invoked when the configuration option `core.fsmonitor` is
463
+set to `.git/hooks/fsmonitor-watchman`. It takes two arguments, a version
464
(currently 1) and the time in elapsed nanoseconds since midnight,
465
January 1, 1970.
466
@@ -478,7 +479,7 @@ directories are checked for untracked files based on the path names
479
given.
480
481
An optimized way to tell git "all files have changed" is to return
481
-the filename '/'.
482
+the filename `/`.
483
484
The exit status determines whether git will use the data from the
485
hook to limit its search. On error, it will fall back to verifying