summaryrefslogtreecommitdiff
path: root/blob.c
diff options
context:
space:
mode:
authorDaniel Barkalow <barkalow@iabervon.org>2005-04-18 18:39:48 (GMT)
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-18 18:39:48 (GMT)
commit175785e5ff7395be8a458694a7df0511ac14e948 (patch)
tree3e65cde9bb577457d62c11fc6075f3a04a8d4bc9 /blob.c
parent6eb8ae00d4bceaf660a07d8bc5ab8d6ddccbe1af (diff)
downloadgit-175785e5ff7395be8a458694a7df0511ac14e948.zip
git-175785e5ff7395be8a458694a7df0511ac14e948.tar.gz
git-175785e5ff7395be8a458694a7df0511ac14e948.tar.bz2
[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.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/blob.c b/blob.c
new file mode 100644
index 0000000..35031af
--- /dev/null
+++ b/blob.c
@@ -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;
+}