From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: "Stefan Beller" <sbeller@google.com>,
"Brandon Williams" <bmwill@google.com>,
"git@vger.kernel.org" <git@vger.kernel.org>,
"Johannes Schindelin" <Johannes.Schindelin@gmx.de>,
"Jonathan Nieder" <jrnieder@gmail.com>,
"Ramsay Jones" <ramsay@ramsayjones.plus.com>,
"Ben Peart" <peartben@gmail.com>,
"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Subject: Re: [PATCH v2 2/2] Makefile: add style build rule
Date: Mon, 14 Aug 2017 21:52:57 -0400 [thread overview]
Message-ID: <20170815015256.c423wjwrq7crghu4@sigill.intra.peff.net> (raw)
In-Reply-To: <xmqqvalpsoda.fsf@gitster.mtv.corp.google.com>
On Mon, Aug 14, 2017 at 04:47:45PM -0700, Junio C Hamano wrote:
> > By the way, I do not know which vintage of /usr/bin/git-clang-format
> > I happen to have on my box, but I needed a crude workaround patch
> > (attached at the end) ...
>
> I guess you hit the same thing while our messages crossing ;-)
Yep. Our solutions were at opposite ends of the spectrum, though. :)
> > As to what it does, the first example I tried may not have been a
> > great one. I got this:
> >
> > git clang-format --style file --diff --extensions c,h
> > diff --git a/cache.h b/cache.h
> > index 73e0085186..6462fe25bc 100644
> > --- a/cache.h
> > +++ b/cache.h
> > @@ -1498,11 +1498,8 @@ struct checkout {
> > const char *base_dir;
> > int base_dir_len;
> > struct delayed_checkout *delayed_checkout;
> > - unsigned force:1,
> > - quiet:1,
> > - not_new:1,
> > - a_new_field:1,
> > - refresh_cache:1;
> > + unsigned force : 1, quiet : 1, not_new : 1, a_new_field : 1,
> > + refresh_cache : 1;
> > };
> > #define CHECKOUT_INIT { NULL, "" }
> >
> > which is not wrong per-se, but I have a mixed feelings. I do not
> > want it to complain if the original tried to fit many items on a
> > single line, but if the original wanted to have one item per line,
> > I'd rather see it kept as-is.
>
> To clarify, the above is after I added a_new_field that is one-bit
> wide without doing anything else. I do not mind the checker
> complaining the existing force, quiet, etc. whose widths are all
> spelled without SP around ':', because they appear near-by, as a
> collateral damage. My only gripe is that the result got squished
> into a single line.
Yes, agreed. My personal rule with a list like this is often "once you
have to start breaking across multiple lines, you should put one per
line". I don't know if there's a way to codify that in clang-format,
though.
The case I fed it (which is just nonsense I made up that does not fit
our style) also left me a bit confused at first, but I think it was
because the .clang-format parser was bailing as soon as it found an
unrecognized entry, but then formatting according to bogus rules. With
the original file from Brandon I got:
diff --git a/builtin/merge-file.c b/builtin/merge-file.c
index 7e8371670b..8994450e0c 100644
--- a/builtin/merge-file.c
+++ b/builtin/merge-file.c
@@ -21,10 +21,7 @@ static int label_cb(const struct option *opt, const char *arg, int unset)
return 0;
}
-static
-int foo(void* bar,int baz) {
- /* nothing */
-}
+static int foo(void *bar, int baz) { /* nothing */ }
int cmd_merge_file(int argc, const char **argv, const char *prefix)
{
which is clearly not our style. And then after removing the entries I
mentioned elsewhere, I get:
diff --git a/builtin/merge-file.c b/builtin/merge-file.c
index 7e8371670b..574ba6d86f 100644
--- a/builtin/merge-file.c
+++ b/builtin/merge-file.c
@@ -21,8 +21,8 @@ static int label_cb(const struct option *opt, const char *arg, int unset)
return 0;
}
-static
-int foo(void* bar,int baz) {
+static int foo(void *bar, int baz)
+{
/* nothing */
}
which looks right. So you might want to double-check that it was
respecting our settings, and there were no warnings to stderr.
-Peff
next prev parent reply other threads:[~2017-08-15 1:53 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
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 [this message]
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=20170815015256.c423wjwrq7crghu4@sigill.intra.peff.net \
--to=peff@peff.net \
--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=peartben@gmail.com \
--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).