]> git.ipfire.org Git - thirdparty/git.git/blame - blob.c
[PATCH] Implementations of parsing functions
[thirdparty/git.git] / blob.c
CommitLineData
175785e5
DB
1#include "blob.h"
2#include "cache.h"
3#include <stdlib.h>
4
5const char *blob_type = "blob";
6
7struct blob *lookup_blob(unsigned char *sha1)
8{
9 struct object *obj = lookup_object(sha1);
10 if (!obj) {
11 struct blob *ret = malloc(sizeof(struct blob));
12 memset(ret, 0, sizeof(struct blob));
13 created_object(sha1, &ret->object);
14 ret->object.type = blob_type;
15 ret->object.parsed = 1;
16 return ret;
17 }
18 if (obj->parsed && obj->type != blob_type) {
19 error("Object %s is a %s, not a blob",
20 sha1_to_hex(sha1), obj->type);
21 return NULL;
22 }
23 return (struct blob *) obj;
24}