coccicheck: introduce 'pending' semantic patches
Teach `make coccicheck` to avoid patches named "*.pending.cocci" and handle them separately in a new `make coccicheck-pending` instead. This means that we can separate "critical" patches from "FYI" patches. The former target can continue causing Travis to fail its static analysis job, while the latter can let us keep an eye on ongoing (pending) transitions without them causing too much fallout. Document the intended use-cases around these two targets. As the process around the pending patches is not yet fully explored, leave that out. Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com> Based-on-work-by: SZEDER Gábor <szeder.dev@gmail.com> Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
SZEDER Gábor committed
Nov 9, 2018 at 16:10 UTC
dd5d052c397229f46cbc14768c0b11a09a79720f
2 files changed
+46
-2
Makefile
+5
-2
@@ -2740,9 +2740,12 @@ endif
2740
then \
2741
echo ' ' SPATCH result: $@; \
2742
fi
2743
-coccicheck: $(addsuffix .patch,$(wildcard contrib/coccinelle/*.cocci))
2743
+coccicheck: $(addsuffix .patch,$(filter-out %.pending.cocci,$(wildcard contrib/coccinelle/*.cocci)))
2744
2745
-.PHONY: coccicheck
2745
+# See contrib/coccinelle/README
2746
+coccicheck-pending: $(addsuffix .patch,$(wildcard contrib/coccinelle/*.pending.cocci))
2747
+
2748
+.PHONY: coccicheck coccicheck-pending
2749
2750
### Installation rules
2751
contrib/coccinelle/README
+41
@@ -1,2 +1,43 @@
1
This directory provides examples of Coccinelle (http://coccinelle.lip6.fr/)
2
semantic patches that might be useful to developers.
3
+
4
+There are two types of semantic patches:
5
+
6
+ * Using the semantic transformation to check for bad patterns in the code;
7
+ The target 'make coccicheck' is designed to check for these patterns and
8
+ it is expected that any resulting patch indicates a regression.
9
+ The patches resulting from 'make coccicheck' are small and infrequent,
10
+ so once they are found, they can be sent to the mailing list as per usual.
11
+
12
+ Example for introducing new patterns:
13
+ 67947c34ae (convert "hashcmp() != 0" to "!hasheq()", 2018-08-28)
14
+ b84c783882 (fsck: s/++i > 1/i++/, 2018-10-24)
15
+
16
+ Example of fixes using this approach:
17
+ 248f66ed8e (run-command: use strbuf_addstr() for adding a string to
18
+ a strbuf, 2018-03-25)
19
+ f919ffebed (Use MOVE_ARRAY, 2018-01-22)
20
+
21
+ These types of semantic patches are usually part of testing, c.f.
22
+ 0860a7641b (travis-ci: fail if Coccinelle static analysis found something
23
+ to transform, 2018-07-23)
24
+
25
+ * Using semantic transformations in large scale refactorings throughout
26
+ the code base.
27
+
28
+ When applying the semantic patch into a real patch, sending it to the
29
+ mailing list in the usual way, such a patch would be expected to have a
30
+ lot of textual and semantic conflicts as such large scale refactorings
31
+ change function signatures that are used widely in the code base.
32
+ A textual conflict would arise if surrounding code near any call of such
33
+ function changes. A semantic conflict arises when other patch series in
34
+ flight introduce calls to such functions.
35
+
36
+ So to aid these large scale refactorings, semantic patches can be used.
37
+ However we do not want to store them in the same place as the checks for
38
+ bad patterns, as then automated builds would fail.
39
+ That is why semantic patches 'contrib/coccinelle/*.pending.cocci'
40
+ are ignored for checks, and can be applied using 'make coccicheck-pending'.
41
+
42
+ This allows to expose plans of pending large scale refactorings without
43
+ impacting the bad pattern checks.