Skip to content

Commit a510bfa

Browse files
iabervonLinus Torvalds
authored andcommitted
[PATCH] Mark blobs as parsed when they're actually parsed
This eliminates the special case for blobs versus other types of objects. Now the scheme is entirely regular and I won't introduce stupid bugs. (And fsck-cache doesn't have to do the do-nothing parse) Signed-Off-By: Daniel Barkalow <barkalow@iabervon.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
1 parent 3a663fd commit a510bfa

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

blob.c

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,28 @@ struct blob *lookup_blob(unsigned char *sha1)
1414
ret->object.type = blob_type;
1515
return ret;
1616
}
17-
if (obj->parsed && obj->type != blob_type) {
17+
if (obj->type != blob_type) {
1818
error("Object %s is a %s, not a blob",
1919
sha1_to_hex(sha1), obj->type);
2020
return NULL;
2121
}
2222
return (struct blob *) obj;
2323
}
24+
25+
int parse_blob(struct blob *item)
26+
{
27+
char type[20];
28+
void *buffer;
29+
unsigned long size;
30+
if (item->object.parsed)
31+
return 0;
32+
item->object.parsed = 1;
33+
buffer = read_sha1_file(item->object.sha1, type, &size);
34+
if (!buffer)
35+
return error("Could not read %s",
36+
sha1_to_hex(item->object.sha1));
37+
if (strcmp(type, blob_type))
38+
return error("Object %s not a blob",
39+
sha1_to_hex(item->object.sha1));
40+
return 0;
41+
}

blob.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,6 @@ struct blob {
1111

1212
struct blob *lookup_blob(unsigned char *sha1);
1313

14+
int parse_blob(struct blob *item);
15+
1416
#endif /* BLOB_H */

0 commit comments

Comments
 (0)