Merge branch 'es/chainlint-ncores-fix' into next
[git.git] / Documentation / githooks.txt
blob06e997131bcaf2f589252799eb0aa156b0e9b2b2
1 githooks(5)
2 ===========
4 NAME
5 ----
6 githooks - Hooks used by Git
8 SYNOPSIS
9 --------
10 $GIT_DIR/hooks/* (or \`git config core.hooksPath`/*)
13 DESCRIPTION
14 -----------
16 Hooks are programs you can place in a hooks directory to trigger
17 actions at certain points in git's execution. Hooks that don't have
18 the executable bit set are ignored.
20 By default the hooks directory is `$GIT_DIR/hooks`, but that can be
21 changed via the `core.hooksPath` configuration variable (see
22 linkgit:git-config[1]).
24 Before Git invokes a hook, it changes its working directory to either
25 $GIT_DIR in a bare repository or the root of the working tree in a non-bare
26 repository. An exception are hooks triggered during a push ('pre-receive',
27 'update', 'post-receive', 'post-update', 'push-to-checkout') which are always
28 executed in $GIT_DIR.
30 Environment variables, such as `GIT_DIR`, `GIT_WORK_TREE`, etc., are exported
31 so that Git commands run by the hook can correctly locate the repository.  If
32 your hook needs to invoke Git commands in a foreign repository or in a
33 different working tree of the same repository, then it should clear these
34 environment variables so they do not interfere with Git operations at the
35 foreign location.  For example:
37 ------------
38 local_desc=$(git describe)
39 foreign_desc=$(unset $(git rev-parse --local-env-vars); git -C ../foreign-repo describe)
40 ------------
42 Hooks can get their arguments via the environment, command-line
43 arguments, and stdin. See the documentation for each hook below for
44 details.
46 `git init` may copy hooks to the new repository, depending on its
47 configuration. See the "TEMPLATE DIRECTORY" section in
48 linkgit:git-init[1] for details. When the rest of this document refers
49 to "default hooks" it's talking about the default template shipped
50 with Git.
52 The currently supported hooks are described below.
54 HOOKS
55 -----
57 applypatch-msg
58 ~~~~~~~~~~~~~~
60 This hook is invoked by linkgit:git-am[1].  It takes a single
61 parameter, the name of the file that holds the proposed commit
62 log message.  Exiting with a non-zero status causes `git am` to abort
63 before applying the patch.
65 The hook is allowed to edit the message file in place, and can
66 be used to normalize the message into some project standard
67 format. It can also be used to refuse the commit after inspecting
68 the message file.
70 The default 'applypatch-msg' hook, when enabled, runs the
71 'commit-msg' hook, if the latter is enabled.
73 pre-applypatch
74 ~~~~~~~~~~~~~~
76 This hook is invoked by linkgit:git-am[1].  It takes no parameter, and is
77 invoked after the patch is applied, but before a commit is made.
79 If it exits with non-zero status, then the working tree will not be
80 committed after applying the patch.
82 It can be used to inspect the current working tree and refuse to
83 make a commit if it does not pass certain tests.
85 The default 'pre-applypatch' hook, when enabled, runs the
86 'pre-commit' hook, if the latter is enabled.
88 post-applypatch
89 ~~~~~~~~~~~~~~~
91 This hook is invoked by linkgit:git-am[1].  It takes no parameter,
92 and is invoked after the patch is applied and a commit is made.
94 This hook is meant primarily for notification, and cannot affect
95 the outcome of `git am`.
97 pre-commit
98 ~~~~~~~~~~
100 This hook is invoked by linkgit:git-commit[1], and can be bypassed
101 with the `--no-verify` option.  It takes no parameters, and is
102 invoked before obtaining the proposed commit log message and
103 making a commit.  Exiting with a non-zero status from this script
104 causes the `git commit` command to abort before creating a commit.
106 The default 'pre-commit' hook, when enabled, catches introduction
107 of lines with trailing whitespaces and aborts the commit when
108 such a line is found.
110 All the `git commit` hooks are invoked with the environment
111 variable `GIT_EDITOR=:` if the command will not bring up an editor
112 to modify the commit message.
114 The default 'pre-commit' hook, when enabled--and with the
115 `hooks.allownonascii` config option unset or set to false--prevents
116 the use of non-ASCII filenames.
118 pre-merge-commit
119 ~~~~~~~~~~~~~~~~
121 This hook is invoked by linkgit:git-merge[1], and can be bypassed
122 with the `--no-verify` option.  It takes no parameters, and is
123 invoked after the merge has been carried out successfully and before
124 obtaining the proposed commit log message to
125 make a commit.  Exiting with a non-zero status from this script
126 causes the `git merge` command to abort before creating a commit.
128 The default 'pre-merge-commit' hook, when enabled, runs the
129 'pre-commit' hook, if the latter is enabled.
131 This hook is invoked with the environment variable
132 `GIT_EDITOR=:` if the command will not bring up an editor
133 to modify the commit message.
135 If the merge cannot be carried out automatically, the conflicts
136 need to be resolved and the result committed separately (see
137 linkgit:git-merge[1]). At that point, this hook will not be executed,
138 but the 'pre-commit' hook will, if it is enabled.
140 prepare-commit-msg
141 ~~~~~~~~~~~~~~~~~~
143 This hook is invoked by linkgit:git-commit[1] right after preparing the
144 default log message, and before the editor is started.
146 It takes one to three parameters.  The first is the name of the file
147 that contains the commit log message.  The second is the source of the commit
148 message, and can be: `message` (if a `-m` or `-F` option was
149 given); `template` (if a `-t` option was given or the
150 configuration option `commit.template` is set); `merge` (if the
151 commit is a merge or a `.git/MERGE_MSG` file exists); `squash`
152 (if a `.git/SQUASH_MSG` file exists); or `commit`, followed by
153 a commit object name (if a `-c`, `-C` or `--amend` option was given).
155 If the exit status is non-zero, `git commit` will abort.
157 The purpose of the hook is to edit the message file in place, and
158 it is not suppressed by the `--no-verify` option.  A non-zero exit
159 means a failure of the hook and aborts the commit.  It should not
160 be used as a replacement for the pre-commit hook.
162 The sample `prepare-commit-msg` hook that comes with Git removes the
163 help message found in the commented portion of the commit template.
165 commit-msg
166 ~~~~~~~~~~
168 This hook is invoked by linkgit:git-commit[1] and linkgit:git-merge[1], and can be
169 bypassed with the `--no-verify` option.  It takes a single parameter,
170 the name of the file that holds the proposed commit log message.
171 Exiting with a non-zero status causes the command to abort.
173 The hook is allowed to edit the message file in place, and can be used
174 to normalize the message into some project standard format. It
175 can also be used to refuse the commit after inspecting the message
176 file.
178 The default 'commit-msg' hook, when enabled, detects duplicate
179 `Signed-off-by` trailers, and aborts the commit if one is found.
181 post-commit
182 ~~~~~~~~~~~
184 This hook is invoked by linkgit:git-commit[1]. It takes no parameters, and is
185 invoked after a commit is made.
187 This hook is meant primarily for notification, and cannot affect
188 the outcome of `git commit`.
190 pre-rebase
191 ~~~~~~~~~~
193 This hook is called by linkgit:git-rebase[1] and can be used to prevent a
194 branch from getting rebased.  The hook may be called with one or
195 two parameters.  The first parameter is the upstream from which
196 the series was forked.  The second parameter is the branch being
197 rebased, and is not set when rebasing the current branch.
199 post-checkout
200 ~~~~~~~~~~~~~
202 This hook is invoked when a linkgit:git-checkout[1] or
203 linkgit:git-switch[1] is run after having updated the
204 worktree.  The hook is given three parameters: the ref of the previous HEAD,
205 the ref of the new HEAD (which may or may not have changed), and a flag
206 indicating whether the checkout was a branch checkout (changing branches,
207 flag=1) or a file checkout (retrieving a file from the index, flag=0).
208 This hook cannot affect the outcome of `git switch` or `git checkout`,
209 other than that the hook's exit status becomes the exit status of
210 these two commands.
212 It is also run after linkgit:git-clone[1], unless the `--no-checkout` (`-n`) option is
213 used. The first parameter given to the hook is the null-ref, the second the
214 ref of the new HEAD and the flag is always 1. Likewise for `git worktree add`
215 unless `--no-checkout` is used.
217 This hook can be used to perform repository validity checks, auto-display
218 differences from the previous HEAD if different, or set working dir metadata
219 properties.
221 post-merge
222 ~~~~~~~~~~
224 This hook is invoked by linkgit:git-merge[1], which happens when a `git pull`
225 is done on a local repository.  The hook takes a single parameter, a status
226 flag specifying whether or not the merge being done was a squash merge.
227 This hook cannot affect the outcome of `git merge` and is not executed,
228 if the merge failed due to conflicts.
230 This hook can be used in conjunction with a corresponding pre-commit hook to
231 save and restore any form of metadata associated with the working tree
232 (e.g.: permissions/ownership, ACLS, etc).  See contrib/hooks/setgitperms.perl
233 for an example of how to do this.
235 pre-push
236 ~~~~~~~~
238 This hook is called by linkgit:git-push[1] and can be used to prevent
239 a push from taking place.  The hook is called with two parameters
240 which provide the name and location of the destination remote, if a
241 named remote is not being used both values will be the same.
243 Information about what is to be pushed is provided on the hook's standard
244 input with lines of the form:
246   <local-ref> SP <local-object-name> SP <remote-ref> SP <remote-object-name> LF
248 For instance, if the command +git push origin master:foreign+ were run the
249 hook would receive a line like the following:
251   refs/heads/master 67890 refs/heads/foreign 12345
253 although the full object name would be supplied.  If the foreign ref does not
254 yet exist the `<remote-object-name>` will be the all-zeroes object name.  If a
255 ref is to be deleted, the `<local-ref>` will be supplied as `(delete)` and the
256 `<local-object-name>` will be the all-zeroes object name.  If the local commit
257 was specified by something other than a name which could be expanded (such as
258 `HEAD~`, or an object name) it will be supplied as it was originally given.
260 If this hook exits with a non-zero status, `git push` will abort without
261 pushing anything.  Information about why the push is rejected may be sent
262 to the user by writing to standard error.
264 [[pre-receive]]
265 pre-receive
266 ~~~~~~~~~~~
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.
270 Just before starting to update refs on the remote repository, the
271 pre-receive hook is invoked.  Its exit status determines the success
272 or failure of the update.
274 This hook executes once for the receive operation. It takes no
275 arguments, but for each ref to be updated it receives on standard
276 input a line of the format:
278   <old-oid> SP <new-oid> SP <ref-name> LF
280 where `<old-oid>` is the old object name stored in the ref,
281 `<new-oid>` is the new object name to be stored in the ref and
282 `<ref-name>` is the full name of the ref.
283 When creating a new ref, `<old-oid>` is the all-zeroes object name.
285 If the hook exits with non-zero status, none of the refs will be
286 updated. If the hook exits with zero, updating of individual refs can
287 still be prevented by the <<update,'update'>> hook.
289 Both standard output and standard error output are forwarded to
290 `git send-pack` on the other end, so you can simply `echo` messages
291 for the user.
293 The number of push options given on the command line of
294 `git push --push-option=...` can be read from the environment
295 variable `GIT_PUSH_OPTION_COUNT`, and the options themselves are
296 found in `GIT_PUSH_OPTION_0`, `GIT_PUSH_OPTION_1`,...
297 If it is negotiated to not use the push options phase, the
298 environment variables will not be set. If the client selects
299 to use push options, but doesn't transmit any, the count variable
300 will be set to zero, `GIT_PUSH_OPTION_COUNT=0`.
302 See the section on "Quarantine Environment" in
303 linkgit:git-receive-pack[1] for some caveats.
305 [[update]]
306 update
307 ~~~~~~
309 This hook is invoked by linkgit:git-receive-pack[1] when it reacts to
310 `git push` and updates reference(s) in its repository.
311 Just before updating the ref on the remote repository, the update hook
312 is invoked.  Its exit status determines the success or failure of
313 the ref update.
315 The hook executes once for each ref to be updated, and takes
316 three parameters:
318  - the name of the ref being updated,
319  - the old object name stored in the ref,
320  - and the new object name to be stored in the ref.
322 A zero exit from the update hook allows the ref to be updated.
323 Exiting with a non-zero status prevents `git receive-pack`
324 from updating that ref.
326 This hook can be used to prevent 'forced' update on certain refs by
327 making sure that the object name is a commit object that is a
328 descendant of the commit object named by the old object name.
329 That is, to enforce a "fast-forward only" policy.
331 It could also be used to log the old..new status.  However, it
332 does not know the entire set of branches, so it would end up
333 firing one e-mail per ref when used naively, though.  The
334 <<post-receive,'post-receive'>> hook is more suited to that.
336 In an environment that restricts the users' access only to git
337 commands over the wire, this hook can be used to implement access
338 control without relying on filesystem ownership and group
339 membership. See linkgit:git-shell[1] for how you might use the login
340 shell to restrict the user's access to only git commands.
342 Both standard output and standard error output are forwarded to
343 `git send-pack` on the other end, so you can simply `echo` messages
344 for the user.
346 The default 'update' hook, when enabled--and with
347 `hooks.allowunannotated` config option unset or set to false--prevents
348 unannotated tags from being pushed.
350 [[proc-receive]]
351 proc-receive
352 ~~~~~~~~~~~~
354 This hook is invoked by linkgit:git-receive-pack[1].  If the server has
355 set the multi-valued config variable `receive.procReceiveRefs`, and the
356 commands sent to 'receive-pack' have matching reference names, these
357 commands will be executed by this hook, instead of by the internal
358 `execute_commands()` function.  This hook is responsible for updating
359 the relevant references and reporting the results back to 'receive-pack'.
361 This hook executes once for the receive operation.  It takes no
362 arguments, but uses a pkt-line format protocol to communicate with
363 'receive-pack' to read commands, push-options and send results.  In the
364 following example for the protocol, the letter 'S' stands for
365 'receive-pack' and the letter 'H' stands for this hook.
367     # Version and features negotiation.
368     S: PKT-LINE(version=1\0push-options atomic...)
369     S: flush-pkt
370     H: PKT-LINE(version=1\0push-options...)
371     H: flush-pkt
373     # Send commands from server to the hook.
374     S: PKT-LINE(<old-oid> <new-oid> <ref>)
375     S: ... ...
376     S: flush-pkt
377     # Send push-options only if the 'push-options' feature is enabled.
378     S: PKT-LINE(push-option)
379     S: ... ...
380     S: flush-pkt
382     # Receive results from the hook.
383     # OK, run this command successfully.
384     H: PKT-LINE(ok <ref>)
385     # NO, I reject it.
386     H: PKT-LINE(ng <ref> <reason>)
387     # Fall through, let 'receive-pack' execute it.
388     H: PKT-LINE(ok <ref>)
389     H: PKT-LINE(option fall-through)
390     # OK, but has an alternate reference.  The alternate reference name
391     # and other status can be given in option directives.
392     H: PKT-LINE(ok <ref>)
393     H: PKT-LINE(option refname <refname>)
394     H: PKT-LINE(option old-oid <old-oid>)
395     H: PKT-LINE(option new-oid <new-oid>)
396     H: PKT-LINE(option forced-update)
397     H: ... ...
398     H: flush-pkt
400 Each command for the 'proc-receive' hook may point to a pseudo-reference
401 and always has a zero-old as its old-oid, while the 'proc-receive' hook
402 may update an alternate reference and the alternate reference may exist
403 already with a non-zero old-oid.  For this case, this hook will use
404 "option" directives to report extended attributes for the reference given
405 by the leading "ok" directive.
407 The report of the commands of this hook should have the same order as
408 the input.  The exit status of the 'proc-receive' hook only determines
409 the success or failure of the group of commands sent to it, unless
410 atomic push is in use.
412 [[post-receive]]
413 post-receive
414 ~~~~~~~~~~~~
416 This hook is invoked by linkgit:git-receive-pack[1] when it reacts to
417 `git push` and updates reference(s) in its repository.
418 It executes on the remote repository once after all the refs have
419 been updated.
421 This hook executes once for the receive operation.  It takes no
422 arguments, but gets the same information as the
423 <<pre-receive,'pre-receive'>>
424 hook does on its standard input.
426 This hook does not affect the outcome of `git receive-pack`, as it
427 is called after the real work is done.
429 This supersedes the <<post-update,'post-update'>> hook in that it gets
430 both old and new values of all the refs in addition to their
431 names.
433 Both standard output and standard error output are forwarded to
434 `git send-pack` on the other end, so you can simply `echo` messages
435 for the user.
437 The default 'post-receive' hook is empty, but there is
438 a sample script `post-receive-email` provided in the `contrib/hooks`
439 directory in Git distribution, which implements sending commit
440 emails.
442 The number of push options given on the command line of
443 `git push --push-option=...` can be read from the environment
444 variable `GIT_PUSH_OPTION_COUNT`, and the options themselves are
445 found in `GIT_PUSH_OPTION_0`, `GIT_PUSH_OPTION_1`,...
446 If it is negotiated to not use the push options phase, the
447 environment variables will not be set. If the client selects
448 to use push options, but doesn't transmit any, the count variable
449 will be set to zero, `GIT_PUSH_OPTION_COUNT=0`.
451 [[post-update]]
452 post-update
453 ~~~~~~~~~~~
455 This hook is invoked by linkgit:git-receive-pack[1] when it reacts to
456 `git push` and updates reference(s) in its repository.
457 It executes on the remote repository once after all the refs have
458 been updated.
460 It takes a variable number of parameters, each of which is the
461 name of ref that was actually updated.
463 This hook is meant primarily for notification, and cannot affect
464 the outcome of `git receive-pack`.
466 The 'post-update' hook can tell what are the heads that were pushed,
467 but it does not know what their original and updated values are,
468 so it is a poor place to do log old..new. The
469 <<post-receive,'post-receive'>> hook does get both original and
470 updated values of the refs. You might consider it instead if you need
471 them.
473 When enabled, the default 'post-update' hook runs
474 `git update-server-info` to keep the information used by dumb
475 transports (e.g., HTTP) up to date.  If you are publishing
476 a Git repository that is accessible via HTTP, you should
477 probably enable this hook.
479 Both standard output and standard error output are forwarded to
480 `git send-pack` on the other end, so you can simply `echo` messages
481 for the user.
483 reference-transaction
484 ~~~~~~~~~~~~~~~~~~~~~
486 This hook is invoked by any Git command that performs reference
487 updates. It executes whenever a reference transaction is prepared,
488 committed or aborted and may thus get called multiple times. The hook
489 also supports symbolic reference updates.
491 The hook takes exactly one argument, which is the current state the
492 given reference transaction is in:
494     - "prepared": All reference updates have been queued to the
495       transaction and references were locked on disk.
497     - "committed": The reference transaction was committed and all
498       references now have their respective new value.
500     - "aborted": The reference transaction was aborted, no changes
501       were performed and the locks have been released.
503 For each reference update that was added to the transaction, the hook
504 receives on standard input a line of the format:
506   <old-value> SP <new-value> SP <ref-name> LF
508 where `<old-value>` is the old object name passed into the reference
509 transaction, `<new-value>` is the new object name to be stored in the
510 ref and `<ref-name>` is the full name of the ref. When force updating
511 the reference regardless of its current value or when the reference is
512 to be created anew, `<old-value>` is the all-zeroes object name. To
513 distinguish these cases, you can inspect the current value of
514 `<ref-name>` via `git rev-parse`.
516 For symbolic reference updates the `<old_value>` and `<new-value>`
517 fields could denote references instead of objects. A reference will be
518 denoted with a 'ref:' prefix, like `ref:<ref-target>`.
520 The exit status of the hook is ignored for any state except for the
521 "prepared" state. In the "prepared" state, a non-zero exit status will
522 cause the transaction to be aborted. The hook will not be called with
523 "aborted" state in that case.
525 push-to-checkout
526 ~~~~~~~~~~~~~~~~
528 This hook is invoked by linkgit:git-receive-pack[1] when it reacts to
529 `git push` and updates reference(s) in its repository, and when
530 the push tries to update the branch that is currently checked out
531 and the `receive.denyCurrentBranch` configuration variable is set to
532 `updateInstead`.  Such a push by default is refused if the working
533 tree and the index of the remote repository has any difference from
534 the currently checked out commit; when both the working tree and the
535 index match the current commit, they are updated to match the newly
536 pushed tip of the branch.  This hook is to be used to override the
537 default behaviour.
539 The hook receives the commit with which the tip of the current
540 branch is going to be updated.  It can exit with a non-zero status
541 to refuse the push (when it does so, it must not modify the index or
542 the working tree).  Or it can make any necessary changes to the
543 working tree and to the index to bring them to the desired state
544 when the tip of the current branch is updated to the new commit, and
545 exit with a zero status.
547 For example, the hook can simply run `git read-tree -u -m HEAD "$1"`
548 in order to emulate `git fetch` that is run in the reverse direction
549 with `git push`, as the two-tree form of `git read-tree -u -m` is
550 essentially the same as `git switch` or `git checkout`
551 that switches branches while
552 keeping the local changes in the working tree that do not interfere
553 with the difference between the branches.
556 pre-auto-gc
557 ~~~~~~~~~~~
559 This hook is invoked by `git gc --auto` (see linkgit:git-gc[1]). It
560 takes no parameter, and exiting with non-zero status from this script
561 causes the `git gc --auto` to abort.
563 post-rewrite
564 ~~~~~~~~~~~~
566 This hook is invoked by commands that rewrite commits
567 (linkgit:git-commit[1] when called with `--amend` and
568 linkgit:git-rebase[1]; however, full-history (re)writing tools like
569 linkgit:git-fast-import[1] or
570 https://github.com/newren/git-filter-repo[git-filter-repo] typically
571 do not call it!).  Its first argument denotes the command it was
572 invoked by: currently one of `amend` or `rebase`.  Further
573 command-dependent arguments may be passed in the future.
575 The hook receives a list of the rewritten commits on stdin, in the
576 format
578   <old-object-name> SP <new-object-name> [ SP <extra-info> ] LF
580 The 'extra-info' is again command-dependent.  If it is empty, the
581 preceding SP is also omitted.  Currently, no commands pass any
582 'extra-info'.
584 The hook always runs after the automatic note copying (see
585 "notes.rewrite.<command>" in linkgit:git-config[1]) has happened, and
586 thus has access to these notes.
588 The following command-specific comments apply:
590 rebase::
591         For the 'squash' and 'fixup' operation, all commits that were
592         squashed are listed as being rewritten to the squashed commit.
593         This means that there will be several lines sharing the same
594         'new-object-name'.
596 The commits are guaranteed to be listed in the order that they were
597 processed by rebase.
599 sendemail-validate
600 ~~~~~~~~~~~~~~~~~~
602 This hook is invoked by linkgit:git-send-email[1].
604 It takes these command line arguments. They are,
605 1. the name of the file which holds the contents of the email to be sent.
606 2. The name of the file which holds the SMTP headers of the email.
608 The SMTP headers are passed in the exact same way as they are passed to the
609 user's Mail Transport Agent (MTA). In effect, the email given to the user's
610 MTA, is the contents of $2 followed by the contents of $1.
612 An example of a few common headers is shown below. Take notice of the
613 capitalization and multi-line tab structure.
615   From: Example <from@example.com>
616   To: to@example.com
617   Cc: cc@example.com,
618           A <author@example.com>,
619           One <one@example.com>,
620           two@example.com
621   Subject: PATCH-STRING
623 Exiting with a non-zero status causes `git send-email` to abort
624 before sending any e-mails.
626 The following environment variables are set when executing the hook.
628 `GIT_SENDEMAIL_FILE_COUNTER`::
629         A 1-based counter incremented by one for every file holding an e-mail
630         to be sent (excluding any FIFOs). This counter does not follow the
631         patch series counter scheme. It will always start at 1 and will end at
632         GIT_SENDEMAIL_FILE_TOTAL.
634 `GIT_SENDEMAIL_FILE_TOTAL`::
635         The total number of files that will be sent (excluding any FIFOs). This
636         counter does not follow the patch series counter scheme. It will always
637         be equal to the number of files being sent, whether there is a cover
638         letter or not.
640 These variables may for instance be used to validate patch series.
642 The sample `sendemail-validate` hook that comes with Git checks that all sent
643 patches (excluding the cover letter) can be applied on top of the upstream
644 repository default branch without conflicts. Some placeholders are left for
645 additional validation steps to be performed after all patches of a given series
646 have been applied.
648 fsmonitor-watchman
649 ~~~~~~~~~~~~~~~~~~
651 This hook is invoked when the configuration option `core.fsmonitor` is
652 set to `.git/hooks/fsmonitor-watchman` or `.git/hooks/fsmonitor-watchmanv2`
653 depending on the version of the hook to use.
655 Version 1 takes two arguments, a version (1) and the time in elapsed
656 nanoseconds since midnight, January 1, 1970.
658 Version 2 takes two arguments, a version (2) and a token that is used
659 for identifying changes since the token. For watchman this would be
660 a clock id. This version must output to stdout the new token followed
661 by a NUL before the list of files.
663 The hook should output to stdout the list of all files in the working
664 directory that may have changed since the requested time.  The logic
665 should be inclusive so that it does not miss any potential changes.
666 The paths should be relative to the root of the working directory
667 and be separated by a single NUL.
669 It is OK to include files which have not actually changed.  All changes
670 including newly-created and deleted files should be included. When
671 files are renamed, both the old and the new name should be included.
673 Git will limit what files it checks for changes as well as which
674 directories are checked for untracked files based on the path names
675 given.
677 An optimized way to tell git "all files have changed" is to return
678 the filename `/`.
680 The exit status determines whether git will use the data from the
681 hook to limit its search.  On error, it will fall back to verifying
682 all files and folders.
684 p4-changelist
685 ~~~~~~~~~~~~~
687 This hook is invoked by `git-p4 submit`.
689 The `p4-changelist` hook is executed after the changelist
690 message has been edited by the user. It can be bypassed with the
691 `--no-verify` option. It takes a single parameter, the name
692 of the file that holds the proposed changelist text. Exiting
693 with a non-zero status causes the command to abort.
695 The hook is allowed to edit the changelist file and can be used
696 to normalize the text into some project standard format. It can
697 also be used to refuse the Submit after inspect the message file.
699 Run `git-p4 submit --help` for details.
701 p4-prepare-changelist
702 ~~~~~~~~~~~~~~~~~~~~~
704 This hook is invoked by `git-p4 submit`.
706 The `p4-prepare-changelist` hook is executed right after preparing
707 the default changelist message and before the editor is started.
708 It takes one parameter, the name of the file that contains the
709 changelist text. Exiting with a non-zero status from the script
710 will abort the process.
712 The purpose of the hook is to edit the message file in place,
713 and it is not suppressed by the `--no-verify` option. This hook
714 is called even if `--prepare-p4-only` is set.
716 Run `git-p4 submit --help` for details.
718 p4-post-changelist
719 ~~~~~~~~~~~~~~~~~~
721 This hook is invoked by `git-p4 submit`.
723 The `p4-post-changelist` hook is invoked after the submit has
724 successfully occurred in P4. It takes no parameters and is meant
725 primarily for notification and cannot affect the outcome of the
726 git p4 submit action.
728 Run `git-p4 submit --help` for details.
730 p4-pre-submit
731 ~~~~~~~~~~~~~
733 This hook is invoked by `git-p4 submit`. It takes no parameters and nothing
734 from standard input. Exiting with non-zero status from this script prevent
735 `git-p4 submit` from launching. It can be bypassed with the `--no-verify`
736 command line option. Run `git-p4 submit --help` for details.
740 post-index-change
741 ~~~~~~~~~~~~~~~~~
743 This hook is invoked when the index is written in read-cache.c
744 do_write_locked_index.
746 The first parameter passed to the hook is the indicator for the
747 working directory being updated.  "1" meaning working directory
748 was updated or "0" when the working directory was not updated.
750 The second parameter passed to the hook is the indicator for whether
751 or not the index was updated and the skip-worktree bit could have
752 changed.  "1" meaning skip-worktree bits could have been updated
753 and "0" meaning they were not.
755 Only one parameter should be set to "1" when the hook runs.  The hook
756 running passing "1", "1" should not be possible.
758 SEE ALSO
759 --------
760 linkgit:git-hook[1]
764 Part of the linkgit:git[1] suite