]> git.ipfire.org Git - thirdparty/git.git/blobdiff - object.c
l10n: it.po: update the Italian translation for Git 2.24.0 round #2
[thirdparty/git.git] / object.c
index cf1a2b708612a0e335893fadee0952e620400c5f..3b8b8c55c9a8e7e2961d9911f1ec4fd70730f07f 100644 (file)
--- a/object.c
+++ b/object.c
@@ -7,7 +7,6 @@
 #include "commit.h"
 #include "tag.h"
 #include "alloc.h"
-#include "object-store.h"
 #include "packfile.h"
 #include "commit-graph.h"
 
@@ -59,9 +58,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 oidhash(oid) & (n - 1);
 }
 
 /*
@@ -71,7 +70,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++;
@@ -85,7 +84,7 @@ static void insert_obj_hash(struct object *obj, struct object **hash, unsigned i
  * 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;
@@ -93,9 +92,9 @@ struct object *lookup_object(struct repository *r, const unsigned char *sha1)
        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)
@@ -141,13 +140,13 @@ static void grow_object_hash(struct repository *r)
        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);
@@ -178,11 +177,11 @@ void *object_as_type(struct repository *r, struct object *obj, enum object_type
        }
 }
 
-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;
 }
@@ -256,7 +255,7 @@ struct object *parse_object(struct repository *r, const struct object_id *oid)
        void *buffer;
        struct object *obj;
 
-       obj = lookup_object(r, oid->hash);
+       obj = lookup_object(r, oid);
        if (obj && obj->parsed)
                return obj;
 
@@ -268,7 +267,7 @@ struct object *parse_object(struct repository *r, const struct object_id *oid)
                        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);