Skip to content

Commit 9dba84d

Browse files
asheidukgitster
authored andcommitted
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 <[email protected]> Reviewed-by: Martin Ågren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 468165c commit 9dba84d

File tree

1 file changed

+58
-57
lines changed

1 file changed

+58
-57
lines changed

Documentation/githooks.txt

Lines changed: 58 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Hooks can get their arguments via the environment, command-line
3131
arguments, and stdin. See the documentation for each hook below for
3232
details.
3333

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
3535
configuration. See the "TEMPLATE DIRECTORY" section in
3636
linkgit:git-init[1] for details. When the rest of this document refers
3737
to "default hooks" it's talking about the default template shipped
@@ -45,9 +45,9 @@ HOOKS
4545
applypatch-msg
4646
~~~~~~~~~~~~~~
4747

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
4949
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
5151
before applying the patch.
5252

5353
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
6161
pre-applypatch
6262
~~~~~~~~~~~~~~
6363

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
6565
invoked after the patch is applied, but before a commit is made.
6666

6767
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
7676
post-applypatch
7777
~~~~~~~~~~~~~~~
7878

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,
8080
and is invoked after the patch is applied and a commit is made.
8181

8282
This hook is meant primarily for notification, and cannot affect
83-
the outcome of 'git am'.
83+
the outcome of `git am`.
8484

8585
pre-commit
8686
~~~~~~~~~~
8787

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
8989
with the `--no-verify` option. It takes no parameters, and is
9090
invoked before obtaining the proposed commit log message and
9191
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.
9393

9494
The default 'pre-commit' hook, when enabled, catches introduction
9595
of lines with trailing whitespaces and aborts the commit when
9696
such a line is found.
9797

98-
All the 'git commit' hooks are invoked with the environment
98+
All the `git commit` hooks are invoked with the environment
9999
variable `GIT_EDITOR=:` if the command will not bring up an editor
100100
to modify the commit message.
101101

102102
prepare-commit-msg
103103
~~~~~~~~~~~~~~~~~~
104104

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
106106
default log message, and before the editor is started.
107107

108108
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`
114114
(if a `.git/SQUASH_MSG` file exists); or `commit`, followed by
115115
a commit SHA-1 (if a `-c`, `-C` or `--amend` option was given).
116116

117-
If the exit status is non-zero, 'git commit' will abort.
117+
If the exit status is non-zero, `git commit` will abort.
118118

119119
The purpose of the hook is to edit the message file in place, and
120120
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.
127127
commit-msg
128128
~~~~~~~~~~
129129

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
131131
bypassed with the `--no-verify` option. It takes a single parameter,
132132
the name of the file that holds the proposed commit log message.
133133
Exiting with a non-zero status causes the command to abort.
@@ -143,16 +143,16 @@ The default 'commit-msg' hook, when enabled, detects duplicate
143143
post-commit
144144
~~~~~~~~~~~
145145

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
147147
invoked after a commit is made.
148148

149149
This hook is meant primarily for notification, and cannot affect
150-
the outcome of 'git commit'.
150+
the outcome of `git commit`.
151151

152152
pre-rebase
153153
~~~~~~~~~~
154154

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
156156
branch from getting rebased. The hook may be called with one or
157157
two parameters. The first parameter is the upstream from which
158158
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.
161161
post-checkout
162162
~~~~~~~~~~~~~
163163

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
165165
worktree. The hook is given three parameters: the ref of the previous HEAD,
166166
the ref of the new HEAD (which may or may not have changed), and a flag
167167
indicating whether the checkout was a branch checkout (changing branches,
168168
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`.
170170

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
172172
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.
175175

176176
This hook can be used to perform repository validity checks, auto-display
177177
differences from the previous HEAD if different, or set working dir metadata
@@ -180,10 +180,10 @@ properties.
180180
post-merge
181181
~~~~~~~~~~
182182

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`
184184
is done on a local repository. The hook takes a single parameter, a status
185185
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,
187187
if the merge failed due to conflicts.
188188

189189
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.
194194
pre-push
195195
~~~~~~~~
196196

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.
201201

202202
Information about what is to be pushed is provided on the hook's standard
203203
input with lines of the form:
@@ -216,16 +216,16 @@ SHA-1>` will be 40 `0`. If the local commit was specified by something other
216216
than a name which could be expanded (such as `HEAD~`, or a SHA-1) it will be
217217
supplied as it was originally given.
218218

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
220220
pushing anything. Information about why the push is rejected may be sent
221221
to the user by writing to standard error.
222222

