From: Linus Torvalds Date: Sun, 24 Apr 2005 21:10:55 +0000 (-0700) Subject: fsck-cache: notice missing "blob" objects. X-Git-Tag: v0.99~758 X-Git-Url: https://git.octo.it/?a=commitdiff_plain;h=4728b861ace127dc39c648f3bea64c3b86bbabc5;p=git.git 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. --- diff --git a/blob.c b/blob.c index 35031af6..f79f5abd 100644 --- a/blob.c +++ b/blob.c @@ -12,7 +12,6 @@ struct blob *lookup_blob(unsigned char *sha1) 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) { diff --git a/fsck-cache.c b/fsck-cache.c index 96b8eb16..985adb68 100644 --- a/fsck-cache.c +++ b/fsck-cache.c @@ -60,11 +60,19 @@ static int fsck_commit(unsigned char *sha1, void *data, unsigned long size) return 0; } +static int fsck_blob(unsigned char *sha1, void *data, unsigned long size) +{ + struct blob *blob = lookup_blob(sha1); + blob->object.parsed = 1; + return 0; +} + static int fsck_entry(unsigned char *sha1, char *tag, void *data, unsigned long size) { if (!strcmp(tag, "blob")) { - lookup_blob(sha1); /* Nothing to check; but notice it. */ + if (fsck_blob(sha1, data, size) < 0) + return -1; } else if (!strcmp(tag, "tree")) { if (fsck_tree(sha1, data, size) < 0) return -1;