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

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

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 17, 2021, 19:43 UTC
Message-ID
<xmqqmtobgf7m.fsf@gitster.g>
In-Reply-To
<874kajdmsh.fsf@evledraar.gmail.com>
Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
> I'd think we'd want to call it on an empty message, e.g. maybe someone
> depends on that with empty message = auto-generate a message for me.

I tend to agree with you that, especially if we are to keep the "commit-msg hook is allowed to change the message, even though it is a job for other hooks", we should invoke it even on an empty file.

Show 7 quoted lines
> But for those that don't, doesn't the default behavior of "git commit"
> catch this in either case, i.e. it wouldn't let it pass without
> --allow-empty-message.
>
> I understood this report as the hook taking the empty message (e.g. the
> user using it as a shorthand to abort), and their hook "helpfully"
> inserting some "default" message or template.

My understanding largely overlaps with yours but with some differences.

They do not fall into either of the two camps. Their hook does futz with the message indiscriminately and adds some boilerplate material blindly, even to an empty file.

The complaint is "the message is otherwise without any substance, but because the hook blindly added some boilerplate material into the empty original, it appears to be non-empty and fails to trigger the --no-allow-empty-message machinery."

Previous: Ævar Arnfjörð BjarmasonNext: Kurt von Laven
Message 4 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.