Using strace I noticed that git-revert invokes only two hooks:
- prepare-commit-msg
- post-commit
But git-commit invoke these four:
- pre-commit
- prepare-commit-msg
- commit-msg
- post-commit
Since git-revert produces a commit, why doesn't it invoke the same hooks as git-commit?
I asked this on the Git mailing list but got no response. So I'm asking here.
I ended up researching this when I was implementing a hook to detect and deny commits which revert merge-commits, since they are troublesome.
I tried to implement it as a commit-msg hook to search for the string "This reverts commit SHA-1" in the commit message. But git-revert doesn't invoke the commit-msg hook.
So, for now I implemented my check as a pre-receive hook. But I find it useful to have all pre-receive checks implemented also as a pre-commit or a commit-msg hook so that I can detect problems at commit time instead of only at push time.