Pre-commit hook does not stash unstaged changes before running code style checkers
How to reproduce:
- Make some changes to C files and violate whitespace rules.
-
git add
affected files and try togit commit
. Pre-commit hook will not allow it and will print the whitespace issues it found. - Fix whitespace problems, but forget to
git add
the files. - Running
git commit
again does not reject the changes, despite whitespace fixes not being staged. New commit now includes whitespace violations and none of the fixes that were done in step 3.
This is not limited to whitespace issues, but could affect other code style checks as well.