Trying to make a php syntax check hook for a git repository. I was happy when I found a snipped that does exactly this.
But it seems that the snippet script has a flaw. It executes
git diff-index --cached --name-only HEAD
to get a list of files in the index. Now it runs php -l for each file on that list. The flaw is that a file might differ between the working copy and the staging area. If the staging area php has a syntax error, but the working copy version doesnt, no syntax error is found and the committ succeeds which was the thing to prevent.
Is this a nontrivial problem to solve, or is there some way to run php -l on the staging-version of each file?