`git cl format` will reorder includes in blocks of #includes
that are not separated by newlines.
This works in almost all cases, but it can break some code, e.g.:
#include <windows.h>
#include <shellapi.h>
clang-format will reorder these now, but shellapi.h only compiles if
windows.h was included first. Relying on this is brittle, so replace
code like this with
#include <windows.h>
// Must be after windows.h:
#include <shellapi.h>
Since clang-format doesn't reorder across blocks, this will do the right
thing.
This also means you're still on the hook of putting blocks with user headers,
C++ headers, and C headers in the right order.
This will hopefully replace src/tools/sort-headers.py which contains
some hacky heuristics -- just inserting newlines between includes
when needed (with a comment) seems like a better tradeoff anyhow.
And the automatic integration with `git cl format` is nice.
(clang-format has IncludeIsMainRegex and IncludeCategories for adding
heuristics, but we shouldn't use these, they're too complicated.)
for now. If you think this is useful, or if it causes you problems, please let
me know. Based on feedback, I'll make a call if we should this enabled in
four weeks or so. (Unless it breaks the world somehow, in that case I'll