git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2] coccicheck: fail "make" when it fails

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 23, 2025, 16:14 UTC
Message-ID
<xmqqbjqe77vw.fsf@gitster.g>
In-Reply-To
<xmqqwm97bv7c.fsf@gitster.g>

With "make coccicheck", we generate contrib/coccinelle/*.cocci.patch files that contain changes suggested by semantic patches, but "make" succeeds. Admittedly, not many developers may run "make coccicheck" in the first place, but it makes it harder to notice when they do run it after they introduced an iffy piece of code.

Check that the resulting cocci.patch files are all empty.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 Makefile | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/Makefile b/Makefile
index 97e8385b66..8f1e9424a7 100644
--- a/Makefile
+++ b/Makefile
@@ -3422,11 +3422,14 @@ endif
 coccicheck-test: $(COCCI_TEST_RES_GEN)
 
 coccicheck: coccicheck-test
+
 ifdef SPATCH_CONCAT_COCCI
-coccicheck: contrib/coccinelle/ALL.cocci.patch
+COCCICHECK_PATCH_MUST_BE_EMPTY_FILES = contrib/coccinelle/ALL.cocci.patch
 else
-coccicheck: $(COCCICHECK_PATCHES_INTREE)
+COCCICHECK_PATCH_MUST_BE_EMPTY_FILES = $(COCCICHECK_PATCHES_INTREE)
 endif
+coccicheck: $(COCCICHECK_PATCH_MUST_BE_EMPTY_FILES)
+	! grep -q ^ $(COCCICHECK_PATCH_MUST_BE_EMPTY_FILES) /dev/null
 
 # See contrib/coccinelle/README
 coccicheck-pending: coccicheck-test

Range-diff against v1:
1:  163a63f2cf ! 1:  dee873e931 coccicheck: fail "make" when it fails
    @@ Commit message
         Signed-off-by: Junio C Hamano <gitster@pobox.com>
     
      ## Makefile ##
    -@@ Makefile: coccicheck-test: $(COCCI_TEST_RES_GEN)
    +@@ Makefile: endif
    + coccicheck-test: $(COCCI_TEST_RES_GEN)
    + 
      coccicheck: coccicheck-test
    ++
      ifdef SPATCH_CONCAT_COCCI
    - coccicheck: contrib/coccinelle/ALL.cocci.patch
    -+	! test -s contrib/coccinelle/ALL.cocci.patch
    +-coccicheck: contrib/coccinelle/ALL.cocci.patch
    ++COCCICHECK_PATCH_MUST_BE_EMPTY_FILES = contrib/coccinelle/ALL.cocci.patch
      else
    - coccicheck: $(COCCICHECK_PATCHES_INTREE)
    -+	test $$(cat $(COCCICHECK_PATCHES_INTREE) | wc -c) = 0
    +-coccicheck: $(COCCICHECK_PATCHES_INTREE)
    ++COCCICHECK_PATCH_MUST_BE_EMPTY_FILES = $(COCCICHECK_PATCHES_INTREE)
      endif
    ++coccicheck: $(COCCICHECK_PATCH_MUST_BE_EMPTY_FILES)
    ++	! grep -q ^ $(COCCICHECK_PATCH_MUST_BE_EMPTY_FILES) /dev/null
      
      # See contrib/coccinelle/README
    + coccicheck-pending: coccicheck-test
-- 
2.50.0-243-g67b26bc0ed
Previous: Junio C Hamano
Message 6 of 6 in “coccicheck: fail "make" when it fails”
  1. coccicheck: fail "make" when it failsJunio C Hamano, Jun 19, 2025
  2. Jeff KingJun 21, 2025
  3. Carlo Marcelo Arenas BelónJun 21, 2025
  4. Eric SunshineJun 21, 2025
  5. Junio C HamanoJun 22, 2025
  6. coccicheck: fail "make" when it failsJunio C Hamano, Jun 23, 2025

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.