git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Ben Peart <peartben@gmail.com>
To: Stefan Beller <sbeller@google.com>, Brandon Williams <bmwill@google.com>
Cc: "git@vger.kernel.org" <git@vger.kernel.org>,
	"Junio C Hamano" <gitster@pobox.com>,
	"Johannes Schindelin" <Johannes.Schindelin@gmx.de>,
	"Jonathan Nieder" <jrnieder@gmail.com>,
	"Ramsay Jones" <ramsay@ramsayjones.plus.com>,
	"Jeff King" <peff@peff.net>,
	"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Subject: Re: [PATCH v2 1/2] clang-format: outline the git project's coding style
Date: Tue, 15 Aug 2017 09:56:07 -0400	[thread overview]
Message-ID: <41c8c119-af98-f16f-1585-81b29429afe8@gmail.com> (raw)
In-Reply-To: <CAGZ79kau6_XeEQqYDhFC2FmyJiqWY2+SuRzvGFrfmLdhAaQS+Q@mail.gmail.com>



On 8/14/2017 6:02 PM, Stefan Beller wrote:
> On Mon, Aug 14, 2017 at 2:30 PM, Brandon Williams <bmwill@google.com> wrote:
>> Add a '.clang-format' file which outlines the git project's coding
>> style.  This can be used with clang-format to auto-format .c and .h
>> files to conform with git's style.
>>
>> Signed-off-by: Brandon Williams <bmwill@google.com>
> 
> Applying this patch and running
>      clang-format -i -style file *.c *.h builtin/*.c
> produces a diff, that I'd mostly agree with.
> This style guide is close to our current style.
> 

I'm happy to see progress being made in helping reduce the time spent 
manually reviewing and fixing style formatting errors.  In an effort to 
help, I installed this in Windows and tried it as well.  The tools all 
appear to be working fine and are supported on Windows.

For the most part, the formatting rules look pretty consistent with the 
existing style.  I ran the same test and looked at the diffs and saw a 
couple of things that looked odd. For example, how it wrapped the 
"static int" on the function header below was different.  Not sure why 
as it didn't wrap all the other function headers the same even later in 
the file it didn't do that with "static void mute_routine"

diff --git a/apply.c b/apply.c
index f2d599141d..bb77242e3d 100644
--- a/apply.c
+++ b/apply.c
@@ -58,12 +59,11 @@ static int parse_whitespace_option(struct 
apply_state *state, const char *option
         return error(_("unrecognized whitespace option '%s'"), option);
  }

-static int parse_ignorewhitespace_option(struct apply_state *state,
-                                                const char *option)
+static int
+parse_ignorewhitespace_option(struct apply_state *state, const char 
*option)
  {
-       if (!option || !strcmp(option, "no") ||
-           !strcmp(option, "false") || !strcmp(option, "never") ||
-           !strcmp(option, "none")) {
+       if (!option || !strcmp(option, "no") || !strcmp(option, "false") ||
+           !strcmp(option, "never") || !strcmp(option, "none")) {
                 state->ws_ignore_action = ignore_ws_none;
                 return 0;
         }


Later in the file it wraps some of them again: (add_line_info, 
prepare_image, find_name_common, etc).  Again, it appears to be 
inconsistent but there must be some rule that is causing this behavior.



Here is an example of how it wrapped bit fields differently.  Again, it 
didn't seem to be consistent with itself as just below this, it left 
them on separate lines.


@@ -182,8 +185,7 @@ struct fragment {
          * but some codepaths store an allocated buffer.
          */
         const char *patch;
-       unsigned free_patch:1,
-               rejected:1;
+       unsigned free_patch : 1, rejected : 1;
         int size;
         int linenr;
         struct fragment *next;


Big thanks to those working on this!

> As noted in patch 2/2 we'd now need an easy way to
> expose this for use in various situations, such as
> * contributor wanting to format their patch
> * reformatting code for readability
> 
> Thanks,
> Stefan
> 

  reply	other threads:[~2017-08-15 13:56 UTC|newest]

