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

Re: amend param not available to the pre-commit hook

From
PWPhillip Wood <phillip.wood123@gmail.com>
Date
Aug 2, 2020, 15:10 UTC
Message-ID
<f9016e7a-0769-6a55-ab32-6b54674ae2c1@gmail.com>
In-Reply-To
<30DFCBF3-FEA8-4FF5-94ED-A81AB10B04A3@gmail.com>
Hi Andrea
On 02/08/2020 14:22, Andrea Wyss wrote:
Show 18 quoted lines
> Issue
> amend param not available to the pre-commit hook
> 
> Problem
> Cannot write a pre-commit hook that stops amending a commit that is present in other branches.
> 
> Steps to Reproduce (git version 2.21.1)
> 1. Code in the pre-commit hook:
>    echo "DEBUG 0='$0' 1='$1'"
> 
> 2. run:
>    git commit --amend
> 
> Current Result
>    DEBUG 0='.git/hooks/pre-commit' 1=''
> 
> Expected Result
>    DEBUG 0='.git/hooks/pre-commit' 1='--amend'

I'm not sure why you expect this, the documentation for the pre-commit hook states 'this hook takes no parameters'

That does not mean that it would not be useful to have this information available to the pre-commit and possibly prepare-commit-msg hooks but it is not a bug. I'm not sure that adding a parameter to the hook is a good route as it may break existing hooks that do not expect any parameters, maybe we could pass it in the environment.

Best Wishes
Phillip
Show 6 quoted lines
> Please, let me know if you need other info.
> I'm looking forward for a fix or workaround.
> 
> Thank you,
> Andrea Wyss
> 
Previous: Andrea Wyss
Message 2 of 2 in “amend param not available to the pre-commit hook”
  1. Andrea WyssAug 2, 2020
  2. Phillip WoodAug 2, 2020

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.