* the specified sha1. n must be a power of 2. Please note that the
* return value is *not* consistent across computer architectures.
*/
-static unsigned int hash_obj(const unsigned char *sha1, unsigned int n)
+static unsigned int hash_obj(const struct object_id *oid, unsigned int n)
{
- return sha1hash(sha1) & (n - 1);
+ return oidhash(oid) & (n - 1);
}
/*
*/
static void insert_obj_hash(struct object *obj, struct object **hash, unsigned int size)
{
- unsigned int j = hash_obj(obj->oid.hash, size);
+ unsigned int j = hash_obj(&obj->oid, size);
while (hash[j]) {
j++;
* Look up the record for the given sha1 in the hash map stored in
* obj_hash. Return NULL if it was not found.
*/
-struct object *lookup_object(struct repository *r, const unsigned char *sha1)
+struct object *lookup_object(struct repository *r, const struct object_id *oid)
{
unsigned int i, first;
struct object *obj;
if (!r->parsed_objects->obj_hash)
return NULL;
- first = i = hash_obj(sha1, r->parsed_objects->obj_hash_size);
+ first = i = hash_obj(oid, r->parsed_objects->obj_hash_size);
while ((obj = r->parsed_objects->obj_hash[i]) != NULL) {
- if (hasheq(sha1, obj->oid.hash))
+ if (oideq(oid, &obj->oid))
break;
i++;
if (i == r->parsed_objects->obj_hash_size)
r->parsed_objects->obj_hash_size = new_hash_size;
}
-void *create_object(struct repository *r, const unsigned char *sha1, void *o)
+void *create_object(struct repository *r, const struct object_id *oid, void *o)
{
struct object *obj = o;
obj->parsed = 0;
obj->flags = 0;
- hashcpy(obj->oid.hash, sha1);
+ oidcpy(&obj->oid, oid);
if (r->parsed_objects->obj_hash_size - 1 <= r->parsed_objects->nr_objs * 2)
grow_object_hash(r);
}
}
-struct object *lookup_unknown_object(const unsigned char *sha1)
+struct object *lookup_unknown_object(const struct object_id *oid)
{
- struct object *obj = lookup_object(the_repository, sha1);
+ struct object *obj = lookup_object(the_repository, oid);
if (!obj)
- obj = create_object(the_repository, sha1,
+ obj = create_object(the_repository, oid,
alloc_object_node(the_repository));
return obj;
}
void *buffer;
struct object *obj;
- obj = lookup_object(r, oid->hash);
+ obj = lookup_object(r, oid);
if (obj && obj->parsed)
return obj;
return NULL;
}
parse_blob_buffer(lookup_blob(r, oid), NULL, 0);
- return lookup_object(r, oid->hash);
+ return lookup_object(r, oid);
}
buffer = repo_read_object_file(r, oid, &type, &size);