223223
[[pre-receive]]
224224
pre-receive
225225
~~~~~~~~~~~
226226

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.
229229
Just before starting to update refs on the remote repository, the
230230
pre-receive hook is invoked. Its exit status determines the success
231231
or failure of the update.
@@ -246,7 +246,7 @@ updated. If the hook exits with zero, updating of individual refs can
246246
still be prevented by the <<update,'update'>> hook.
247247

248248
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
250250
for the user.
251251

252252
The number of push options given on the command line of
@@ -265,8 +265,8 @@ linkgit:git-receive-pack[1] for some caveats.
265265
update
266266
~~~~~~
267267

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.
270270
Just before updating the ref on the remote repository, the update hook
271271
is invoked. Its exit status determines the success or failure of
272272
the ref update.
@@ -279,7 +279,7 @@ three parameters:
279279
- and the new object name to be stored in the ref.
280280

281281
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`
283283
from updating that ref.
284284

285285
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
299299
shell to restrict the user's access to only git commands.
300300

301301
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
303303
for the user.
304304

305305
The default 'update' hook, when enabled--and with
@@ -310,8 +310,8 @@ unannotated tags to be pushed.
310310
post-receive
311311
~~~~~~~~~~~~
312312

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.
315315
It executes on the remote repository once after all the refs have
316316
been updated.
317317

@@ -320,15 +320,15 @@ arguments, but gets the same information as the
320320
<<pre-receive,'pre-receive'>>
321321
hook does on its standard input.
322322

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
324324
is called after the real work is done.
325325

326326
This supersedes the <<post-update,'post-update'>> hook in that it gets
327327
both old and new values of all the refs in addition to their
328328
names.
329329

330330
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
332332
for the user.
333333

334334
The default 'post-receive' hook is empty, but there is
@@ -349,16 +349,16 @@ will be set to zero, `GIT_PUSH_OPTION_COUNT=0`.
349349
post-update
350350
~~~~~~~~~~~
351351

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.
354354
It executes on the remote repository once after all the refs have
355355
been updated.
356356

357357
It takes a variable number of parameters, each of which is the
358358
name of ref that was actually updated.
359359

360360
This hook is meant primarily for notification, and cannot affect
361-
the outcome of 'git-receive-pack'.
361+
the outcome of `git receive-pack`.
362362

363363
The 'post-update' hook can tell what are the heads that were pushed,
364364
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
368368
them.
369369

370370
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
372372
transports (e.g., HTTP) up to date. If you are publishing
373373
a Git repository that is accessible via HTTP, you should
374374
probably enable this hook.
375375

376376
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
378378
for the user.
379379

380380
push-to-checkout
381381
~~~~~~~~~~~~~~~~
382382

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
385385
the push tries to update the branch that is currently checked out
386386
and the `receive.denyCurrentBranch` configuration variable is set to
387387
`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
400400
exit with a zero status.
401401

402402
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
405405
essentially the same as `git checkout` that switches branches while
406406
keeping the local changes in the working tree that do not interfere
407407
with the difference between the branches.
@@ -410,15 +410,16 @@ with the difference between the branches.
410410
pre-auto-gc
411411
~~~~~~~~~~~
412412

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.
416416

417417
post-rewrite
418418
~~~~~~~~~~~~
419419

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
422423
it!). Its first argument denotes the command it was invoked by:
423424
currently one of `amend` or `rebase`. Further command-dependent
424425
arguments may be passed in the future.
@@ -450,16 +451,16 @@ processed by rebase.
450451
sendemail-validate
451452
~~~~~~~~~~~~~~~~~~
452453

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,
454455
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
456457
e-mails.
457458

458459
fsmonitor-watchman
459460
~~~~~~~~~~~~~~~~~~
460461

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
463464
(currently 1) and the time in elapsed nanoseconds since midnight,
464465
January 1, 1970.
465466

@@ -478,7 +479,7 @@ directories are checked for untracked files based on the path names
478479
given.
479480

480481
An optimized way to tell git "all files have changed" is to return
481-
the filename '/'.
482+
the filename `/`.
482483

483484
The exit status determines whether git will use the data from the
484485
hook to limit its search. On error, it will fall back to verifying

0 commit comments

Comments
 (0)