contrib/coccinelle: add basic Coccinelle transforms
Coccinelle (http://coccinelle.lip6.fr/) is a program which performs mechanical transformations on C programs using semantic patches. These semantic patches can be used to implement automatic refactoring and maintenance tasks. Add a set of basic semantic patches to convert common patterns related to the struct object_id transformation, as well as a README. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
brian m. carlson committed
Jun 24, 2016 at 23:09 UTC
db1d80b8faddc5d5702d79974c5757b464bcbaf6
2 files changed
+97
contrib/coccinelle/README
new
+2
@@ -0,0 +1,2 @@
1
+This directory provides examples of Coccinelle (http://coccinelle.lip6.fr/)
2
+semantic patches that might be useful to developers.
contrib/coccinelle/object_id.cocci
new
+95
@@ -0,0 +1,95 @@
1
+@@
2
+expression E1;
3
+@@
4
+- is_null_sha1(E1.hash)
5
++ is_null_oid(&E1)
6
+
7
+@@
8
+expression E1;
9
+@@
10
+- is_null_sha1(E1->hash)
11
++ is_null_oid(E1)
12
+
13
+@@
14
+expression E1;
15
+@@
16
+- sha1_to_hex(E1.hash)
17
++ oid_to_hex(&E1)
18
+
19
+@@
20
+expression E1;
21
+@@
22
+- sha1_to_hex(E1->hash)
23
++ oid_to_hex(E1)
24
+
25
+@@
26
+expression E1;
27
+@@
28
+- sha1_to_hex_r(E1.hash)
29
++ oid_to_hex_r(&E1)
30
+
31
+@@
32
+expression E1;
33
+@@
34
+- sha1_to_hex_r(E1->hash)
35
++ oid_to_hex_r(E1)
36
+
37
+@@
38
+expression E1;
39
+@@
40
+- hashclr(E1.hash)
41
++ oidclr(&E1)
42
+
43
+@@
44
+expression E1;
45
+@@
46
+- hashclr(E1->hash)
47
++ oidclr(E1)
48
+
49
+@@
50
+expression E1, E2;
51
+@@
52
+- hashcmp(E1.hash, E2.hash)
53
++ oidcmp(&E1, &E2)
54
+
55
+@@
56
+expression E1, E2;
57
+@@
58
+- hashcmp(E1->hash, E2->hash)
59
++ oidcmp(E1, E2)
60
+
61
+@@
62
+expression E1, E2;
63
+@@
64
+- hashcmp(E1->hash, E2.hash)
65
++ oidcmp(E1, &E2)
66
+
67
+@@
68
+expression E1, E2;
69
+@@
70
+- hashcmp(E1.hash, E2->hash)
71
++ oidcmp(&E1, E2)
72
+
73
+@@
74
+expression E1, E2;
75
+@@
76
+- hashcpy(E1.hash, E2.hash)
77
++ oidcpy(&E1, &E2)
78
+
79
+@@
80
+expression E1, E2;
81
+@@
82
+- hashcpy(E1->hash, E2->hash)
83
++ oidcpy(E1, E2)
84
+
85
+@@
86
+expression E1, E2;
87
+@@
88
+- hashcpy(E1->hash, E2.hash)
89
++ oidcpy(E1, &E2)
90
+
91
+@@
92
+expression E1, E2;
93
+@@
94
+- hashcpy(E1.hash, E2->hash)
95
++ oidcpy(&E1, E2)