> -----Original Message-----
> From:
repo-d...@googlegroups.com <
repo-d...@googlegroups.com>
> On Behalf Of Abhineet Chaudhary
> Sent: den 15 juni 2022 08:31
> To: Repo and Gerrit Discussion <
repo-d...@googlegroups.com>
> Subject: commit-msg hook tries to add a new ChangeId in footer even
> when the git commit his in -amend mode
>
> The gerrit's commit-msg hook executes the line trying to add the
> ChangeId in the footer for the commit message even when a previous
> commit is being amended.
>
> Command used for commit:
> git commit --amend
>
> Although, the ChangeId in this case does not get changed in Gerrit
> Review from the previous commit; we keep a record of these ChangeIds
> in a local file associated to each revision and its an issue in our
> usecase as the commit-msg hook overwrites the existing changeId in
> our file.
>
> Is this expected?
While I can't speak for others, I regularly use `git commit --amend` to
add a missing Change-Id. E.g., if you do `git revert`, Git will not run
the commit-msg hook and you have to use `git commit --amend` to add one.
> Also is there a way to find out whether the commit is trying to amend
> a previous commit or create a new one?
AFAIK, no. At least not in a simple way.
//Peter