From 175785e5ff7395be8a458694a7df0511ac14e948 Mon Sep 17 00:00:00 2001 From: Daniel Barkalow Date: Mon, 18 Apr 2005 11:39:48 -0700 Subject: [PATCH] Implementations of parsing functions This implements the parsing functions. Signed-Off-By: Daniel Barkalow Signed-off-by: Linus Torvalds --- blob.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 blob.c (limited to 'blob.c') diff --git a/blob.c b/blob.c new file mode 100644 index 0000000000..35031af62b --- /dev/null +++ b/blob.c @@ -0,0 +1,24 @@ +#include "blob.h" +#include "cache.h" +#include + +const char *blob_type = "blob"; + +struct blob *lookup_blob(unsigned char *sha1) +{ + struct object *obj = lookup_object(sha1); + if (!obj) { + struct blob *ret = malloc(sizeof(struct blob)); + memset(ret, 0, sizeof(struct blob)); + created_object(sha1, &ret->object); + ret->object.type = blob_type; + ret->object.parsed = 1; + return ret; + } + if (obj->parsed && 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; +} -- cgit v1.2.1