Skip to content

Commit 4728b86

Browse files
author
Linus Torvalds
committed
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.
1 parent da6abf5 commit 4728b86

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

blob.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ struct blob *lookup_blob(unsigned char *sha1)
1212
memset(ret, 0, sizeof(struct blob));
1313
created_object(sha1, &ret->object);
1414
ret->object.type = blob_type;
15-
ret->object.parsed = 1;
1615
return ret;
1716
}
1817
if (obj->parsed && obj->type != blob_type) {

fsck-cache.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,19 @@ static int fsck_commit(unsigned char *sha1, void *data, unsigned long size)
6060
return 0;
6161
}
6262

63+
static int fsck_blob(unsigned char *sha1, void *data, unsigned long size)
64+
{
65+
struct blob *blob = lookup_blob(sha1);
66+
blob->object.parsed = 1;
67+
return 0;
68+
}
69+
6370
static int fsck_entry(unsigned char *sha1, char *tag, void *data,
6471
unsigned long size)
6572
{
6673
if (!strcmp(tag, "blob")) {
67-
lookup_blob(sha1); /* Nothing to check; but notice it. */
74+
if (fsck_blob(sha1, data, size) < 0)
75+
return -1;
6876
} else if (!strcmp(tag, "tree")) {
6977
if (fsck_tree(sha1, data, size) < 0)
7078
return -1;

0 commit comments

Comments
 (0)