git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* Why git-revert doesn't invoke the pre-commit and the commit-msg hooks?
@ 2018-02-13 22:27 Gustavo Chaves
  2018-02-19 14:50 ` Gustavo Chaves
  0 siblings, 1 reply; 5+ messages in thread
From: Gustavo Chaves @ 2018-02-13 22:27 UTC (permalink / raw)
  To: git

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 couldn't find any discussing about this in the list or elsewhere. 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 (https://www.kernel.org/pub/software/scm/git/docs/howto/revert-a-faulty-merge.html).
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.

-- 
Gustavo Chaves

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-02-21 13:34 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-13 22:27 Why git-revert doesn't invoke the pre-commit and the commit-msg hooks? Gustavo Chaves
2018-02-19 14:50 ` Gustavo Chaves
2018-02-20 10:28   ` Phillip Wood
2018-02-20 18:00     ` Junio C Hamano
2018-02-21 13:33       ` Gustavo Chaves

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).