Jeff Atwood wrote about whitespace and suggested creating commit hook which removes trailing whitespace at the ends of lines and files.
I've searched, but I haven't found a clear example of using a pre-commit hook to modify files like this. Do you have a script which you'd like to share?
I'm pretty sure that pre-commit hooks can't be used to modify the transaction in progress. It can only allow or deny the commit action. In your case, you'd want to examine the files to see if they meet your whitespace requirements and fail the commit with a useful error message if they do not. You could use a post-commit hook to do what you propose, but it would involve making a second commit from the hook script to fix the bad whitespace in the first commit. I think the pre-commit hook approach is better.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With