]> git.ipfire.org Git - thirdparty/git.git/commitdiff
contrib: move "coccinelle/" directory into "tools/"
authorPatrick Steinhardt <ps@pks.im>
Thu, 19 Mar 2026 05:33:21 +0000 (06:33 +0100)
committerJunio C Hamano <gitster@pobox.com>
Thu, 19 Mar 2026 13:40:08 +0000 (06:40 -0700)
The Coccinelle tool is an ingrained part of our build infrastructure. It
is executed by our CI to detect antipatterns and is used to detect
misuses of certain interfaces. It's presence in "contrib/" is thus
rather misleading.

Promote the configuration into the new "tools/" directory.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
30 files changed:
Makefile
ci/run-static-analysis.sh
contrib/meson.build
tools/coccinelle/.gitignore [moved from contrib/coccinelle/.gitignore with 100% similarity]
tools/coccinelle/README [moved from contrib/coccinelle/README with 98% similarity]
tools/coccinelle/array.cocci [moved from contrib/coccinelle/array.cocci with 100% similarity]
tools/coccinelle/commit.cocci [moved from contrib/coccinelle/commit.cocci with 100% similarity]
tools/coccinelle/config_fn_ctx.pending.cocci [moved from contrib/coccinelle/config_fn_ctx.pending.cocci with 100% similarity]
tools/coccinelle/equals-null.cocci [moved from contrib/coccinelle/equals-null.cocci with 100% similarity]
tools/coccinelle/flex_alloc.cocci [moved from contrib/coccinelle/flex_alloc.cocci with 100% similarity]
tools/coccinelle/free.cocci [moved from contrib/coccinelle/free.cocci with 100% similarity]
tools/coccinelle/git_config_number.cocci [moved from contrib/coccinelle/git_config_number.cocci with 100% similarity]
tools/coccinelle/hashmap.cocci [moved from contrib/coccinelle/hashmap.cocci with 100% similarity]
tools/coccinelle/index-compatibility.cocci [moved from contrib/coccinelle/index-compatibility.cocci with 100% similarity]
tools/coccinelle/meson.build [moved from contrib/coccinelle/meson.build with 100% similarity]
tools/coccinelle/object_id.cocci [moved from contrib/coccinelle/object_id.cocci with 100% similarity]
tools/coccinelle/preincr.cocci [moved from contrib/coccinelle/preincr.cocci with 100% similarity]
tools/coccinelle/qsort.cocci [moved from contrib/coccinelle/qsort.cocci with 100% similarity]
tools/coccinelle/refs.cocci [moved from contrib/coccinelle/refs.cocci with 100% similarity]
tools/coccinelle/spatchcache [moved from contrib/coccinelle/spatchcache with 97% similarity]
tools/coccinelle/strbuf.cocci [moved from contrib/coccinelle/strbuf.cocci with 100% similarity]
tools/coccinelle/swap.cocci [moved from contrib/coccinelle/swap.cocci with 100% similarity]
tools/coccinelle/tests/free.c [moved from contrib/coccinelle/tests/free.c with 100% similarity]
tools/coccinelle/tests/free.res [moved from contrib/coccinelle/tests/free.res with 100% similarity]
tools/coccinelle/the_repository.cocci [moved from contrib/coccinelle/the_repository.cocci with 100% similarity]
tools/coccinelle/xcalloc.cocci [moved from contrib/coccinelle/xcalloc.cocci with 100% similarity]
tools/coccinelle/xopen.cocci [moved from contrib/coccinelle/xopen.cocci with 100% similarity]
tools/coccinelle/xstrdup_or_null.cocci [moved from contrib/coccinelle/xstrdup_or_null.cocci with 100% similarity]
tools/coccinelle/xstrncmpz.cocci [moved from contrib/coccinelle/xstrncmpz.cocci with 100% similarity]
tools/meson.build

