{"thread":{"id":"46879","subject":"hooks are ignored if there are not marked as executable","startedAt":"2017-10-02T10:06:35Z","lastAt":"2017-10-02T22:51:04Z","messageCount":2,"participants":["Damien","Jonathan Nieder"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"329427","messageId":"CAAQ5yigO8FxhUjwr68OnW0UEYck2AKF5P0Qt_zedhBL_SEiKTw@mail.gmail.com","threadId":"46879","inReplyTo":null,"subject":"hooks are ignored if there are not marked as executable","fromName":"Damien","fromEmail":"damien@dam.io","sentAt":"2017-10-02T10:06:09Z","receivedAt":"2017-10-02T10:06:35Z","isPatch":false,"sender":{"key":"damien@dam.io","avatar":"https://avatars.githubusercontent.com/u/1469823?v=4"},"body":"Hi,\n\nIf you do `echo my_script > .git/hooks/pre-commit` and then `git commit`,\nThe hook is just gonna be ignored.\nBut if you do `chmod +x .git/hooks/pre-commit`, then it's executed.\n\nI think ignoring a hook is misleading and not newbie friendly, an error\nmessage to signal an incorrectly configured hook could be better.\nAt least as a warning to be backward-compatible.\n\nThanks,\nDamien\n"},{"id":"329486","messageId":"20171002225056.GS19555@aiede.mtv.corp.google.com","threadId":"46879","inReplyTo":"CAAQ5yigO8FxhUjwr68OnW0UEYck2AKF5P0Qt_zedhBL_SEiKTw@mail.gmail.com","subject":"Re: hooks are ignored if there are not marked as executable","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2017-10-02T22:50:56Z","receivedAt":"2017-10-02T22:51:04Z","isPatch":false,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Hi Damien,\n\nDamien wrote:\n\n> If you do `echo my_script > .git/hooks/pre-commit` and then `git commit`,\n> The hook is just gonna be ignored.\n> But if you do `chmod +x .git/hooks/pre-commit`, then it's executed.\n\nThis is intentional.\n\n> I think ignoring a hook is misleading and not newbie friendly, an error\n> message to signal an incorrectly configured hook could be better.\n\nAdding a warning sounds like a nice change.  Care to propose a patch?\n\nIn the early days, sample hooks were installed without .sample in\ntheir filename and could be enabled by \"chmod +x\"-ing them.  Because\nof this, long-time users of Git may find themselves experiencing this\nwarning more often than they'd like.  That could be acceptable if the\nwarning shows a command to run to prevent the warning from showing up\nagain, though (see advice.c for some examples of how that can be\ndone).\n\nThe main code path to look at is run-command.c::find_hook.\n\n\"git grep -e 'rev-parse --git-path hooks' -- . ':!contrib'\" finds a\nfew other code paths you may also want to look at.\n\nThanks and hope that helps,\nJonathan\n"}]}