{"thread":{"id":"29437","subject":"Most reliable method to detect a merge commit in pre-commit hook","startedAt":"2012-01-24T14:16:40Z","lastAt":"2012-01-24T15:10:48Z","messageCount":2,"participants":["Sebastian Schuberth","Stefan Haller"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"183016","messageId":"jfmegi$scg$1@dough.gmane.org","threadId":"29437","inReplyTo":null,"subject":"Most reliable method to detect a merge commit in pre-commit hook","fromName":"Sebastian Schuberth","fromEmail":"sschuberth@gmail.com","sentAt":"2012-01-24T14:16:40Z","receivedAt":"2012-01-24T14:16:40Z","isPatch":false,"sender":{"key":"sschuberth@gmail.com","avatar":"https://avatars.githubusercontent.com/u/349154?v=4"},"body":"Hi,\n\nI'd like our pre-commit hook to skip some checks if the commit that's \nabout to be made is a merge commit. What's the most reliable way to \ndetect a merge commit from within a pre-commit hook script? Currently, \nthe only way I see is to check whether .git/MERGE_MSG exists, but I'd \nfeel safer to check whether the commit is going to have more than one \nparent or so. Is that possible / a better detection?\n\n-- \nSebastian Schuberth\n"},{"id":"183017","messageId":"1kedu51.n7co6x1s8qhdbM%lists@haller-berlin.de","threadId":"29437","inReplyTo":"jfmegi$scg$1@dough.gmane.org","subject":"Re: Most reliable method to detect a merge commit in pre-commit hook","fromName":"Stefan Haller","fromEmail":"lists@haller-berlin.de","sentAt":"2012-01-24T15:10:48Z","receivedAt":"2012-01-24T15:10:48Z","isPatch":false,"sender":{"key":"lists@haller-berlin.de","avatar":null},"body":"Sebastian Schuberth <sschuberth@gmail.com> wrote:\n\n> I'd like our pre-commit hook to skip some checks if the commit that's\n> about to be made is a merge commit. What's the most reliable way to \n> detect a merge commit from within a pre-commit hook script? Currently,\n> the only way I see is to check whether .git/MERGE_MSG exists, but I'd\n> feel safer to check whether the commit is going to have more than one\n> parent or so. Is that possible / a better detection?\n\nI haven't found a better way either, so this is the method we use too.\nThe problem is that it fails when you are amending a merge commit; so\nthe output of our pre-commit hook advises the user to manually do a \"git\ncommit --no-verify\" in that case.\n\n\n-- \nStefan Haller\nBerlin, Germany\nhttp://www.haller-berlin.de/\n"}]}