This eliminates the special case for blobs versus other types of objects. Now the scheme is entirely regular and I won't introduce stupid bugs. (And fsck-cache doesn't have to do the do-nothing parse) Signed-Off-By: Daniel Barkalow <barkalow@iabervon.org> Index: blob.c =================================================================== --- 89fdfd09b281fdf5071bc13a30ef683bd6851b61/blob.c (mode:100644 sha1:3d99b93f020d84c5410c2b1056f2d7446b647d1e) +++ bcb43fecd82fa6f851e266b7e3873973068d51f3/blob.c (mode:100644 sha1:d4af4a309433744d2fe819886d66741ab016f62b) @@ -14,10 +14,28 @@ ret->object.type = blob_type; return ret; } - if (obj->parsed && obj->type != blob_type) { + if (obj->type != blob_type) { error("Object %s is a %s, not a blob", sha1_to_hex(sha1), obj->type); return NULL; } return (struct blob *) obj; } + +int parse_blob(struct blob *item) +{ + char type[20]; + void *buffer; + unsigned long size; + if (item->object.parsed) + return 0; + item->object.parsed = 1; + buffer = read_sha1_file(item->object.sha1, type, &size); + if (!buffer) + return error("Could not read %s", + sha1_to_hex(item->object.sha1)); + if (strcmp(type, blob_type)) + return error("Object %s not a blob", + sha1_to_hex(item->object.sha1)); + return 0; +} Index: blob.h =================================================================== --- 89fdfd09b281fdf5071bc13a30ef683bd6851b61/blob.h (mode:100644 sha1:5cbf6d65ee88e1e0c0f1153af4aa7f80c3c48c16) +++ bcb43fecd82fa6f851e266b7e3873973068d51f3/blob.h (mode:100644 sha1:4afad0f067e1979d7ccc4778e254cce6962ad136) @@ -11,4 +11,6 @@ struct blob *lookup_blob(unsigned char *sha1); +int parse_blob(struct blob *item); + #endif /* BLOB_H */ - To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.htmlReceived on Thu Apr 28 16:02:20 2005
This archive was generated by hypermail 2.1.8 : 2005-04-28 16:02:21 EST