[PATCH] D54881: [clang-format] Prevent Clang-Format from editing leading whitespace on lines outside of the format range

Russell McClellan via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 21 15:02:11 PDT 2019


russellmcc added a comment.

Sorry for the ambiguity.  I meant, "running clang-format on the changed lines locally was not enough".  I'll edit the description to clarify.

To go in more detail, let's imagine you changed line 3.  You run clang-format locally on line 3, but because of the bug fixed in the patch, this affects lines 3 and 4.  Then, when you commit and push to CI, CI will see diffs on lines 3 and 4.  CI will then try to ensure that running clang-format on line range 3-4 will produce no diffs.  However, due to the same bug will produce a diff on line 5, so your code will be rejected by the CI.

The reason our CI works like this is we want to ensure that no _new_ formatting errors are introduced into our code.  We're extensive users of git blame and we don't want to do a full format pass on our whole codebase.  Clang-format documents its line filter option, so in my opinion, it should work correctly.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54881/new/

https://reviews.llvm.org/D54881





More information about the cfe-commits mailing list