rev-list --objects: fix object list without commit.
[git/git.git] / Documentation / hooks.txt
CommitLineData
72e9340c 1Hooks used by git
6d35cc76 2=================
6d35cc76
JH
3
4Hooks are little scripts you can place in `$GIT_DIR/hooks`
5directory to trigger action at certain points. When
6`git-init-db` is run, a handful example hooks are copied in the
7`hooks` directory of the new repository, but by default they are
8all disabled. To enable a hook, make it executable with `chmod
9+x`.
10
11This document describes the currently defined hooks.
12
13applypatch-msg
14--------------
15
16This hook is invoked by `git-applypatch` script, which is
17typically invoked by `git-applymbox`. It takes a single
18parameter, the name of the file that holds the proposed commit
19log message. Exiting with non-zero status causes the
20'git-applypatch' to abort before applying the patch.
21
22The hook is allowed to edit the message file in place, and can
23be used to normalize the message into some project standard
24format (if the project has one). It can also be used to refuse
25the commit after inspecting the message file.
26
27The default applypatch-msg hook, when enabled, runs the
28commit-msg hook, if the latter is enabled.
29
30pre-applypatch
31--------------
32
33This hook is invoked by `git-applypatch` script, which is
34typically invoked by `git-applymbox`. It takes no parameter,
35and is invoked after the patch is applied, but before a commit
36is made. Exiting with non-zero status causes the working tree
37after application of the patch not committed.
38
39It can be used to inspect the current working tree and refuse to
40make a commit if it does not pass certain test.
41
42The default pre-applypatch hook, when enabled, runs the
43pre-commit hook, if the latter is enabled.
44
45post-applypatch
46---------------
47
48This hook is invoked by `git-applypatch` script, which is
49typically invoked by `git-applymbox`. It takes no parameter,
50and is invoked after the patch is applied and a commit is made.
51
52This hook is meant primarily for notification, and cannot affect
53the outcome of `git-applypatch`.
54
55pre-commit
56----------
57
215a7ad1 58This hook is invoked by `git-commit`, and can be bypassed
e1ccf53a 59with `\--no-verify` option. It takes no parameter, and is
6d35cc76
JH
60invoked before obtaining the proposed commit log message and
61making a commit. Exiting with non-zero status from this script
215a7ad1 62causes the `git-commit` to abort.
6d35cc76
JH
63
64The default pre-commit hook, when enabled, catches introduction
65of lines with trailing whitespaces and aborts the commit when
66a such line is found.
67
68commit-msg
69----------
70
215a7ad1 71This hook is invoked by `git-commit`, and can be bypassed
e1ccf53a 72with `\--no-verify` option. It takes a single parameter, the
6d35cc76 73name of the file that holds the proposed commit log message.
215a7ad1 74Exiting with non-zero status causes the `git-commit` to
6d35cc76
JH
75abort.
76
77The hook is allowed to edit the message file in place, and can
78be used to normalize the message into some project standard
79format (if the project has one). It can also be used to refuse
80the commit after inspecting the message file.
81
82The default commit-msg hook, when enabled, detects duplicate
83Signed-off-by: lines, and aborts the commit when one is found.
84
85post-commit
86-----------
87
215a7ad1 88This hook is invoked by `git-commit`. It takes no
6d35cc76
JH
89parameter, and is invoked after a commit is made.
90
91This hook is meant primarily for notification, and cannot affect
215a7ad1 92the outcome of `git-commit`.
6d35cc76
JH
93
94The default post-commit hook, when enabled, demonstrates how to
95send out a commit notification e-mail.
96
97update
98------
99
100This hook is invoked by `git-receive-pack`, which is invoked
101when a `git push` is done against the repository. It takes
102three parameters, name of the ref being updated, old object name
103stored in the ref, and the new objectname to be stored in the
104ref. Exiting with non-zero status from this hook prevents
105`git-receive-pack` from updating the ref.
106
107This can be used to prevent 'forced' update on certain refs by
108making sure that the object name is a commit object that is a
109descendant of the commit object named by the old object name.
110Another use suggested on the mailing list is to use this hook to
111implement access control which is finer grained than the one
112based on filesystem group.
113
114post-update
115-----------
116
117This hook is invoked by `git-receive-pack`, which is invoked
118when a `git push` is done against the repository. It takes
119variable number of parameters; each of which is the name of ref
120that was actually updated.
121
122This hook is meant primarily for notification, and cannot affect
123the outcome of `git-receive-pack`.
124
125The default post-update hook, when enabled, runs
126`git-update-server-info` to keep the information used by dumb
127transport up-to-date.