1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-23 09:06:35 +02:00
git/blob.c
Linus Torvalds 4728b861ac fsck-cache: notice missing "blob" objects.
We should _not_ mark a blob object "parsed" just because we
looked it up: it gets marked that way only once we've actually
seen it. Otherwise we can never notice a missing blob.
2005-04-24 14:10:55 -07:00

24 lines
547 B
C

#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;
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;
}