Skip to content

Commit

Permalink
Merge branch 'pb/prepare-commit-msg'
Browse files Browse the repository at this point in the history
* pb/prepare-commit-msg:
  git-commit: add a prepare-commit-msg hook
  git-commit: Refactor creation of log message.
  git-commit: set GIT_EDITOR=: if editor will not be launched
  git-commit: support variable number of hook arguments
  • Loading branch information
Junio C Hamano committed Feb 17, 2008
2 parents fef1c4c + 8089c85 commit 1ae419c
Show file tree
Hide file tree
Showing 7 changed files with 399 additions and 110 deletions.
4 changes: 2 additions & 2 deletions Documentation/git-commit.txt
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,8 @@ order).

HOOKS
-----
This command can run `commit-msg`, `pre-commit`, and
`post-commit` hooks. See link:hooks.html[hooks] for more
This command can run `commit-msg`, `prepare-commit-msg`, `pre-commit`,
and `post-commit` hooks. See link:hooks.html[hooks] for more
information.


Expand Down
29 changes: 29 additions & 0 deletions Documentation/hooks.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,35 @@ The default 'pre-commit' hook, when enabled, catches introduction
of lines with trailing whitespaces and aborts the commit when
such a line is found.

All the `git-commit` hooks are invoked with the environment
variable `GIT_EDITOR=:` if the command will not bring up an editor
to modify the commit message.

prepare-commit-msg
------------------

This hook is invoked by `git-commit` right after preparing the
default log message, and before the editor is started.

It takes one to three parameters. The first is the name of the file
that the commit log message. The second is the source of the commit
message, and can be: `message` (if a `\-m` or `\-F` option was
given); `template` (if a `\-t` option was given or the
configuration option `commit.template` is set); `merge` (if the
commit is a merge or a `.git/MERGE_MSG` file exists); `squash`
(if a `.git/SQUASH_MSG` file exists); or `commit`, followed by
a commit SHA1 (if a `\-c`, `\-C` or `\--amend` option was given).

If the exit status is non-zero, `git-commit` will abort.

The purpose of the hook is to edit the message file in place, and
it is not suppressed by the `\--no-verify` option. A non-zero exit
means a failure of the hook and aborts the commit. It should not
be used as replacement for pre-commit hook.

The sample `prepare-commit-msg` hook that comes with git comments
out the `Conflicts:` part of a merge's commit message.

commit-msg
----------

Expand Down
Loading

0 comments on commit 1ae419c

Please sign in to comment.