summaryrefslogtreecommitdiff
path: root/object.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2019-06-20 07:41:17 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-06-20 17:19:37 (GMT)
commit46931d39389f2886e6c159674923345f024e1c64 (patch)
treea72422ed1865233450d9ddc4eb5876799bba0613 /object.c
parentd0229abd93e1115d935b0e55067e29bcc9815ce8 (diff)
downloadgit-46931d39389f2886e6c159674923345f024e1c64.zip
git-46931d39389f2886e6c159674923345f024e1c64.tar.gz
git-46931d39389f2886e6c159674923345f024e1c64.tar.bz2
object: convert internal hash_obj() to object_id
Now that lookup_object() has an object_id, we can consistently pass that around instead of a raw sha1. We still convert to a hash to pass to sha1hash(), but the goal is for that to go away shortly. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'object.c')
-rw-r--r--object.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/object.c b/object.c
index 34c1d0d..dbfdbe5 100644
--- a/object.c
+++ b/object.c
@@ -59,9 +59,9 @@ int type_from_string_gently(const char *str, ssize_t len, int gentle)
* 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 sha1hash(oid->hash) & (n - 1);
}
/*
@@ -71,7 +71,7 @@ static unsigned int hash_obj(const unsigned char *sha1, unsigned int n)
*/
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++;
@@ -93,7 +93,7 @@ struct object *lookup_object(struct repository *r, const struct object_id *oid)
if (!r->parsed_objects->obj_hash)
return NULL;
- first = i = hash_obj(oid->hash, 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 (oideq(oid, &obj->oid))
break;