Skip to content

Commit 49fa52f

Browse files
avargitster
authored andcommitted
githooks.txt: improve the intro section
Change the documentation so that: * We don't talk about "little scripts". Hooks can be as big as you want, and don't have to be scripts, just call them "programs". * We note that we change the working directory before a hook is called, nothing documented this explicitly, but the current behavior is predictable. It helps a lot to know what directory these hooks will be executed from. * We don't make claims about the example hooks which may not be true depending on the configuration of 'init.templateDir'. Clarify that we're talking about the default settings of git-init in those cases, and move some of this documentation into git-init's documentation about the default templates. * We briefly note in the intro that hooks can get their arguments in various different ways, and that how exactly is described below for each hook. Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 90f7b16 commit 49fa52f

File tree

2 files changed

+25
-13
lines changed

2 files changed

+25
-13
lines changed

Documentation/git-init.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,12 @@ The template directory will be one of the following (in order):
130130
- the default template directory: `/usr/share/git-core/templates`.
131131

132132
The default template directory includes some directory structure, suggested
133-
"exclude patterns" (see linkgit:gitignore[5]), and sample hook files (see linkgit:githooks[5]).
133+
"exclude patterns" (see linkgit:gitignore[5]), and sample hook files.
134+
135+
The sample hooks are all disabled by default, To enable one of the
136+
sample hooks rename it by removing its `.sample` suffix.
137+
138+
See linkgit:githooks[5] for more general info on hook execution.
134139

135140
EXAMPLES
136141
--------

Documentation/githooks.txt

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,25 @@ $GIT_DIR/hooks/*
1313
DESCRIPTION
1414
-----------
1515

16-
Hooks are little scripts you can place in `$GIT_DIR/hooks`
17-
directory to trigger action at certain points. When
18-
'git init' is run, a handful of example hooks are copied into the
19-
`hooks` directory of the new repository, but by default they are
20-
all disabled. To enable a hook, rename it by removing its `.sample`
21-
suffix.
22-
23-
NOTE: It is also a requirement for a given hook to be executable.
24-
However - in a freshly initialized repository - the `.sample` files are
25-
executable by default.
26-
27-
This document describes the currently defined hooks.
16+
Hooks are programs you can place in the `$GIT_DIR/hooks` directory to
17+
trigger actions at certain points in git's execution. Hooks that don't
18+
have the executable bit set are ignored.
19+
20+
Before Git invokes a hook, it changes its working directory to either
21+
the root of the working tree in a non-bare repository, or to the
22+
$GIT_DIR in a bare repository.
23+
24+
Hooks can get their arguments via the environment, command-line
25+
arguments, and stdin. See the documentation for each hook below for
26+
details.
27+
28+
'git init' may copy hooks to the new repository, depending on its
29+
configuration. See the "TEMPLATE DIRECTORY" section in
30+
linkgit:git-init[1] for details. When the rest of this document refers
31+
to "default hooks" it's talking about the default template shipped
32+
with Git.
33+
34+
The currently supported hooks are described below.
2835

2936
HOOKS
3037
-----

0 commit comments

Comments
 (0)