diff options
author | Daniel Barkalow <barkalow@iabervon.org> | 2005-04-18 11:39:48 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-18 11:39:48 -0700 |
commit | 175785e5ff7395be8a458694a7df0511ac14e948 (patch) | |
tree | 3e65cde9bb577457d62c11fc6075f3a04a8d4bc9 /blob.c | |
parent | 6eb8ae00d4bceaf660a07d8bc5ab8d6ddccbe1af (diff) | |
download | git-175785e5ff7395be8a458694a7df0511ac14e948.tar.gz git-175785e5ff7395be8a458694a7df0511ac14e948.tar.xz |
[PATCH] Implementations of parsing functions
This implements the parsing functions.
Signed-Off-By: Daniel Barkalow <barkalow@iabervon.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'blob.c')
-rw-r--r-- | blob.c | 24 |
1 files changed, 24 insertions, 0 deletions
@@ -0,0 +1,24 @@ +#include "blob.h" +#include "cache.h" +#include <stdlib.h> + +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; +} |