Use astyle to minimize 'noise' diffs

I thought this may be one of these things that are better posted in the forum first rather than opening a new issue in Mantis :slight_smile:

I want to suggest some (semi?) automated way of formatting the code according to some style that the main coders here agree on.

It does not really matter (to me anyway) WHAT the exact style is - the idea is to minimize ‘noise’ diffs resulting from some guy’s editor using tabs and another’s using spaces or some editor removing trailing spaces at the end of the line while some other editor not caring about it. Things like that.

I am a git guy and dunno much about svn so I would not know how to make svn do this automatically. We could just use a script file for starters… (btw - you guys don’t want to switch to git? It’s got branches and nice tools both cli and gui, and is lightning FAST :wink: NO? ok, ok… :slight_smile: ).

Based on those source files that I have worked with it, it seems to me that the predominant code style is best matched by these astyle options:

$ astyle --style=allman --lineend=windows --unpad-paren --indent=force-tab --min-conditional-indent=0 --indent-cases --break-blocks  --pad-oper --indent-namespaces --keep-one-line-statements --keep-one-line-blocks <src-file>

For code style I think you’re looking for this:
Personally I don’t ‘see’ problems with diffs. Literally. Most diff viewers can ignore whitespace changes.
Tabs\spaces - it’s possible that there are some places with spaces but 99% of code have tabs. So space -> tabs conversion is OK.

git - just one question: why? SVN works fine, our team is quite small so we’re going fine with single trunk without large amount of conflicts. Speed? I use SVN once or twice per day at most so I don’t care if update or commit takes 5 seconds or 20.

Regarding git - it was more of a joke… I understand that if something does the job and people have gotten used to it then there’s little point in changing it. I see what you’re saying about SVN being quite adequate for your needs, and I guess the ONLY thing that I REALLY don’t like about svn is that it puts those damn .svn directories everywhere…

Regarding code style - thanks, I’ll do my best to format any code I contribute in accordance with this. I did not know that there is such written guidelines regarding the coding style in VCMI. And since there is - my personal opinion is that using astyle , or some other way of automatically formatting the code is simply a must: otherwise it’s like having laws which no one obeys (not that there aren’t many countries like this, mine including :slight_smile: But its usually not a very safe place to live in, hehe ).

It will be real easy to follow the wiki doc and to generate a set of astyle rules and then it’s problem solved - run the script and your code is formatted according to the guidelines. I think that it will be a good thing and a logical extension of the wiki doc to have these guidelines enforced in some way…

Update your svn.