<div dir="ltr"><div dir="ltr">On Tue, Aug 10, 2021 at 1:32 PM Ben Boeckel <<a href="mailto:ben.boeckel@kitware.com">ben.boeckel@kitware.com</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Tue, Aug 10, 2021 at 13:13:09 +0200, Manuel Klimek via cfe-dev wrote:<br>
> clang-format is designed to run on changed lines, not to have all code be<br>
> compliant. You can use it for the latter, but I think it's a pretty<br>
> fundamental difference in development goals.<br>
<br>
The problem I've seen is that the opinion of code formatted with 3 lines<br>
of context can differ from 5 lines of context which can be still<br>
different again given the entire file. The only reliable way we've<br>
gotten it to work is to format the whole file every time. But we require<br>
well-formatted code via CI processes, so that's fine (if one can afford<br>
the "rewrite the world" every time the tool gets updated…hence why some<br>
projects are still on version 3.8(!), others 6, some even made it to 9).<br></blockquote><div><br></div><div>The underlying design idea for clang-format is to give it the whole file as *context*, but only *format* the changed lines.</div><div>clang-format supports that use case very well, and it can even be built into presubmit checks.</div><div><br></div></div></div>