Re: [ANNOUNCE] Git v2.19.0-rc0
- From
Jeff King <peff@peff.net>
- Date
- Aug 24, 2018, 02:59 UTC
- Message-ID
- <20180824025955.GA24535@sigill.intra.peff.net>
- In-Reply-To
- <CA+P7+xpm-gsjCpPOZ=2z03Peb1Jb6axKo2nTp=UUpAFgWNureg@mail.gmail.com>
On Thu, Aug 23, 2018 at 07:48:42PM -0700, Jacob Keller wrote:
Show 7 quoted lines
> Odd...
>
> What about..
>
> - if (oidcmp(a,b))
> + if(!oideq(a,b))
> { ... }Nope, it doesn't like that syntactically.
Show 6 quoted lines
> Or maybe you need to use something like > > <... > - if (oidcmp(a,b)) > + if (!oideq(a,b)) > ...>
Nor that (I also tried finding documentation on what exactly the angle brackets mean, but couldn't).
> Hmm. Yea, semantic patches are a bit confusing overall sometimes. > > But it looks like you got something which works?
Actually, what I showed earlier does seem to have some weirdness with else-if. But I finally stumbled on something even better:
- oidcmp(a, b) != 0 + !oideq(a, b)
Because of the isomorphisms that coccinelle knows about, that catches everything we want. Obvious ones like:
diff --git a/bisect.c b/bisect.c index 41c56a665e..7c1d8f1a6d 100644 --- a/bisect.c +++ b/bisect.c @@ -595,7 +595,7 @@ static struct commit_list *skip_away(struct commit_list *list, int count) 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; and compound conditionals like: diff --git a/blame.c b/blame.c index 10d72e36dd..538d0ab1aa 100644 --- a/blame.c +++ b/blame.c @@ -1834,7 +1834,7 @@ void setup_scoreboard(struct blame_scoreboard *sb, sb->revs->children.name = "children"; while (c->parents && - oidcmp(&c->object.oid, &sb->final->object.oid)) { + !oideq(&c->object.oid, &sb->final->object.oid)) { struct commit_list *l = xcalloc(1, sizeof(*l)); l->item = c; and even non-if contexts, like: diff --git a/sha1-file.c b/sha1-file.c index 631f6b9dc2..d85f4e93e1 100644 --- a/sha1-file.c +++ b/sha1-file.c @@ -825,7 +825,7 @@ int check_object_signature(const struct object_id *oid, void *map, if (map) { hash_object_file(map, size, type, &real_oid); - return oidcmp(oid, &real_oid) ? -1 : 0; + return !oideq(oid, &real_oid) ? -1 : 0; } So I think we have a winner. I'll polish that up into patches and send it out later tonight. -Peff