diff mbox series

[01/24] Makefile: add pending semantic patches

Message ID 20181030220817.61691-2-sbeller@google.com (mailing list archive)
State New, archived
Headers show
Series Bring more repository handles into our code base] | expand

Commit Message

Stefan Beller Oct. 30, 2018, 10:07 p.m. UTC
From: SZEDER Gábor <szeder.dev@gmail.com>

There are basically two main use cases for semantic patches:

      - To avoid undesirable code patterns, e.g. we should not use
        sha1_to_hex(oid.hash) or strbuf_addf(&sb, "fixed string"), but
        use oid_to_hex(&oid) or strbuf_addstr(&sb, "fixed string")
        instead.  Note that in these cases we don't remove the
        functions sha1_to_hex() or strbuf_addf(), because there are
        good reasons to use them in other scenarios.

        Our semantic patches under 'contrib/coccinelle/' fall into
        this category, and we have 'make coccicheck' and the static
        analysis build job on Travis CI to catch these undesirable
        code patterns preferably early, and to prevent them from
        entering our codebase.

      - To perform one-off code transformations, e.g. to modify a
        function's name and/or signature and convert all its
        callsites; see e.g. commits abef9020e3 (sha1_file: convert
        sha1_object_info* to object_id, 2018-03-12) and b4f5aca40e
        (sha1_file: convert read_sha1_file to struct object_id,
        2018-03-12).

To allows semantic patches of the second category, we'll introduce
the concept of "pending" semantic patches, stored in
'contrib/coccinelle/<name>.pending.cocci' files, modifying
'make coccicheck' to skip them, and adding the new 'make
coccicheck-pending' target to make it convenient to apply them.

[Missing: SZEDERs sign off, so I also do not sign off]
---
 Makefile | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Junio C Hamano Oct. 31, 2018, 6:42 a.m. UTC | #1
Stefan Beller <sbeller@google.com> writes:

> [Missing: SZEDERs sign off, so I also do not sign off]

At least to me, based on my reading of DCO in
Documentation/SubmittingPatches, this reasoning does not make much
sense.
diff mbox series

Patch

diff --git a/Makefile b/Makefile
index b08d5ea258..6ea2bbd7f5 100644
--- a/Makefile
+++ b/Makefile
@@ -2739,9 +2739,11 @@  endif
 	then \
 		echo '    ' SPATCH result: $@; \
 	fi
-coccicheck: $(addsuffix .patch,$(wildcard contrib/coccinelle/*.cocci))
+coccicheck: $(addsuffix .patch,$(filter-out %.pending.cocci,$(wildcard contrib/coccinelle/*.cocci)))
 
-.PHONY: coccicheck
+coccicheck-pending: $(addsuffix .patch,$(wildcard contrib/coccinelle/*.pending.cocci))
+
+.PHONY: coccicheck coccicheck-pending
 
 ### Installation rules