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>
This commit is contained in:
committed by
Junio C Hamano
parent
e3ff0683e2
commit
9001dc2a74
6
diff.c
6
diff.c
@ -3765,7 +3765,7 @@ static int reuse_worktree_file(const char *name, const struct object_id *oid, in
|
||||
* This is not the sha1 we are looking for, or
|
||||
* unreusable because it is not a regular file.
|
||||
*/
|
||||
if (oidcmp(oid, &ce->oid) || !S_ISREG(ce->ce_mode))
|
||||
if (!oideq(oid, &ce->oid) || !S_ISREG(ce->ce_mode))
|
||||
return 0;
|
||||
|
||||
/*
|
||||
@ -4170,7 +4170,7 @@ static void fill_metainfo(struct strbuf *msg,
|
||||
default:
|
||||
*must_show_header = 0;
|
||||
}
|
||||
if (one && two && oidcmp(&one->oid, &two->oid)) {
|
||||
if (one && two && !oideq(&one->oid, &two->oid)) {
|
||||
const unsigned hexsz = the_hash_algo->hexsz;
|
||||
int abbrev = o->flags.full_index ? hexsz : DEFAULT_ABBREV;
|
||||
|
||||
@ -5457,7 +5457,7 @@ static void diff_resolve_rename_copy(void)
|
||||
else
|
||||
p->status = DIFF_STATUS_RENAMED;
|
||||
}
|
||||
else if (oidcmp(&p->one->oid, &p->two->oid) ||
|
||||
else if (!oideq(&p->one->oid, &p->two->oid) ||
|
||||
p->one->mode != p->two->mode ||
|
||||
p->one->dirty_submodule ||
|
||||
p->two->dirty_submodule ||
|
||||
|
||||
Reference in New Issue
Block a user