threads / discuss / 53964

amend param not available to the pre-commit hook

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

## tl;dr

2 messages between Aug 2, 2020 and Aug 2, 2020.

replies: 1people: 2as markdown or json

Andrea Wyss· Aug 2, 2020, 13:22 UTC · lore
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'

Please, let me know if you need other info. I'm looking forward for a fix or workaround.

Thank you, Andrea Wyss

Phillip Wood· Aug 2, 2020, 15:10 UTC · re: Andrea Wyss · lore

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

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
> 

← back to recent threads