MCPcopy Index your code
hub / github.com/git/git / patch_id_neq

Function patch_id_neq

patch-ids.c:39–67  ·  view source on GitHub ↗

* 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

Source from the content-addressed store, hash-verified

37 * any significance; only that it is non-zero matters.
38 */
39static 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
69int init_patch_ids(struct repository *r, struct patch_ids *ids)
70{

Callers

nothing calls this directly

Calls 5

is_null_oidFunction · 0.85
commit_patch_idFunction · 0.85
errorFunction · 0.85
oid_to_hexFunction · 0.85
oideqFunction · 0.85

Tested by

no test coverage detected