Developer Fixed Same Git Hook Three Times Without Ever Testing If Git Ran It
A developer discovered that a Git prepare-commit-msg hook in their repository had been debugged and declared 'verified live' three separate times, yet none of the fixes ever confirmed whether Git actually invoked the hook. Each verification tested the hook script's internal path logic directly, bypassing the prior question of whether Git would choose to execute the file at all. The root cause turned out to be unrelated to any of the three fixes: the hook file was committed without the executable bit set (mode 100644 instead of 100755), which Git requires before it will run any hook. Because Git tracks file permission modes in the repository tree, every fresh clone reproduced the non-executable state, silently skipping the hook with an easy-to-miss hint message. A secondary install method that copies the hook and runs chmod +x worked correctly all along, but the README's recommended method of pointing core.hooksPath directly at the tracked hooks directory had never functioned through any of the three rounds of fixes.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in