git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 4/4] git-commit: add a prepare-commit-msg hook

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 5, 2008, 03:08 UTC
Message-ID
<7vk5lkgkw2.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<5840dd34338023e3af8446241a63927d18772f62.1200933409.git.bonzini@gnu.org>
Paolo Bonzini <bonzini@gnu.org> writes:
Show 8 quoted lines
> It takes two parameters.  The first 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 a commit id (if a
> `\-c`, `\-C` or `\--amend` option was given).  The second
> parameter if the name of the file that the commit log message.

Please do without funny mark-ups. The commit log is not AsciiDoc.

> The hook is not suppressed by the `\--no-verify` option.  However,
> exiting with non-zero status only aborts the commit if said option
> is not given to `git-commit`.

I do not understand why. I do understand that you do not want to bypass prepare-commit-msg with or without --no-verify, because this hook is not about input validation but about input preparation. But I do not understand why a failure exit from it should be treated any differently with or without --no-verify?

If you want to be strict and be safe catching a breakage in the prepare-commit-msg hook, you should always abort. You could also choose to ignore. In either case, shouldn't the validation be left to pre-commit hook (for the tree) and commit-msg hook (for the message, that is left after this hook)?

> While the default hook just adds a Signed-Off-By line at the bottom
It's "s/[OB]/ob/;", and ...
Show 5 quoted lines
> of the commit messsage, the hook is more intended to build a template
> for the commit message following project standards, that the user
> can then edit or discard altogether.
>
> Signed-off-by: Paolo Bonzini <bonzini@gnu.org>
... you know it ;-)
Previous: Paolo BonziniNext: Paolo Bonzini
Message 7 of 13 in “git-commit: add a prepare-commit-msg hook”
  1. git-commit: add a prepare-commit-msg hookPaolo Bonzini, Jan 21, 2008
  2. 1/4 git-commit: support variable number of hook argumentsPaolo Bonzini, Jan 21, 2008
  3. Johannes SchindelinFeb 4, 2008
  4. Junio C HamanoFeb 5, 2008
  5. 2/4 git-commit: set GIT_EDITOR=: if editor will not be launchedPaolo Bonzini, Jan 21, 2008
  6. 4/4 git-commit: add a prepare-commit-msg hookPaolo Bonzini, Jan 21, 2008
  7. Junio C HamanoFeb 5, 2008
  8. 3/4 git-commit: Refactor creation of log message.Paolo Bonzini, Jan 21, 2008
  9. Johannes SchindelinFeb 4, 2008
  10. Paolo BonziniFeb 4, 2008
  11. Junio C HamanoFeb 5, 2008
  12. Junio C HamanoFeb 5, 2008
  13. Paolo BonziniFeb 5, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.