Next: , Previous: , Up: Editing Commit Messages   [Contents][Index]


Commit Mode and Hooks

git-commit-mode is a minor mode that is only used to establish certain key bindings. This makes it possible to use an arbitrary major mode in buffers used to edit commit messages. It is even possible to use different major modes in different repositories, which is useful when different projects impose different commit message conventions.

User Option: git-commit-major-mode

The value of this option is the major mode used to edit Git commit messages.

Because git-commit-mode is a minor mode, we don’t use its mode hook to setup the buffer, except for the key bindings. All other setup happens in the function git-commit-setup, which among other things runs the hook git-commit-setup-hook.

User Option: git-commit-setup-hook

Hook run at the end of git-commit-setup.

The following functions are suitable for this hook:

Function: git-commit-save-message

Save the current buffer content to the commit message ring.

Function: git-commit-setup-changelog-support

After this function is called, ChangeLog entries are treated as paragraphs.

Function: git-commit-turn-on-auto-fill

Turn on auto-fill-mode.

Function: git-commit-turn-on-flyspell

Turn on Flyspell mode. Also prevent comments from being checked and finally check current non-comment text.

Function: git-commit-propertize-diff

Propertize the diff shown inside the commit message buffer. Git inserts such diffs into the commit message template when the --verbose argument is used. magit-commit by default does not offer that argument because the diff that is shown in a separate buffer is more useful. But some users disagree, which is why this function exists.

Function: bug-reference-mode

Hyperlink bug references in the buffer.

Function: with-editor-usage-message

Show usage information in the echo area.

User Option: git-commit-post-finish-hook

Hook run after the user finished writing a commit message.

This hook is only run after pressing C-c C-c in a buffer used to edit a commit message. If a commit is created without the user typing a message into a buffer, then this hook is not run.

This hook is not run until the new commit has been created. If doing so takes Git longer than one second, then this hook isn’t run at all. For certain commands such as magit-rebase-continue this hook is never run because doing so would lead to a race condition.

This hook is only run if magit is available.

Also see magit-post-commit-hook.


Next: Commit Message Conventions, Previous: Commit Pseudo Headers, Up: Editing Commit Messages   [Contents][Index]