[PATCH for comments] configure: install a whitespace checking pre-commit hook for developers

Uri Simchoni uri at samba.org
Tue Apr 10 09:39:06 UTC 2018

On 04/10/2018 12:03 PM, Douglas Bagnall via samba-technical wrote:
> On 10/04/18 18:30, Ralph Böhme wrote:
>> On Mon, Apr 09, 2018 at 08:44:10AM -0700, Jeremy Allison via samba-technical wrote:
>>> Thanks very much Douglas, this looks like it might be a great
>>> solution that works for all ! Thanks very much for helping out
>>> with this contentious issue.
>>> I'll test it out and push if happy.
>> +1 from my side.
>> Wonder whether we still need the more complex checking tool from Simo given that
>> the original issue that started the outrage would be addressed by Douglas'
>> patch.
> I think there is a place for a more sophisticated tool that can be run manually.
> I haven't looked closely at Simo's patch, but it sounds like it has pedigree. 
> When I am reviewing or working on python files, I quite often run flake8 to see
> what it says. I don't always agree. It would be nice to have a similar thing for C.
> It is sometimes more interesting for a tool to be opinionated than authoritative.

IMHO the one-stop-shop for an opinionated formatting tool for C is

- The samba-conformant configuration is in README.Coding
- It does whitespace (end-of-line, tab), alignment, 80-column, space
between variables and operators, you name it. Being based on a compiler,
it probably does a better job than any hand-crafted script.
- Combined with the git-clang-format git add-on, doing "git
clang-format" will only re-format the changed lines.
- I mostly take its edits as-is. Only place where I consistently
disagree is in initialized arrays of popt options - it's not necessarily
incorrect but the new option has to be consistent with other options.
This is an example of where the automatic formatting doesn't work though.

So my workflow for a single commit is:
- add all changes - everything is in the index
- run "git clang-format" - clang-format reformats the patches that are
in the index
- run "git add -i" to accept or reject git-clang-format edits.


> I also agree that the git-commit hook could do more than check whitespace.
> cheers,
> Douglas

More information about the samba-technical mailing list