* When we cannot load the full patch-id for both commits for whatever * reason, the function returns -1 (i.e. return error(...)). Despite * the "neq" in the name of this function, the caller only cares about * the return value being zero (a and b are equivalent) or non-zero (a * and b are different), and returning non-zero would keep both in the * result, even if they actually were equivalent
| 37 | * any significance; only that it is non-zero matters. |
| 38 | */ |
| 39 | static int patch_id_neq(const void *cmpfn_data, |
| 40 | const struct hashmap_entry *eptr, |
| 41 | const struct hashmap_entry *entry_or_key, |
| 42 | const void *keydata UNUSED) |
| 43 | { |
| 44 | /* |
| 45 | * We drop the 'const' modifier here intentionally. |
| 46 | * |
| 47 | * Even though eptr and entry_or_key are const, we want to |
| 48 | * lazily compute their .patch_id members; see b3dfeebb (rebase: |
| 49 | * avoid computing unnecessary patch IDs, 2016-07-29). So we cast |
| 50 | * the constness away with container_of(). |
| 51 | */ |
| 52 | struct diff_options *opt = (void *)cmpfn_data; |
| 53 | struct patch_id *a, *b; |
| 54 | |
| 55 | a = container_of(eptr, struct patch_id, ent); |
| 56 | b = container_of(entry_or_key, struct patch_id, ent); |
| 57 | |
| 58 | if (is_null_oid(&a->patch_id) && |
| 59 | commit_patch_id(a->commit, opt, &a->patch_id, 0)) |
| 60 | return error("Could not get patch ID for %s", |
| 61 | oid_to_hex(&a->commit->object.oid)); |
| 62 | if (is_null_oid(&b->patch_id) && |
| 63 | commit_patch_id(b->commit, opt, &b->patch_id, 0)) |
| 64 | return error("Could not get patch ID for %s", |
| 65 | oid_to_hex(&b->commit->object.oid)); |
| 66 | return !oideq(&a->patch_id, &b->patch_id); |
| 67 | } |
| 68 | |
| 69 | int init_patch_ids(struct repository *r, struct patch_ids *ids) |
| 70 | { |
nothing calls this directly
no test coverage detected