Re: [PATCH 1/8] Add basic Coccinelle transforms.

2 messages, 2 authors, 2016-06-16 · open the first message on its own page

Re: [PATCH 1/8] Add basic Coccinelle transforms.

From: Junio C Hamano <hidden>
Date: 2016-06-16 02:19:46

"brian m. carlson" [off-list ref] writes:
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.

Signed-off-by: brian m. carlson <redacted>
---
I realize the name and location of this file might be suboptimal.
Suggestions on better locations and filenames would be appreciated.
Once is_null_sha1() is updated to is_null_oid(), the first rewrite
definition would become useless, no?  I am not sure what the point
is to keep this file in our history.
quoted hunk
 standard.cocci | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 83 insertions(+)
 create mode 100644 standard.cocci
diff --git a/standard.cocci b/standard.cocci
new file mode 100644
index 00000000..0f068252
--- /dev/null
+++ b/standard.cocci
@@ -0,0 +1,83 @@
+@@
+expression E1;
+@@
+- is_null_sha1(E1.hash)
++ is_null_oid(&E1)
+
+@@
+expression E1;
+@@
+- is_null_sha1(E1->hash)
++ is_null_oid(E1)
+
+@@
+expression E1;
+@@
+- sha1_to_hex(E1.hash)
++ oid_to_hex(&E1)
+
+@@
+expression E1;
+@@
+- sha1_to_hex(E1->hash)
++ oid_to_hex(E1)
+
+@@
+expression E1;
+@@
+- hashclr(E1.hash)
++ oidclr(&E1)
+
+@@
+expression E1;
+@@
+- hashclr(E1->hash)
++ oidclr(E1)
+
+@@
+expression E1, E2;
+@@
+- hashcmp(E1.hash, E2.hash)
++ oidcmp(&E1, &E2)
+
+@@
+expression E1, E2;
+@@
+- hashcmp(E1->hash, E2->hash)
++ oidcmp(E1, E2)
+
+@@
+expression E1, E2;
+@@
+- hashcmp(E1->hash, E2.hash)
++ oidcmp(E1, &E2)
+
+@@
+expression E1, E2;
+@@
+- hashcmp(E1.hash, E2->hash)
++ oidcmp(&E1, E2)
+
+@@
+expression E1, E2;
+@@
+- hashcpy(E1.hash, E2.hash)
++ oidcpy(&E1, &E2)
+
+@@
+expression E1, E2;
+@@
+- hashcpy(E1->hash, E2->hash)
++ oidcpy(E1, E2)
+
+@@
+expression E1, E2;
+@@
+- hashcpy(E1->hash, E2.hash)
++ oidcpy(E1, &E2)
+
+@@
+expression E1, E2;
+@@
+- hashcpy(E1.hash, E2->hash)
++ oidcpy(&E1, E2)

Re: [PATCH 1/8] Add basic Coccinelle transforms.

From: brian m. carlson <hidden>
Date: 2016-06-16 02:19:46

On Mon, Jun 06, 2016 at 07:28:28PM -0700, Junio C Hamano wrote:
"brian m. carlson" [off-list ref] writes:
quoted
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.

Signed-off-by: brian m. carlson <redacted>
---
I realize the name and location of this file might be suboptimal.
Suggestions on better locations and filenames would be appreciated.
Once is_null_sha1() is updated to is_null_oid(), the first rewrite
definition would become useless, no?  I am not sure what the point
is to keep this file in our history.
It might not be generally useful to keep forever.  I generally have
applied this set of transforms after each of the other semantic patches,
but I can simply refer to "a standard set of transforms" if you think
that's better, or I can post a URL with those somewhere to refer to.

My goal here is simply to avoid needing to include this set of
transformations in each commit message, which would tend to bloat it
considerably.
-- 
brian m. carlson / brian with sandals: Houston, Texas, US
+1 832 623 2791 | https://www.crustytoothpaste.net/~bmc | My opinion only
OpenPGP: https://keybase.io/bk2204
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help