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

Re: commit-msg hook possible bad behavior with -F <file>

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Dec 18, 2017, 18:31 UTC
Message-ID
<CAPig+cTmRiSfY9+DsvEB7X_cL4AiAmq0FUb-CoDyc3HNDJLtow@mail.gmail.com>
In-Reply-To
<CAJ4+5mHMD+yW1ZDD6KJSnMtyygLUGiHzNPgPDZUi7+KUvOczkg@mail.gmail.com>
On Mon, Dec 18, 2017 at 11:43 AM, Seth Raymond <seth.c.raymond@gmail.com> wrote:
Show 7 quoted lines
> If a commit is invoked with -F <file>, indicating that the commit
> message should be read from an existing file, the the
> prepare-commit-msg and commit-msg hooks do not operate on <file>. The
> first argument to the hook is always <git_repo>/COMMIT_EDITMSG, rather
> than <file>.
>
> Am I wrong in this line of thinking?

The content of <file> gets copied into COMMIT_EDITMSG, so the hook does see the supplied message, as expected. Given that the hook is allowed to edit the message, it makes sense that it works on COMMIT_EDITMSG rather than on <file> directly.

Previous: Seth RaymondNext: Seth Raymond
Message 2 of 3 in “commit-msg hook possible bad behavior with -F <file>”
  1. Seth RaymondDec 18, 2017
  2. Eric SunshineDec 18, 2017
  3. Seth RaymondDec 18, 2017

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.