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 <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ævar Arnfjörð Bjarmason committed May 4, 2016 at 22:58 UTC 49fa52fd003ece5ea997607167bc5aaec3ff61af
2 files changed +25 -13
Documentation/git-init.txt
+6 -1
@@ -130,7 +130,12 @@ The template directory will be one of the following (in order):
130 - the default template directory: `/usr/share/git-core/templates`.
131
132 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.
139
140 EXAMPLES
141 --------
Documentation/githooks.txt
+19 -12
@@ -13,18 +13,25 @@ $GIT_DIR/hooks/*
13 DESCRIPTION
14 -----------
15
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.
35
36 HOOKS
37 -----