Issue 843: commit-msg hook doesn't add new Change-Id line in revert commits
Status:  Accepted
Owner: ----
Cc:
skan...@codeaurora.org
Reported by nas...@chromium.org, Feb 14, 2011
Affected Version: 2.1.6.1

What steps will reproduce the problem?
1. Create, Upload, Review and Submit a change with a Change-Id line in the commit message
2. Revert that change locally using 'git revert'

What is the expected output? What do you see instead?
Expected a new Change-Id line but instead the commit-msg hook assumes the line from the reverted commit message is for this change.
May 13, 2011
#1 c.david86@gmail.com
This is also the case with a fast-forward merge commit.

To workaround, just amend the merge commit with the Change-Id hook enabled.
May 20, 2011
Project Member #2 nas...@grainawi.org
Using the new Revert button (2.1.7) is another workaround. Writing a second hook only for git-revert that fixes up the Change-Id is the only other solution I can think of.
Status: Accepted
Dec 15, 2011
#3 jrobert...@gmail.com
I'm here for the "no ChangeId when I merge" problem as mentioned in comment #1. Should this be a separate ticket?
Sep 7, 2012
#4 eResona...@gmail.com
I looked into this a tiny bit and it's very annoying. The commit-msg hook is only used for git-commit, not for all git programs that may use the git committing plumbing.

It appears git-revert does not invoke the commit-msg hooks:
http://git.661346.n2.nabble.com/git-revert-doesn-t-run-commit-msg-hook-td7559622.html
(similar discussion: http://git.661346.n2.nabble.com/cherry-pick-pre-commit-hook-td5815961.html)

My workaround is to use:
git revert -n <commit>
git commit

Which will then invoke commit-msg, which in-turn adds the Change Id line to the message.

I'm using git version 1.7.11.2

Jul 10, 2014
#5 sschuberth
I guess comment #1 should say "This is also the case for merges without conflicts" (i.e. those that do not invoke the editor), as a fast-forward merge by definition does not create a merge commit.