Reputation: 379
I have a pre-commit hook that when I run returns this error:
error: cannot spawn .git/hooks/pre-commit: No error
I have a #!/bin/sh
at the top and have definitely used chmod +x
on it. However, those appear to be fixes for when there is a no such file or directory error. My error simply says No error
and I cannot work out why.
Code in the hook:
#!/bin/sh
changes() {
git diff --name-only --diff-filter=AMDR --cached @~..@
}
if changes | grep -q dirname {
echo "Test"
}
Upvotes: 2
Views: 2264
Reputation: 1329492
Check first, as in here, if your script does have a final newline.
Its absence would trigger a "no error" message.
Check also the eol style (end of line): LF is prefered for those bash script.
The OP compsciman confirms in the comments that switching to Git For Windows 2.26 from 2.21 solved the issue.
The only recent modification to pre-commit
involves the removal of git config --bool
option (commit 81e3db4) that I mentioned in "How to color the Git console?".
Upvotes: 2