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

Don't Call commit-msg Hooks With Empty Commit Messages

From
Kurt von Laven <kurt.von.laven@gmail.com>
Date
Sep 17, 2021, 03:37 UTC
Message-ID
<CAO-Ogzs7vCtfgjZqp+cg1ERiu3bSwZM47arHJyyTrEqAQ=ZLcw@mail.gmail.com>
Hello,

The most common reason commit messages are left empty is to abort them. commit-msg hooks that replace empty commit messages with non-empty ones (i) make it impossible to abort commits, (ii) are startling to developers joining a project configured in this manner, and (iii) can offer no value that wouldn't be equally or better offered another way. For instance, a default commit message would be better implemented as a commit message template or prepare-commit-msg hook. I propose that Git eventually cease calling commit-msg hooks when the commit-message is empty, but I would understand if backwards compatibility were the overriding concern. On the other hand, the empty commit message case is easy to overlook when crafting a commit-msg hook. One consequence of this behavior is that running the popular pre-commit tool (https://pre-commit.com/) tends to lead to a spew of false positives to the console on an aborted commit when configured with commit-msg hooks.

Be well, Kurt von Laven

Next: Junio C Hamano
Message 1 of 6 in “Don't Call commit-msg Hooks With Empty Commit Messages”
  1. Kurt von LavenSep 17, 2021
  2. Junio C HamanoSep 17, 2021
  3. Ævar Arnfjörð BjarmasonSep 17, 2021
  4. Junio C HamanoSep 17, 2021
  5. Kurt von LavenSep 18, 2021
  6. Kurt von LavenSep 19, 2021

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.