Thread (34 messages) 34 messages, 6 authors, 2017-09-28

Re: [PATCH v2 0/2] clang-format

flat view

From: Jeff King <hidden>
Date: 2017-08-14 23:07:04

On Mon, Aug 14, 2017 at 02:30:44PM -0700, Brandon Williams wrote:
Changes in v2:
 * Changed a couple rules to be more inline with our coding style.
 * Added a Makefile build rule to run git-clang-format on the diff of the
   working tree to suggest style changes.

I found that the llvm project also has the git-clang-format tool which will
allow for doing formating changes based on diffs so that the parts of the code
you didn't touch won't be formated.  It also has a nice '-p' option to only
apply hunks of suggested changes.  I also saw what Ramsay did and attempted to
add a Makefile rule to run clang-format.  This bit may need more tweaking to
get it right.
One more oddity I found while playing with this that Git folks might run
into:

  $ git init tmp && cd tmp
  $ git commit --allow-empty -m foo
  $ echo "[mysection]mykey" >>.git/config
  $ git clang-format-5.0
  Traceback (most recent call last):
    File "/usr/bin/git-clang-format-5.0", line 579, in <module>
      main()
    File "/usr/bin/git-clang-format-5.0", line 62, in main
      config = load_git_config()
    File "/usr/bin/git-clang-format-5.0", line 194, in load_git_config
      name, value = entry.split('\n', 1)
  ValueError: need more than 1 value to unpack

  $ sed -i 's/mykey/&=true/' .git/config
  $ git clang-format-5.0
  no modified files to format

So it looks like they do their own config parsing and it's not quite
compatible. :(

That's not the end of the world, and something we can try to fix
upstream. I just wanted to mention it here so other people don't waste
time trying to track down the problem.

-Peff
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help