Thread overview: 64+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-08  1:25 [RFC] clang-format: outline the git project's coding style Brandon Williams
2017-08-08 12:05 ` Johannes Schindelin
2017-08-08 17:40   ` Stefan Beller
2017-08-08 18:23     ` Brandon Williams
2017-08-09 22:33       ` Johannes Schindelin
2017-08-09 22:42         ` Stefan Beller
2017-08-10  9:38           ` Johannes Schindelin
2017-08-10 16:41             ` Junio C Hamano
2017-08-10 17:15               ` Brandon Williams
2017-08-10 17:28                 ` Junio C Hamano
2017-08-10 21:30                   ` Brandon Williams
2017-08-11 20:06                     ` Ben Peart
2017-08-14 15:52               ` Johannes Schindelin
2017-09-28 11:41         ` Johannes Schindelin
2017-09-28 17:16           ` Brandon Williams
2017-08-08 17:45 ` Junio C Hamano
2017-08-08 18:03   ` Brandon Williams
2017-08-08 18:25     ` Junio C Hamano
2017-08-09  7:05       ` Junio C Hamano
2017-08-11 17:49         ` Brandon Williams
2017-08-11 19:00           ` Junio C Hamano
2017-08-09 13:01 ` Jeff King
2017-08-09 14:03   ` Ævar Arnfjörð Bjarmason
2017-08-09 22:53     ` Stefan Beller
2017-08-09 23:11       ` Stefan Beller
2017-08-11 17:52         ` Brandon Williams
2017-08-11 21:18           ` Jeff King
2017-08-12  4:39             ` Junio C Hamano
2017-08-13  4:41               ` Jeff King
2017-08-13 16:14                 ` Ramsay Jones
2017-08-13 16:36                   ` Ramsay Jones
2017-08-13 17:33                   ` Junio C Hamano
2017-08-13 19:17                     ` Ramsay Jones
2017-08-09 23:19       ` Jeff King
2017-08-15  0:40         ` brian m. carlson
2017-08-15  1:03           ` Jonathan Nieder
2017-08-14 21:30 ` [PATCH v2 0/2] clang-format Brandon Williams
2017-08-14 21:30   ` [PATCH v2 1/2] clang-format: outline the git project's coding style Brandon Williams
2017-08-14 22:02     ` Stefan Beller
2017-08-15 13:56       ` Ben Peart [this message]
2017-08-15 17:37         ` Brandon Williams
2017-08-14 22:48     ` Jeff King
2017-08-14 22:51       ` Jeff King
2017-08-14 22:54         ` Brandon Williams
2017-08-14 23:01           ` Jeff King
2017-08-16 12:18             ` Johannes Schindelin
2017-08-15 14:28     ` Ben Peart
2017-08-15 17:34       ` Brandon Williams
2017-08-15 17:41         ` Stefan Beller
2017-08-14 21:30   ` [PATCH v2 2/2] Makefile: add style build rule Brandon Williams
2017-08-14 21:53     ` Stefan Beller
2017-08-14 22:25     ` Junio C Hamano
2017-08-14 22:28       ` Stefan Beller
2017-08-14 22:57         ` Jeff King
2017-08-14 23:29           ` Junio C Hamano
2017-08-14 23:47             ` Junio C Hamano
2017-08-15  0:05               ` Brandon Williams
2017-08-15  1:52               ` Jeff King
2017-08-14 21:32   ` [PATCH v2 0/2] clang-format Brandon Williams
2017-08-14 23:06   ` Jeff King
2017-08-14 23:15     ` Stefan Beller
2017-08-15  1:47       ` Jeff King
2017-08-15  3:03         ` Junio C Hamano
2017-08-15  3:38           ` Jeff King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=41c8c119-af98-f16f-1585-81b29429afe8@gmail.com \
    --to=peartben@gmail.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=avarab@gmail.com \
    --cc=bmwill@google.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jrnieder@gmail.com \
    --cc=peff@peff.net \
    --cc=ramsay@ramsayjones.plus.com \
    --cc=sbeller@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).