connect: display connection progress
[git/dscho.git] / Documentation / hooks.txt
blobaabb9750fddbc28091c46780ccf7b835b62b04c7
1 Hooks used by git
2 =================
4 Hooks are little scripts you can place in `$GIT_DIR/hooks`
5 directory to trigger action at certain points.  When
6 `git-init` is run, a handful example hooks are copied in the
7 `hooks` directory of the new repository, but by default they are
8 all disabled.  To enable a hook, make it executable with `chmod +x`.
10 This document describes the currently defined hooks.
12 applypatch-msg
13 --------------
15 This hook is invoked by `git-applypatch` script, which is
16 typically invoked by `git-applymbox`.  It takes a single
17 parameter, the name of the file that holds the proposed commit
18 log message.  Exiting with non-zero status causes
19 `git-applypatch` to abort before applying the patch.
21 The hook is allowed to edit the message file in place, and can
22 be used to normalize the message into some project standard
23 format (if the project has one). It can also be used to refuse
24 the commit after inspecting the message file.
26 The default 'applypatch-msg' hook, when enabled, runs the
27 'commit-msg' hook, if the latter is enabled.
29 pre-applypatch
30 --------------
32 This hook is invoked by `git-applypatch` script, which is
33 typically invoked by `git-applymbox`.  It takes no parameter,
34 and is invoked after the patch is applied, but before a commit
35 is made.  Exiting with non-zero status causes the working tree
36 after application of the patch not committed.
38 It can be used to inspect the current working tree and refuse to
39 make a commit if it does not pass certain test.
41 The default 'pre-applypatch' hook, when enabled, runs the
42 'pre-commit' hook, if the latter is enabled.
44 post-applypatch
45 ---------------
47 This hook is invoked by `git-applypatch` script, which is
48 typically invoked by `git-applymbox`.  It takes no parameter,
49 and is invoked after the patch is applied and a commit is made.
51 This hook is meant primarily for notification, and cannot affect
52 the outcome of `git-applypatch`.
54 pre-commit
55 ----------
57 This hook is invoked by `git-commit`, and can be bypassed
58 with `\--no-verify` option.  It takes no parameter, and is
59 invoked before obtaining the proposed commit log message and
60 making a commit.  Exiting with non-zero status from this script
61 causes the `git-commit` to abort.
63 The default 'pre-commit' hook, when enabled, catches introduction
64 of lines with trailing whitespaces and aborts the commit when
65 such a line is found.
67 commit-msg
68 ----------
70 This hook is invoked by `git-commit`, and can be bypassed
71 with `\--no-verify` option.  It takes a single parameter, the
72 name of the file that holds the proposed commit log message.
73 Exiting with non-zero status causes the `git-commit` to
74 abort.
76 The hook is allowed to edit the message file in place, and can
77 be used to normalize the message into some project standard
78 format (if the project has one). It can also be used to refuse
79 the commit after inspecting the message file.
81 The default 'commit-msg' hook, when enabled, detects duplicate
82 "Signed-off-by" lines, and aborts the commit if one is found.
84 post-commit
85 -----------
87 This hook is invoked by `git-commit`.  It takes no
88 parameter, and is invoked after a commit is made.
90 This hook is meant primarily for notification, and cannot affect
91 the outcome of `git-commit`.
93 [[pre-receive]]
94 pre-receive
95 -----------
97 This hook is invoked by `git-receive-pack` on the remote repository,
98 which happens when a `git push` is done on a local repository.
99 Just before starting to update refs on the remote repository, the
100 pre-receive hook is invoked.  Its exit status determines the success
101 or failure of the update.
103 This hook executes once for the receive operation. It takes no
104 arguments, but for each ref to be updated it receives on standard
105 input a line of the format:
107   <old-value> SP <new-value> SP <ref-name> LF
109 where `<old-value>` is the old object name stored in the ref,
110 `<new-value>` is the new object name to be stored in the ref and
111 `<ref-name>` is the full name of the ref.
112 When creating a new ref, `<old-value>` is 40 `0`.
114 If the hook exits with non-zero status, none of the refs will be
115 updated. If the hook exits with zero, updating of individual refs can
116 still be prevented by the <<update,'update'>> hook.
118 Both standard output and standard error output are forwarded to
119 `git-send-pack` on the other end, so you can simply `echo` messages
120 for the user.
122 [[update]]
123 update
124 ------
126 This hook is invoked by `git-receive-pack` on the remote repository,
127 which happens when a `git push` is done on a local repository.
128 Just before updating the ref on the remote repository, the update hook
129 is invoked.  Its exit status determines the success or failure of
130 the ref update.
132 The hook executes once for each ref to be updated, and takes
133 three parameters:
135  - the name of the ref being updated,
136  - the old object name stored in the ref,
137  - and the new objectname to be stored in the ref.
139 A zero exit from the update hook allows the ref to be updated.
140 Exiting with a non-zero status prevents `git-receive-pack`
141 from updating that ref.
143 This hook can be used to prevent 'forced' update on certain refs by
144 making sure that the object name is a commit object that is a
145 descendant of the commit object named by the old object name.
146 That is, to enforce a "fast forward only" policy.
148 It could also be used to log the old..new status.  However, it
149 does not know the entire set of branches, so it would end up
150 firing one e-mail per ref when used naively, though.  The
151 <<post-receive,'post-receive'>> hook is more suited to that.
153 Another use suggested on the mailing list is to use this hook to
154 implement access control which is finer grained than the one
155 based on filesystem group.
157 Both standard output and standard error output are forwarded to
158 `git-send-pack` on the other end, so you can simply `echo` messages
159 for the user.
161 The default 'update' hook, when enabled--and with
162 `hooks.allowunannotated` config option turned on--prevents
163 unannotated tags to be pushed.
165 [[post-receive]]
166 post-receive
167 ------------
169 This hook is invoked by `git-receive-pack` on the remote repository,
170 which happens when a `git push` is done on a local repository.
171 It executes on the remote repository once after all the refs have
172 been updated.
174 This hook executes once for the receive operation.  It takes no
175 arguments, but gets the same information as the
176 <<pre-receive,'pre-receive'>>
177 hook does on its standard input.
179 This hook does not affect the outcome of `git-receive-pack`, as it
180 is called after the real work is done.
182 This supersedes the <<post-update,'post-update'>> hook in that it get's
183 both old and new values of all the refs in addition to their
184 names.
186 Both standard output and standard error output are forwarded to
187 `git-send-pack` on the other end, so you can simply `echo` messages
188 for the user.
190 The default 'post-receive' hook is empty, but there is
191 a sample script `post-receive-email` provided in the `contrib/hooks`
192 directory in git distribution, which implements sending commit
193 emails.
195 [[post-update]]
196 post-update
197 -----------
199 This hook is invoked by `git-receive-pack` on the remote repository,
200 which happens when a `git push` is done on a local repository.
201 It executes on the remote repository once after all the refs have
202 been updated.
204 It takes a variable number of parameters, each of which is the
205 name of ref that was actually updated.
207 This hook is meant primarily for notification, and cannot affect
208 the outcome of `git-receive-pack`.
210 The 'post-update' hook can tell what are the heads that were pushed,
211 but it does not know what their original and updated values are,
212 so it is a poor place to do log old..new. The
213 <<post-receive,'post-receive'>> hook does get both original and
214 updated values of the refs. You might consider it instead if you need
215 them.
217 When enabled, the default 'post-update' hook runs
218 `git-update-server-info` to keep the information used by dumb
219 transports (e.g., HTTP) up-to-date.  If you are publishing
220 a git repository that is accessible via HTTP, you should
221 probably enable this hook.
223 Both standard output and standard error output are forwarded to
224 `git-send-pack` on the other end, so you can simply `echo` messages
225 for the user.