Most reliable method to detect a merge commit in pre-commit hook

2 messages, 2 authors, 2016-06-15 · open the first message on its own page

Most reliable method to detect a merge commit in pre-commit hook

From: Sebastian Schuberth <hidden>
Date: 2016-06-15 22:52:51

Hi,

I'd like our pre-commit hook to skip some checks if the commit that's 
about to be made is a merge commit. What's the most reliable way to 
detect a merge commit from within a pre-commit hook script? Currently, 
the only way I see is to check whether .git/MERGE_MSG exists, but I'd 
feel safer to check whether the commit is going to have more than one 
parent or so. Is that possible / a better detection?

-- 
Sebastian Schuberth

Re: Most reliable method to detect a merge commit in pre-commit hook

From: Stefan Haller <hidden>
Date: 2016-06-15 22:52:51

Sebastian Schuberth [off-list ref] wrote:
I'd like our pre-commit hook to skip some checks if the commit that's
about to be made is a merge commit. What's the most reliable way to 
detect a merge commit from within a pre-commit hook script? Currently,
the only way I see is to check whether .git/MERGE_MSG exists, but I'd
feel safer to check whether the commit is going to have more than one
parent or so. Is that possible / a better detection?
I haven't found a better way either, so this is the method we use too.
The problem is that it fails when you are amending a merge commit; so
the output of our pre-commit hook advises the user to manually do a "git
commit --no-verify" in that case.


-- 
Stefan Haller
Berlin, Germany
http://www.haller-berlin.de/
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help