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

Should commit-msg hook receive the washed message?

From
Sean Allred <allred.sean@gmail.com>
Date
Jul 5, 2024, 20:12 UTC
Message-ID
<m0h6d3pphu.fsf@epic96565.epic.com>
From githooks.txt:
Show 5 quoted lines
> This hook is invoked by linkgit:git-commit[1] and
> linkgit:git-merge[1], and can be bypassed with the `--no-verify`
> option. It takes a single parameter, the name of the file that holds
> the proposed commit log message. Exiting with a non-zero status causes
> the command to abort.

Of course the actual 'proposed commit log message' doesn't include the comments included when running a commit, e.g.

    git -c commit.status=true commit

but the execution of the `commit-msg` happens before `cleanup_message` is called on COMMIT_EDITMSG.

This seems like a bug to me; is there something I'm missing? I would propose adding a call to `cleanup_message` (with the appropriate arguments) inside `prepare_to_commit` right before `commit-msg` is invoked.

It's causing us quite a bit of grief (e.g. with external tools that invoke hooks incorrectly [1] + some other internal workarounds for things like patch scissors).

Thanks, -Sean

[1]: https://lore.kernel.org/git/17df67804ef7a3c8.df629cdadcf4ea15.524a056283063601@EPIC94403/
-- 
Sean Allred
Next: Eric Sunshine
Message 1 of 3 in “Should commit-msg hook receive the washed message?”
  1. Sean AllredJul 5, 2024
  2. Eric SunshineJul 5, 2024
  3. Jeff KingJul 6, 2024

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.