Convert remaining callers of sha1_object_info_extended to object_id
[gitweb.git] / object.c
index 0afdfd19b784a541ad6d7237add2fbb1c9ec91ab..68bcf35d955a03f87ffe956de08fb3f7c30791a1 100644 (file)
--- a/object.c
+++ b/object.c
@@ -26,7 +26,7 @@ static const char *object_type_strings[] = {
        "tag",          /* OBJ_TAG = 4 */
 };
 
-const char *typename(unsigned int type)
+const char *type_name(unsigned int type)
 {
        if (type >= ARRAY_SIZE(object_type_strings))
                return NULL;
@@ -166,7 +166,7 @@ void *object_as_type(struct object *obj, enum object_type type, int quiet)
                if (!quiet)
                        error("object %s is a %s, not a %s",
                              oid_to_hex(&obj->oid),
-                             typename(obj->type), typename(type));
+                             type_name(obj->type), type_name(type));
                return NULL;
        }
 }
@@ -252,10 +252,13 @@ struct object *parse_object(const struct object_id *oid)
        if (obj && obj->parsed)
                return obj;
 
-       if ((obj && obj->type == OBJ_BLOB) ||
+       if ((obj && obj->type == OBJ_BLOB && has_object_file(oid)) ||
            (!obj && has_object_file(oid) &&
             sha1_object_info(oid->hash, NULL) == OBJ_BLOB)) {
-               if (check_sha1_signature(repl, NULL, 0, NULL) < 0) {
+               struct object_id reploid;
+               hashcpy(reploid.hash, repl);
+
+               if (check_object_signature(&reploid, NULL, 0, NULL) < 0) {
                        error("sha1 mismatch %s", oid_to_hex(oid));
                        return NULL;
                }
@@ -265,7 +268,10 @@ struct object *parse_object(const struct object_id *oid)
 
        buffer = read_sha1_file(oid->hash, &type, &size);
        if (buffer) {
-               if (check_sha1_signature(repl, buffer, size, typename(type)) < 0) {
+               struct object_id reploid;
+               hashcpy(reploid.hash, repl);
+
+               if (check_object_signature(&reploid, buffer, size, type_name(type)) < 0) {
                        free(buffer);
                        error("sha1 mismatch %s", sha1_to_hex(repl));
                        return NULL;