treewide: correct several "up-to-date" to "up to date"
[gitweb.git] / object.c
index e680d881a45756eb234a80a9909c24a7b146c1f7..f818777412187890b88a6c90507b8b41f131487c 100644 (file)
--- a/object.c
+++ b/object.c
@@ -180,21 +180,21 @@ struct object *lookup_unknown_object(const unsigned char *sha1)
        return obj;
 }
 
-struct object *parse_object_buffer(const unsigned char *sha1, enum object_type type, unsigned long size, void *buffer, int *eaten_p)
+struct object *parse_object_buffer(const struct object_id *oid, enum object_type type, unsigned long size, void *buffer, int *eaten_p)
 {
        struct object *obj;
        *eaten_p = 0;
 
        obj = NULL;
        if (type == OBJ_BLOB) {
-               struct blob *blob = lookup_blob(sha1);
+               struct blob *blob = lookup_blob(oid);
                if (blob) {
                        if (parse_blob_buffer(blob, buffer, size))
                                return NULL;
                        obj = &blob->object;
                }
        } else if (type == OBJ_TREE) {
-               struct tree *tree = lookup_tree(sha1);
+               struct tree *tree = lookup_tree(oid);
                if (tree) {
                        obj = &tree->object;
                        if (!tree->buffer)
@@ -206,7 +206,7 @@ struct object *parse_object_buffer(const unsigned char *sha1, enum object_type t
                        }
                }
        } else if (type == OBJ_COMMIT) {
-               struct commit *commit = lookup_commit(sha1);
+               struct commit *commit = lookup_commit(oid);
                if (commit) {
                        if (parse_commit_buffer(commit, buffer, size))
                                return NULL;
@@ -217,54 +217,54 @@ struct object *parse_object_buffer(const unsigned char *sha1, enum object_type t
                        obj = &commit->object;
                }
        } else if (type == OBJ_TAG) {
-               struct tag *tag = lookup_tag(sha1);
+               struct tag *tag = lookup_tag(oid);
                if (tag) {
                        if (parse_tag_buffer(tag, buffer, size))
                               return NULL;
                        obj = &tag->object;
                }
        } else {
-               warning("object %s has unknown type id %d", sha1_to_hex(sha1), type);
+               warning("object %s has unknown type id %d", oid_to_hex(oid), type);
                obj = NULL;
        }
        return obj;
 }
 
-struct object *parse_object_or_die(const unsigned char *sha1,
+struct object *parse_object_or_die(const struct object_id *oid,
                                   const char *name)
 {
-       struct object *o = parse_object(sha1);
+       struct object *o = parse_object(oid);
        if (o)
                return o;
 
-       die(_("unable to parse object: %s"), name ? name : sha1_to_hex(sha1));
+       die(_("unable to parse object: %s"), name ? name : oid_to_hex(oid));
 }
 
-struct object *parse_object(const unsigned char *sha1)
+struct object *parse_object(const struct object_id *oid)
 {
        unsigned long size;
        enum object_type type;
        int eaten;
-       const unsigned char *repl = lookup_replace_object(sha1);
+       const unsigned char *repl = lookup_replace_object(oid->hash);
        void *buffer;
        struct object *obj;
 
-       obj = lookup_object(sha1);
+       obj = lookup_object(oid->hash);
        if (obj && obj->parsed)
                return obj;
 
        if ((obj && obj->type == OBJ_BLOB) ||
-           (!obj && has_sha1_file(sha1) &&
-            sha1_object_info(sha1, NULL) == OBJ_BLOB)) {
+           (!obj && has_object_file(oid) &&
+            sha1_object_info(oid->hash, NULL) == OBJ_BLOB)) {
                if (check_sha1_signature(repl, NULL, 0, NULL) < 0) {
-                       error("sha1 mismatch %s", sha1_to_hex(repl));
+                       error("sha1 mismatch %s", oid_to_hex(oid));
                        return NULL;
                }
-               parse_blob_buffer(lookup_blob(sha1), NULL, 0);
-               return lookup_object(sha1);
+               parse_blob_buffer(lookup_blob(oid), NULL, 0);
+               return lookup_object(oid->hash);
        }
 
-       buffer = read_sha1_file(sha1, &type, &size);
+       buffer = read_sha1_file(oid->hash, &type, &size);
        if (buffer) {
                if (check_sha1_signature(repl, buffer, size, typename(type)) < 0) {
                        free(buffer);
@@ -272,7 +272,7 @@ struct object *parse_object(const unsigned char *sha1)
                        return NULL;
                }
 
-               obj = parse_object_buffer(sha1, type, size, buffer, &eaten);
+               obj = parse_object_buffer(oid, type, size, buffer, &eaten);
                if (!eaten)
                        free(buffer);
                return obj;
@@ -377,8 +377,7 @@ void object_array_clear(struct object_array *array)
        int i;
        for (i = 0; i < array->nr; i++)
                object_array_release_entry(&array->objects[i]);
-       free(array->objects);
-       array->objects = NULL;
+       FREE_AND_NULL(array->objects);
        array->nr = array->alloc = 0;
 }