This will add a python convenience wrapper for clang-format. The python code includes a list with tested versions (tested_versions) which can easily be updated in the future.
[ci skip]
This will add a python convenience wrapper for clang-format. The python code includes a list with tested versions (tested_versions) which can easily be updated in the future.
[ci skip]
Not sure if possible: a script that only clang-formats changed/added code (would require some clever git operations) would be nice.
@jonasschnelli Not sure if clang-format-diff.py is what you are looking for.
After looking at the amount of changes clang-format generates and actually looking at such changes and looking at our release process (releasing 0.10, 0.11, ...), I think it doesn't make sense to apply the formatting in one shot for all the source files.
It only has sense for formatting new files and (maybe) for very stable files, like primites/* etc.
And as written above, I do not think the wrapper (in fact, -i and "tested" version check) is needed at all.
@paveljanik I think it doesn't make sense to apply the formatting in one shot for all the source files.
I think we all agree on this.
@paveljanik I do not think the [...] "tested" version check is needed at all.
How would one verify a format PR when different versions produce different output? Also, it may be useful the extend the clang-format.py to skip git subtrees et al. (c.f. https://github.com/sipa/bitcoin/commit/a1261296e48967b3236053d3435a3f521898df2f#diff-6ca10bb3f43dbe234b1fce27929ce0d4R10 ).
Code review ACK, although I'm not sure I see when this should be used.
Needs mention in contrib/devtools/README.md
Earlier reasons to not use clang-format was that its output changed, even between several "versions" of clang-format-3.5. I wonder whether a solution could be to include a small snippet of representative unformatted code, and have the wrapper script check whether it results in the expected output?
It should definitely be used when committing new files...
I wonder whether a solution could be to include a small snippet of representative unformatted code, and have the wrapper script check whether it results in the expected output?
I like this idea a lot.