struct patch_id *has_commit_patch_id(struct commit *commit, struct patch_ids *ids) { struct patch_id patch; if (!patch_id_defined(commit)) return NULL; memset(&patch, 0, sizeof(patch)); if (init_patch_id_entry(&patch, commit, ids)) return NULL; return hashmap_get(&ids->patches, &patch, NULL); }
int commit_patch_id(struct commit *commit, struct diff_options *options, struct object_id *oid, int diff_header_only) { if (!patch_id_defined(commit)) return -1; if (commit->parents) diff_tree_oid(&commit->parents->item->object.oid, &commit->object.oid, "", options); else diff_root_tree_oid(&commit->object.oid, "", options); diffcore_std(options); return diff_flush_patch_id(options, oid, diff_header_only); }
int commit_patch_id(struct commit *commit, struct diff_options *options, unsigned char *sha1, int diff_header_only) { if (!patch_id_defined(commit)) return -1; if (commit->parents) diff_tree_sha1(commit->parents->item->object.oid.hash, commit->object.oid.hash, "", options); else diff_root_tree_sha1(commit->object.oid.hash, "", options); diffcore_std(options); return diff_flush_patch_id(options, sha1, diff_header_only); }
struct patch_id *add_commit_patch_id(struct commit *commit, struct patch_ids *ids) { struct patch_id *key = xcalloc(1, sizeof(*key)); if (!patch_id_defined(commit)) return NULL; if (init_patch_id_entry(key, commit, ids)) { free(key); return NULL; } hashmap_add(&ids->patches, key); return key; }