On 03/02/2013 04:55 AM, Paul Menzel wrote:
Do you know of other solutions? For example, how do other projects handle this?
For the EC code at OLPC we had similar problems. It was really bad for a while because we were forced to use the Keil development environment under a windows VM and thus also had to deal with line ending conversions. Eventually we figured out how to run the command line compiler via wine and things got _so_ much nicer.
Our solution was that all code must pass through astyle with a formatting specifier that we agreed on.
http://astyle.sourceforge.net/
Astyle formatting is not perfect and there are a few formatting things it does that we just had to accept. Also there were a few releases where astyle really mangled the code. We require a specific version statically built and checked into the repository.
There was a flag day where we re-formatted the entire repository with astyle and then went from there. Its pretty configurable so there wasn't actually too much churn as it almost exactly matched the existing style.
How could that be solved elegantly? On the editor level, “git hook” level or can Gerrit be setup to do this?
You can set up git to run it on all commits and reject anything that astyle says it had to reformat. But we choose to let that be done by humans. The EC team at OLPC is small enough that if one dev forgets to run astyle before pushing patches we can whine at him. In a much larger project I can seen the need auto rejecting it if astyle changes it.