index c7cedbcd7cc31c855409f65d2468daab4a0d325b..8564b1be369caecf8ac79975f920a734e35c32ac 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1005,8 +1005,8 @@ SPATCH_TEST_FLAGS =
 # COMPUTE_HEADER_DEPENDENCIES=no this will be unset too.
 SPATCH_USE_O_DEPENDENCIES = YesPlease
 
-# Set SPATCH_CONCAT_COCCI to concatenate the contrib/cocci/*.cocci
-# files into a single contrib/cocci/ALL.cocci before running
+# Set SPATCH_CONCAT_COCCI to concatenate the tools/coccinelle/*.cocci
+# files into a single tools/coccinelle/ALL.cocci before running
 # "coccicheck".
 #
 # Pros:
@@ -1025,7 +1025,7 @@ SPATCH_USE_O_DEPENDENCIES = YesPlease
 #   generate a specific patch, e.g. this will always use strbuf.cocci,
 #   not ALL.cocci:
 #
-#      make contrib/coccinelle/strbuf.cocci.patch
+#      make tools/coccinelle/strbuf.cocci.patch
 SPATCH_CONCAT_COCCI = YesPlease
 
 # Rebuild 'coccicheck' if $(SPATCH), its flags etc. change
@@ -3457,15 +3457,15 @@ check:
                exit 1; \
        fi
 
