summaryrefslogtreecommitdiff
path: root/contrib/coccinelle
diff options
context:
space:
mode:
authorLibravatar Jeff King <peff@peff.net>2018-08-28 17:22:48 -0400
committerLibravatar Junio C Hamano <gitster@pobox.com>2018-08-29 11:32:49 -0700
commit9001dc2a7493f1366a183c3a9175f608769321d5 (patch)
tree58340f7fbbbf2c49b376c43beac13ab7e39bf5dd /contrib/coccinelle
parentconvert "hashcmp() == 0" to hasheq() (diff)
downloadtgif-9001dc2a7493f1366a183c3a9175f608769321d5.tar.xz
convert "oidcmp() != 0" to "!oideq()"
This is the flip side of the previous two patches: checking for a non-zero oidcmp() can be more strictly expressed as inequality. Like those patches, we write "!= 0" in the coccinelle transformation, which covers by isomorphism the more common: if (oidcmp(E1, E2)) As with the previous two patches, this patch can be achieved almost entirely by running "make coccicheck"; the only differences are manual line-wrap fixes to match the original code. There is one thing to note for anybody replicating this, though: coccinelle 1.0.4 seems to miss the case in builtin/tag.c, even though it's basically the same as all the others. Running with 1.0.7 does catch this, so presumably it's just a coccinelle bug that was fixed in the interim. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'contrib/coccinelle')
-rw-r--r--contrib/coccinelle/object_id.cocci6
1 files changed, 6 insertions, 0 deletions
diff --git a/contrib/coccinelle/object_id.cocci b/contrib/coccinelle/object_id.cocci
index d90ba8a040..4e1f1a7431 100644
--- a/contrib/coccinelle/object_id.cocci
+++ b/contrib/coccinelle/object_id.cocci
@@ -123,3 +123,9 @@ expression E1, E2;
- hashcmp(E1, E2) == 0
+ hasheq(E1, E2)
...>}
+
+@@
+expression E1, E2;
+@@
+- oidcmp(E1, E2) != 0
++ !oideq(E1, E2)