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

Re: [PATCH] commit: abort before commit-msg if empty message

From
Junio C Hamano <gitster@pobox.com>
Date
Dec 8, 2018, 05:44 UTC
Message-ID
<xmqqin048te8.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<20181207224817.231957-1-jonathantanmy@google.com>
Jonathan Tan <jonathantanmy@google.com> writes:
Show 9 quoted lines
> When a user runs "git commit" without specifying a message, an editor
> appears with advice:
>
>     Please enter the commit message for your changes. Lines starting
>     with '#' will be ignored, and an empty message aborts the commit.
>
> However, if the user supplies an empty message and has a commit-msg hook
> which updates the message to be non-empty, the commit proceeds to occur,
> despite what the advice states.

When "--no-edit" is given, and when commit-msg fills that blank, the command should go ahead and record the commit, I think.

An automation where commit-msg is used to produce whatever appropriate message for the automation is entirely a reasonable thing to arrange. Of course, you can move the logic to produce an appropriate message for the automation from commit-msg to the script that drives the "git commit" and use the output of that logic as the value for the "-m" option to achieve the same, so in that sense, there is an escape hatch even if you suddenly start to forbid such a working set-up, but it nevertheless is unnecessary busywork for those with such a set-up to adjust to this change.

I actually think in this partcular case, the commit-msg hook that adds Change-ID to an empty message is BUGGY. If the hook looked at the message contents and refrains from making an otherwise empty message to non-empty, there is no need for any change here.

In any case, you'll have plenty of time to make your case after the rc freeze. I am not so sympathetic to a patch that makes us bend backwards to support such a buggy hook to e honest.

Previous: Jonathan NiederNext: Jonathan Tan
Message 3 of 4 in “commit: abort before commit-msg if empty message”
  1. commit: abort before commit-msg if empty messageJonathan Tan, Dec 7, 2018
  2. Jonathan NiederDec 7, 2018
  3. Junio C HamanoDec 8, 2018
  4. Jonathan TanDec 11, 2018

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.