Brandon Williams [off-list ref] writes:
quoted hunk
Add the 'style' build rule which will run git-clang-format on the diff
between HEAD and the current worktree. The result is a diff of
suggested changes.
Signed-off-by: Brandon Williams <redacted>
---
Makefile | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/Makefile b/Makefile
index ba4359ef8..acfd096b7 100644
--- a/Makefile
+++ b/Makefile
@@ -2414,6 +2414,10 @@ $(SP_OBJ): %.sp: %.c GIT-CFLAGS FORCE
.PHONY: sparse $(SP_OBJ)
sparse: $(SP_OBJ)
+.PHONY: style
+style:
+ git clang-format --style file --diff --extensions c,h
Did we get "git clang-format" subcommand, or is "s/git //" implied
somewhere?
+
check: common-cmds.h
@if sparse; \
then \
On Mon, Aug 14, 2017 at 3:25 PM, Junio C Hamano [off-list ref] wrote:
Brandon Williams [off-list ref] writes:
quoted
Add the 'style' build rule which will run git-clang-format on the diff
between HEAD and the current worktree. The result is a diff of
suggested changes.
Signed-off-by: Brandon Williams <redacted>
---
Makefile | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/Makefile b/Makefile
index ba4359ef8..acfd096b7 100644
--- a/Makefile
+++ b/Makefile
@@ -2414,6 +2414,10 @@ $(SP_OBJ): %.sp: %.c GIT-CFLAGS FORCE
.PHONY: sparse $(SP_OBJ)
sparse: $(SP_OBJ)
+.PHONY: style
+style:
+ git clang-format --style file --diff --extensions c,h
Did we get "git clang-format" subcommand, or is "s/git //" implied
somewhere?
You need to have clang-format installed (debian/Ubuntu package, or
however it is named in your distribution), which provides this command
for us.
On Mon, Aug 14, 2017 at 03:28:50PM -0700, Stefan Beller wrote:
quoted
quoted
+.PHONY: style
+style:
+ git clang-format --style file --diff --extensions c,h
Did we get "git clang-format" subcommand, or is "s/git //" implied
somewhere?
You need to have clang-format installed (debian/Ubuntu package, or
however it is named in your distribution), which provides this command
for us.
Sadly it is called git-clang-format-3.8, git-clang-format-5.0, etc, in
the Debian packages. I think we need a CLANG_FORMAT variable that can be
overridden.
I am surprised that there's no base "git-clang-format" symlink for the
default version. There is for "clang-format" and "clang" themselves. So
arguably this is a bug in the Debian packaging.
I suspect the "-p" version is going to be the one people invoke the most
often. Should it take the coveted "make style" slot, and the diff get
pushed off to another target?
I was also confused at first that the "-p" version requires you to stage
the changes first. I don't know if we can make that less confusing via a
"make style". Or if it's just something people would get used to. But
sadly it makes the command not-quite orthogonal to "make test" in the
workflow. You can't "make style && make test && git add -p". You have
to add first, then check style, then you'd want to test that result to
make sure it didn't change the meaning of the code.
-Peff