git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [RFC] clang-format: outline the git project's coding style

From
Ben Peart <peartben@gmail.com>
Date
Aug 11, 2017, 20:06 UTC
Message-ID
<0378b54f-7332-7a39-23b1-40886c97c596@gmail.com>
In-Reply-To
<20170810213013.GD73298@google.com>
On 8/10/2017 5:30 PM, Brandon Williams wrote:
Show 54 quoted lines
> On 08/10, Junio C Hamano wrote:
>> Brandon Williams <bmwill@google.com> writes:
>>
>>> On 08/10, Junio C Hamano wrote:
>>>
>>>> I vaguely recall that there was a discussion to have SubmitGit wait
>>>> for success from Travis CI; if that is already in place, then I can
>>>> sort of see how it would help individual contributors to have the
>>>> style checker in that pipeline as well.
>>>>
>>>> I have a mixed feelings about "fixing" styles automatically, though.
>>>
>>> I still think we are far away from a world where we can fix style
>>> automatically.  If we do want to keep pursuing this there are a number
>>> steps we'd want to take first.
>>>
>>> 1. Settle on a concrete style and document it using a formatter's rules
>>>     (in say a .clang-format file).  This style would most likely need to
>>>     be tuned a little bit, at least the 'Penalty' configuration would
>>>     need to be tuned which (as far as I understand it) is used to
>>>     determine which rule to break first to ensure a line isn't too long.
>>
>> Yes.  I think this is what you started to get the ball rolling.
>> Together with what checkpatch.pl already diagnoses, I think we can
>> get a guideline that is more or less reasonable.
>>
>>> 2. Start getting contributors to use the tool to format their patches.
>>>     This would include having some script or hook that a contributor
>>>     could run to only format the sections of code that they touched.
>>
>> This, too.  Running checkpatch.pl (possibly combined with a bit of
>> tweaking it to match our needs) already catches many of the issues,
>> so a tool with a similar interface would be easy to use, I would
>> imagine.
>>
>>> 3. Slowly the code base would begin to have a uniform style.  At
>>>     some point we may want to then reformat the remaining sections of the
>>>     code base.  At this point we could have some automated bot that fixes
>>>     style.
>>
>> I suspect I am discussing this based on a different assumption.
>>
>> I think the primary goal of this effort is to make it easier to
>> cleanse the new patches that appear on the list of trivial style
>> issues, so that contributors and reviewers do not have to spend
>> bandwidth and brain cycles during the review.  And I have been
>> assuming that we can do so even without waiting for a "tree wide"
>> code churn on existing code to complete.
> 
> Yes that's one of the steps I missed we can call it 2.5 ;)  (3) could be
> a long term goal which is what I was trying to get at by saying:
> 
>>> 3. Slowly the code base would begin to have a uniform style.
> 
Just adding my "Yes!" vote.

Consistent formatting makes the code easier to read and maintain. I've been in religious wars debating whether the opening brace should be on the same line or the next line and while I have my personal preferences, I can work with just about anything as long as it is consistent. When it comes to dealing with a tool, I am willing to live with some "I would have wrapped that differently" if I can stop spending so much time manually wrapping code.

I think the goals should be to 1) increase readability of the code 2) reduce the time spent by reviewers and 3) reduce the time spent by contributors. A pre-commit hook that checked for errors (and gave the instructions on how to automatically have the tool correct them) would be very helpful.

Please continue to push this forward!
Previous: Brandon WilliamsNext: Johannes Schindelin
Message 12 of 64 in “[RFC] clang-format: outline the git project's coding style”
  1. Brandon WilliamsAug 8, 2017
  2. Johannes SchindelinAug 8, 2017
  3. Stefan BellerAug 8, 2017
  4. Brandon WilliamsAug 8, 2017
  5. Johannes SchindelinAug 9, 2017
  6. Stefan BellerAug 9, 2017
  7. Johannes SchindelinAug 10, 2017
  8. Junio C HamanoAug 10, 2017
  9. Brandon WilliamsAug 10, 2017
  10. Junio C HamanoAug 10, 2017
  11. Brandon WilliamsAug 10, 2017
  12. Ben PeartAug 11, 2017
  13. Johannes SchindelinAug 14, 2017
  14. Johannes SchindelinSep 28, 2017
  15. Brandon WilliamsSep 28, 2017
  16. Junio C HamanoAug 8, 2017
  17. Brandon WilliamsAug 8, 2017
  18. Junio C HamanoAug 8, 2017
  19. Junio C HamanoAug 9, 2017
  20. Brandon WilliamsAug 11, 2017
  21. Junio C HamanoAug 11, 2017
  22. Jeff KingAug 9, 2017
  23. Ævar Arnfjörð BjarmasonAug 9, 2017
  24. Stefan BellerAug 9, 2017
  25. Stefan BellerAug 9, 2017
  26. Jeff KingAug 9, 2017
  27. brian m. carlsonAug 15, 2017
  28. Jonathan NiederAug 15, 2017
  29. Brandon WilliamsAug 11, 2017
  30. Jeff KingAug 11, 2017
  31. Junio C HamanoAug 12, 2017
  32. Jeff KingAug 13, 2017
  33. Ramsay JonesAug 13, 2017
  34. Ramsay JonesAug 13, 2017
  35. Junio C HamanoAug 13, 2017
  36. Ramsay JonesAug 13, 2017
  37. 0/2 clang-formatBrandon Williams, Aug 14, 2017
  38. 2/2 Makefile: add style build ruleBrandon Williams, Aug 14, 2017
  39. Stefan BellerAug 14, 2017
  40. Junio C HamanoAug 14, 2017
  41. Stefan BellerAug 14, 2017
  42. Jeff KingAug 14, 2017
  43. Junio C HamanoAug 14, 2017
  44. Junio C HamanoAug 14, 2017
  45. Brandon WilliamsAug 15, 2017
  46. Jeff KingAug 15, 2017
  47. 1/2 clang-format: outline the git project's coding styleBrandon Williams, Aug 14, 2017
  48. Stefan BellerAug 14, 2017
  49. Ben PeartAug 15, 2017
  50. Brandon WilliamsAug 15, 2017
  51. Jeff KingAug 14, 2017
  52. Jeff KingAug 14, 2017
  53. Brandon WilliamsAug 14, 2017
  54. Jeff KingAug 14, 2017
  55. Johannes SchindelinAug 16, 2017
  56. Ben PeartAug 15, 2017
  57. Brandon WilliamsAug 15, 2017
  58. Stefan BellerAug 15, 2017
  59. Brandon WilliamsAug 14, 2017
  60. Jeff KingAug 14, 2017
  61. Stefan BellerAug 14, 2017
  62. Jeff KingAug 15, 2017
  63. Junio C HamanoAug 15, 2017
  64. Jeff KingAug 15, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.