summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 3a663fd)
raw | patch | inline | side by side (parent: 3a663fd)
author | Daniel Barkalow <barkalow@iabervon.org> | |
Thu, 28 Apr 2005 14:46:33 +0000 (07:46 -0700) | ||
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | |
Thu, 28 Apr 2005 14:46:33 +0000 (07:46 -0700) |
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>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
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>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
blob.c | patch | blob | history | |
blob.h | patch | blob | history |
index 3d99b93f020d84c5410c2b1056f2d7446b647d1e..d4af4a309433744d2fe819886d66741ab016f62b 100644 (file)
--- a/blob.c
+++ b/blob.c
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;
+}