-COCCI_GEN_ALL = .build/contrib/coccinelle/ALL.cocci
-COCCI_GLOB = $(wildcard contrib/coccinelle/*.cocci)
+COCCI_GEN_ALL = .build/tools/coccinelle/ALL.cocci
+COCCI_GLOB = $(wildcard tools/coccinelle/*.cocci)
 COCCI_RULES_TRACKED = $(COCCI_GLOB:%=.build/%)
 COCCI_RULES_TRACKED_NO_PENDING = $(filter-out %.pending.cocci,$(COCCI_RULES_TRACKED))
 COCCI_RULES =
 COCCI_RULES += $(COCCI_GEN_ALL)
 COCCI_RULES += $(COCCI_RULES_TRACKED)
 COCCI_NAMES =
-COCCI_NAMES += $(COCCI_RULES:.build/contrib/coccinelle/%.cocci=%)
+COCCI_NAMES += $(COCCI_RULES:.build/tools/coccinelle/%.cocci=%)
 
 COCCICHECK_PENDING = $(filter %.pending.cocci,$(COCCI_RULES))
 COCCICHECK = $(filter-out $(COCCICHECK_PENDING),$(COCCI_RULES))
@@ -3480,20 +3480,20 @@ COCCICHECK_PATCHES_PENDING_INTREE = $(COCCICHECK_PATCHES_PENDING:.build/%=%)
 # on $(MAKECMDGOALS) that match these $(COCCI_RULES)
 COCCI_RULES_GLOB =
 COCCI_RULES_GLOB += cocci%
-COCCI_RULES_GLOB += .build/contrib/coccinelle/%
+COCCI_RULES_GLOB += .build/tools/coccinelle/%
 COCCI_RULES_GLOB += $(COCCICHECK_PATCHES)
 COCCI_RULES_GLOB += $(COCCICHEC_PATCHES_PENDING)
 COCCI_RULES_GLOB += $(COCCICHECK_PATCHES_INTREE)
 COCCI_RULES_GLOB += $(COCCICHECK_PATCHES_PENDING_INTREE)
 COCCI_GOALS = $(filter $(COCCI_RULES_GLOB),$(MAKECMDGOALS))
 
-COCCI_TEST_RES = $(wildcard contrib/coccinelle/tests/*.res)
+COCCI_TEST_RES = $(wildcard tools/coccinelle/tests/*.res)
 
 $(COCCI_RULES_TRACKED): .build/% : %
        $(call mkdir_p_parent_template)
        $(QUIET_CP)cp $< $@
 
-.build/contrib/coccinelle/FOUND_H_SOURCES: $(FOUND_H_SOURCES)
+.build/tools/coccinelle/FOUND_H_SOURCES: $(FOUND_H_SOURCES)
        $(call mkdir_p_parent_template)
        $(QUIET_GEN) >$@
 
@@ -3507,12 +3507,12 @@ endif
 define cocci-rule
 
 ## Rule for .build/$(1).patch/$(2); Params:
-# $(1) = e.g. ".build/contrib/coccinelle/free.cocci"
+# $(1) = e.g. ".build/tools/coccinelle/free.cocci"
 # $(2) = e.g. "grep.c"
 # $(3) = e.g. "grep.o"
-COCCI_$(1:.build/contrib/coccinelle/%.cocci=%) += $(1).d/$(2).patch
+COCCI_$(1:.build/tools/coccinelle/%.cocci=%) += $(1).d/$(2).patch
 $(1).d/$(2).patch: GIT-SPATCH-DEFINES
-$(1).d/$(2).patch: $(if $(and $(SPATCH_USE_O_DEPENDENCIES),$(wildcard $(3))),$(3),.build/contrib/coccinelle/FOUND_H_SOURCES)
+$(1).d/$(2).patch: $(if $(and $(SPATCH_USE_O_DEPENDENCIES),$(wildcard $(3))),$(3),.build/tools/coccinelle/FOUND_H_SOURCES)
 $(1).d/$(2).patch: $(1)
 $(1).d/$(2).patch: $(1).d/%.patch : %
        $$(call mkdir_p_parent_template)
@@ -3538,13 +3538,13 @@ endif
 
 define spatch-rule
 
-.build/contrib/coccinelle/$(1).cocci.patch: $$(COCCI_$(1))
+.build/tools/coccinelle/$(1).cocci.patch: $$(COCCI_$(1))
        $$(QUIET_SPATCH_CAT)cat $$^ >$$@ && \
        if test -s $$@; \
        then \
                echo '    ' SPATCH result: $$@; \
        fi
-contrib/coccinelle/$(1).cocci.patch: .build/contrib/coccinelle/$(1).cocci.patch
+tools/coccinelle/$(1).cocci.patch: .build/tools/coccinelle/$(1).cocci.patch
        $$(QUIET_CP)cp $$< $$@
 
 endef
@@ -3558,9 +3558,9 @@ $(COCCI_TEST_RES_GEN): GIT-SPATCH-DEFINES
 $(COCCI_TEST_RES_GEN): .build/%.res : %.c
 $(COCCI_TEST_RES_GEN): .build/%.res : %.res
 ifdef SPATCH_CONCAT_COCCI
-$(COCCI_TEST_RES_GEN): .build/contrib/coccinelle/tests/%.res : $(COCCI_GEN_ALL)
+$(COCCI_TEST_RES_GEN): .build/tools/coccinelle/tests/%.res : $(COCCI_GEN_ALL)
 else
-$(COCCI_TEST_RES_GEN): .build/contrib/coccinelle/tests/%.res : contrib/coccinelle/%.cocci
+$(COCCI_TEST_RES_GEN): .build/tools/coccinelle/tests/%.res : tools/coccinelle/%.cocci
 endif
        $(call mkdir_p_parent_template)
        $(QUIET_SPATCH_TEST)$(SPATCH) $(SPATCH_TEST_FLAGS) \
@@ -3576,14 +3576,14 @@ coccicheck-test: $(COCCI_TEST_RES_GEN)
 coccicheck: coccicheck-test
 
 ifdef SPATCH_CONCAT_COCCI
-COCCICHECK_PATCH_MUST_BE_EMPTY_FILES = contrib/coccinelle/ALL.cocci.patch
+COCCICHECK_PATCH_MUST_BE_EMPTY_FILES = tools/coccinelle/ALL.cocci.patch
 else
 COCCICHECK_PATCH_MUST_BE_EMPTY_FILES = $(COCCICHECK_PATCHES_INTREE)
 endif
 coccicheck: $(COCCICHECK_PATCH_MUST_BE_EMPTY_FILES)
        ! grep ^ $(COCCICHECK_PATCH_MUST_BE_EMPTY_FILES) /dev/null
 
-# See contrib/coccinelle/README
+# See tools/coccinelle/README
 coccicheck-pending: coccicheck-test
 coccicheck-pending: $(COCCICHECK_PATCHES_PENDING_INTREE)
 
@@ -3857,8 +3857,8 @@ profile-clean:
 
 cocciclean:
        $(RM) GIT-SPATCH-DEFINES
-       $(RM) -r .build/contrib/coccinelle
-       $(RM) contrib/coccinelle/*.cocci.patch
+       $(RM) -r .build/tools/coccinelle
+       $(RM) tools/coccinelle/*.cocci.patch
 
 clean: profile-clean coverage-clean cocciclean
        $(RM) -r .build $(UNIT_TEST_BIN)
index 9e9c72681d5715559170f94433080a656a2dfa08..ba67e80b4db2d5faefef3551a08f97592aa65cd8 100755 (executable)
@@ -10,7 +10,7 @@ make coccicheck
 set +x
 
 fail=
-for cocci_patch in contrib/coccinelle/*.patch
+for cocci_patch in tools/coccinelle/*.patch
 do
        if test -s "$cocci_patch"
        then
index a88c5dfe09ed629c3c26506d4ac0ac8df2dd48be..569c23ee768bb8dd28f2c41e35f7cde1a1671909 100644 (file)
@@ -2,5 +2,4 @@ foreach feature : get_option('contrib')
   subdir(feature)
 endforeach
 
-subdir('coccinelle')
 subdir('credential')
similarity index 98%
rename from contrib/coccinelle/README
rename to tools/coccinelle/README
index 055ad0e06a70e2a23c88c1cf34782d679d42426a..fd0a543cc27f9e4837ade5186e7ca8d156f9995b 100644 (file)
@@ -38,7 +38,7 @@ that might be useful to developers.
    So to aid these large scale refactorings, semantic patches can be used.
    However we do not want to store them in the same place as the checks for
    bad patterns, as then automated builds would fail.
-   That is why semantic patches 'contrib/coccinelle/*.pending.cocci'
+   That is why semantic patches 'tools/coccinelle/*.pending.cocci'
    are ignored for checks, and can be applied using 'make coccicheck-pending'.
 
    This allows to expose plans of pending large scale refactorings without
similarity index 97%
rename from contrib/coccinelle/spatchcache
rename to tools/coccinelle/spatchcache
index 29e9352d8a278a98406d653c05ec768f84e9719e..efbcbc3827115b4a38e60098e02165dde2ecc36a 100755 (executable)
@@ -30,7 +30,7 @@
 #         out of control.
 #
 # This along with the general incremental "make" support for
-# "contrib/coccinelle" makes it viable to (re-)run coccicheck
+# "tools/coccinelle" makes it viable to (re-)run coccicheck
 # e.g. when merging integration branches.
 #
 # Note that the "--very-quiet" flag is currently critical. The cache
@@ -42,7 +42,7 @@
 # to change, so just supply "--very-quiet" for now.
 #
 # To use this, simply set SPATCH to
-# contrib/coccinelle/spatchcache. Then optionally set:
+# tools/coccinelle/spatchcache. Then optionally set:
 #
 #      [spatchCache]
 #              # Optional: path to a custom spatch
@@ -65,7 +65,7 @@
 #
 #      redis-cli FLUSHALL
 #      <make && make coccicheck, as above>
-#      grep -hore HIT -e MISS -e SET -e NOCACHE -e CANTCACHE .build/contrib/coccinelle | sort | uniq -c
+#      grep -hore HIT -e MISS -e SET -e NOCACHE -e CANTCACHE .build/tools/coccinelle | sort | uniq -c
 #          600 CANTCACHE
 #         7365 MISS
 #         7365 SET
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..f731f74312f613c8da3ada6297ab5f56e1b955bd 100644 (file)
@@ -0,0 +1 @@
+subdir('coccinelle')