On Thu, Aug 23, 2018 at 07:40:49PM -0400, Jeff King wrote: > > You can look for explicitly "if (oidcmp(...))" though. I don't know if > > you can catch *any* use which degrades to boolean outside of an if > > statement, but I wouldn't expect there to be too many of those? > > Yeah, that was my thought, too. And I've been trying this all afternoon > without success. Why doesn't this work: > > @@ > expression a, b; > @@ > - if (oidcmp(a, b)) > + if (!oideq(a, b)) > > I get: > > Fatal error: exception Failure("minus: parse error: \n = File > \"contrib/coccinelle/oideq.cocci\", line 21, column 0, charpos = > 221\n around = '', whole content = \n") > > If I do: > > - if (oidcmp(a, b)) { ... } > > that seems to please the parser for the minus line. But I cannot include > the "..." on the plus line. Clearly the "..." part should be context, > but I can't seem to find the right syntax. This almost works: @@ expression a, b; statement s; @@ - if (oidcmp(a, b)) s + if (!oideq(a, b)) s It generates this, for example: diff -u -p a/bisect.c b/bisect.c --- a/bisect.c +++ b/bisect.c @@ -595,7 +595,7 @@ static struct commit_list *skip_away(str for (i = 0; cur; cur = cur->next, i++) { if (i == index) { - if (oidcmp(&cur->item->object.oid, current_bad_oid)) + if (!oideq(&cur->item->object.oid, current_bad_oid)) return cur; if (previous) return previous; which is what we want. But it also generates this: diff -u -p a/bundle.c b/bundle.c --- a/bundle.c +++ b/bundle.c @@ -369,25 +369,11 @@ static int write_bundle_refs(int bundle_ * commit that is referenced by the tag, and not the tag * itself. */ - if (oidcmp(&oid, &e->item->oid)) { - /* - * Is this the positive end of a range expressed - * in terms of a tag (e.g. v2.0 from the range - * "v1.0..v2.0")? - */ - struct commit *one = lookup_commit_reference(the_repository, - &oid); + if (!oideq(&oid, &e->item->oid)) { + struct commit *one=lookup_commit_reference(the_repository, + &oid); struct object *obj; - if (e->item == &(one->object)) { - /* - * Need to include e->name as an - * independent ref to the pack-objects - * input, so that the tag is included - * in the output; otherwise we would - * end up triggering "empty bundle" - * error. - */ obj = parse_object_or_die(&oid, e->name); obj->flags |= SHOWN; add_pending_object(revs, obj, e->name); So I really do want some way of saying "all of the block, no matter what it is". Or of leaving it out as context. -Peff