MCPcopy Create free account
hub / github.com/git/git / add_promisor_object

Function add_promisor_object

packfile.c:2726–2779  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2724};
2725
2726static int add_promisor_object(const struct object_id *oid,
2727 struct object_info *oi UNUSED,
2728 void *cb_data)
2729{
2730 struct add_promisor_object_data *data = cb_data;
2731 struct object *obj;
2732 int we_parsed_object;
2733
2734 obj = lookup_object(data->repo, oid);
2735 if (obj && obj->parsed) {
2736 we_parsed_object = 0;
2737 } else {
2738 we_parsed_object = 1;
2739 obj = parse_object_with_flags(data->repo, oid,
2740 PARSE_OBJECT_SKIP_HASH_CHECK);
2741 }
2742
2743 if (!obj)
2744 return 1;
2745
2746 oidset_insert(data->set, oid);
2747
2748 /*
2749 * If this is a tree, commit, or tag, the objects it refers
2750 * to are also promisor objects. (Blobs refer to no objects->)
2751 */
2752 if (obj->type == OBJ_TREE) {
2753 struct tree *tree = (struct tree *)obj;
2754 struct tree_desc desc;
2755 struct name_entry entry;
2756 if (init_tree_desc_gently(&desc, &tree->object.oid,
2757 tree->buffer, tree->size, 0))
2758 /*
2759 * Error messages are given when packs are
2760 * verified, so do not print any here.
2761 */
2762 return 0;
2763 while (tree_entry_gently(&desc, &entry))
2764 oidset_insert(data->set, &entry.oid);
2765 if (we_parsed_object)
2766 free_tree_buffer(tree);
2767 } else if (obj->type == OBJ_COMMIT) {
2768 struct commit *commit = (struct commit *) obj;
2769 struct commit_list *parents = commit->parents;
2770
2771 oidset_insert(data->set, get_commit_tree_oid(commit));
2772 for (; parents; parents = parents->next)
2773 oidset_insert(data->set, &parents->item->object.oid);
2774 } else if (obj->type == OBJ_TAG) {
2775 struct tag *tag = (struct tag *) obj;
2776 oidset_insert(data->set, get_tagged_oid(tag));
2777 }
2778 return 0;
2779}
2780
2781int is_promisor_object(struct repository *r, const struct object_id *oid)
2782{

Callers

nothing calls this directly

Calls 8

lookup_objectFunction · 0.85
parse_object_with_flagsFunction · 0.85
oidset_insertFunction · 0.85
init_tree_desc_gentlyFunction · 0.85
tree_entry_gentlyFunction · 0.85
free_tree_bufferFunction · 0.85
get_commit_tree_oidFunction · 0.85
get_tagged_oidFunction · 0.85

Tested by

no test coverage detected