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
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Aug 9, 2017, 14:03 UTC
Message-ID
<87y3qsg7ni.fsf@gmail.com>
In-Reply-To
<20170809130127.ekd4tvyp2rrb7ftk@sigill.intra.peff.net>
On Wed, Aug 09 2017, Jeff King jotted:
Show 24 quoted lines
> On Mon, Aug 07, 2017 at 06:25:54PM -0700, Brandon Williams wrote:
>
>> I'm sure this sort of thing comes up every so often on the list but back at
>> git-merge I mentioned how it would be nice to not have to worry about style
>> when reviewing patches as that is something mechanical and best left to a
>> machine (for the most part).  I saw that 'clang-format' was brought up on the
>> list once before a couple years ago
>> (https://public-inbox.org/git/20150121220903.GA10267@peff.net/) but nothing
>> really came of it.  I spent a little bit of time combing through the various
>> options and came up with this config based on the general style of our code
>> base.  The big issue though is that our code base isn't consistent so try as
>> you might you wont be able to come up with a config which matches everything we
>> do (mostly due to the inconsistencies in our code base).
>
> Right, the reason I stopped pursuing it was that I couldn't find a way
> to have it make suggestions for new code without nagging about existing
> code. If we were to aggressively reformat to match the tool for existing
> code, that would help. But I'm a bit worried that there would always be
> suggestions from the tool that we don't agree with (i.e., where the
> guiding principle is "do what is readable").
>
> I dunno. I guess "go fmt" people decided to just treat the tool's output
> as the One True Way. I haven't written enough Go to have an opinion
> myself, but it seems to at least work for them.

(I have no opinion either way on whether this clang formatting this is a good idea or not)

> What does the tooling look like these days for just adjusting lines
> touched by a given patch?

Presumably even if it sucked we could easily write a "./git-fmt-check.sh <file>" script to do it which would do the following:

 1. Check out the master branch
 2. Apply code formatting to entire project (or just the files you
    changed)
 3. Commit that on a throwaway branch
 4. Switch back to your WIP branch
 5. See if it would merge cleanly with the throwaway code formatting
    branch (I forget the actual 'not a real merge but check' command to
    do this, but it exists).

If there were any reported conflicts presumably the new code you're adding is violating the coding standards laid out in this file. If not you're good.

Previous: Jeff KingNext: Stefan Beller
Message 23 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.