Can anyone recommend an approach to have my Git repo reject commits if the Java code being committed doesn't conform to a predefined coding standard. I'm fed up of seeing a mix of tabs and spaces and a commit log with entries such as 'Converting tabs to spaces'.
I have Eclipse configured to automatically perform formatting on save, but I realised that I had a different set-up across two machines, so I decided I wanted this built into my version control to save me from having to check my Eclipse configuration each time. I am also open for debate as to whether or not the formatting should just be applied automatically on commit rather than rejecting the commit.
Also interested in opinions on whether or not I should include coding styles in this too, such as rejecting for loops that don't use the for-each syntax etc.