git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Sebastian Schuberth <sschuberth@gmail.com>
Date
Jan 24, 2012, 14:16 UTC
Message-ID
<jfmegi$scg$1@dough.gmane.org>
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
Next: Stefan Haller
Message 1 of 2 in “Most reliable method to detect a merge commit in pre-commit hook”
  1. Sebastian SchuberthJan 24, 2012
  2. Stefan HallerJan 24, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.