blob: ae320bd8fa22aaaef8144bd6bc35c20d1e85e4f4 [file] [log] [blame]
Daniel Barkalow175785e2005-04-18 11:39:48 -07001#include "cache.h"
Junio C Hamano8f1d2e62006-01-07 01:33:54 -08002#include "blob.h"
Daniel Barkalow175785e2005-04-18 11:39:48 -07003
4const char *blob_type = "blob";
5
Jason McMullan5d6ccf52005-06-03 11:05:39 -04006struct blob *lookup_blob(const unsigned char *sha1)
Daniel Barkalow175785e2005-04-18 11:39:48 -07007{
8 struct object *obj = lookup_object(sha1);
Linus Torvalds100c5f32007-04-16 22:11:43 -07009 if (!obj)
10 return create_object(sha1, OBJ_BLOB, alloc_blob_node());
Nicolas Pitred1af0022005-05-20 16:59:17 -040011 if (!obj->type)
Linus Torvalds19746322006-07-11 20:45:31 -070012 obj->type = OBJ_BLOB;
13 if (obj->type != OBJ_BLOB) {
Linus Torvalds885a86a2006-06-14 16:45:13 -070014 error("Object %s is a %s, not a blob",
15 sha1_to_hex(sha1), typename(obj->type));
Daniel Barkalow175785e2005-04-18 11:39:48 -070016 return NULL;
17 }
18 return (struct blob *) obj;
19}
Daniel Barkalowa510bfa2005-04-28 07:46:33 -070020
Nicolas Pitrebd2c39f2005-05-06 13:48:34 -040021int parse_blob_buffer(struct blob *item, void *buffer, unsigned long size)
22{
23 item->object.parsed = 1;
24 return 0;
25}