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

Function lookup_object

object.c:92–118  ·  view source on GitHub ↗

* Look up the record for the given sha1 in the hash map stored in * obj_hash. Return NULL if it was not found. */

Source from the content-addressed store, hash-verified

90 * obj_hash. Return NULL if it was not found.
91 */
92struct object *lookup_object(struct repository *r, const struct object_id *oid)
93{
94 unsigned int i, first;
95 struct object *obj;
96
97 if (!r->parsed_objects->obj_hash)
98 return NULL;
99
100 first = i = hash_obj(oid, r->parsed_objects->obj_hash_size);
101 while ((obj = r->parsed_objects->obj_hash[i]) != NULL) {
102 if (oideq(oid, &obj->oid))
103 break;
104 i++;
105 if (i == r->parsed_objects->obj_hash_size)
106 i = 0;
107 }
108 if (obj && i != first) {
109 /*
110 * Move object to where we started to look for it so
111 * that we do not need to walk the hash table the next
112 * time we look for it.
113 */
114 SWAP(r->parsed_objects->obj_hash[i],
115 r->parsed_objects->obj_hash[first]);
116 }
117 return obj;
118}
119
120/*
121 * Increase the size of the hash map stored in obj_hash to the next

Callers 15

lookup_tagFunction · 0.85
find_commonFunction · 0.85
everything_localFunction · 0.85
add_wantsFunction · 0.85
receive_shallow_infoFunction · 0.85
add_to_object_arrayFunction · 0.85
clear_common_flagFunction · 0.85
lookup_blobFunction · 0.85
one_remote_objectFunction · 0.85
add_promisor_objectFunction · 0.85
lookup_treeFunction · 0.85
lookup_unknown_objectFunction · 0.85

Calls 2

oideqFunction · 0.85
hash_objFunction · 0.70

Tested by

no test coverage detected