Hello all,
Yes, thank you! The first half hour of the talk exactly described my experience, and my arguments above:
- formatting is much more than indenting
- clang-format is amazing
- it saves developers a lot of time
I'm inclined to make the first half hour of this talk "required reading" to participate in this discussion...
Done so (yesterday). I agree with the statement that when refactoring code one should really use clang-format. I certainly have had exactly the experience described in the talk, however in my case I had to merge a diverged branch back into master and the diverged branch author had changed indentation all over the place. Having had an agree upon and automatically enforced formatting style with have simplified this work enormously.
So, I change my mind and agree that using clang-format even for Carpet would be good (hoping that indeed there will be refactoring and simplification of the code to follow). It would be less disruptive if clang-format was used only for new commits yet this may not be practical since its formatting will likely look different from what we currently use.
Before reformatting the "official" Carpet codebase I would try it out first and add a custom clang-format option set to handle CCTK_LOOP and BEGIN_XXX macros properly.
To support 'diff' I would suggest for users to make a always-used-clang-format copy of their repository like so:
for b in `git branch | awk '/master/||/AMRToy/{next} {print $NF}'` ; do echo $b rm -rf .git-rewrite * git checkout -f $b git filter-branch --tree-filter \ 'find . -name *.[hc][hc] -print0 | xargs --null clang-format-3.5 --style=llvm -i' $b rm -r .git/refs/original/ done
which takes however about 1.5hrs per branch and skips the branches listed in the awk command. One can then bisect on this repo.
To rebase current development branches onto a reformatted master one can do (eg for a branch "map"):
BRANCH=map
BRANCHPOINT=$(git rev-list origin/master..$BRANCH | tail -n1) git filter-branch --tree-filter 'find . -name *.[hc][hc] -print0 | xargs --null clang-format-3.5 --style=llvm -i' $BRANCHPOINT~2..$BRANCH
BRANCHPOINT=$(git rev-list origin/master..$BRANCH | tail -n1) git rebase --onto master $BRANCHPOINT $BRANCH
where the "~2" makes sure that all of the original $BRANCHes commits appear on to of a reformatted source tree. This will fail if there are merges happening to close to the branching points.
Yours, Roland