X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=object.c;h=0498b18d451b2335d21e2db3edc0ce7838aaa50e;hb=09b90fb3c065ac5ac2ad051596b036131ecedbd5;hp=d8d09f92aacd114e23378af2cfbeb78a3dd785a0;hpb=147d071816c7011d24c195a9d6fca251ad312532;p=git.git diff --git a/object.c b/object.c index d8d09f92a..0498b18d4 100644 --- a/object.c +++ b/object.c @@ -191,10 +191,26 @@ struct object *parse_object(const unsigned char *sha1) enum object_type type; int eaten; const unsigned char *repl = lookup_replace_object(sha1); - void *buffer = read_sha1_file(sha1, &type, &size); + void *buffer; + struct object *obj; + + obj = lookup_object(sha1); + if (obj && obj->parsed) + return obj; + + if ((obj && obj->type == OBJ_BLOB) || + (!obj && has_sha1_file(sha1) && + sha1_object_info(sha1, NULL) == OBJ_BLOB)) { + if (check_sha1_signature(repl, NULL, 0, NULL) < 0) { + error("sha1 mismatch %s\n", sha1_to_hex(repl)); + return NULL; + } + parse_blob_buffer(lookup_blob(sha1), NULL, 0); + return lookup_object(sha1); + } + buffer = read_sha1_file(sha1, &type, &size); if (buffer) { - struct object *obj; if (check_sha1_signature(repl, buffer, size, typename(type)) < 0) { free(buffer); error("sha1 mismatch %s\n", sha1_to_hex(repl));