Skip to content

Commit c1166ca

Browse files
peffgitster
authored andcommitted
blob: drop unused parts of parse_blob_buffer()
Our parse_blob_buffer() takes a ptr/len combo, just like parse_tree_buffer(), etc, and returns success or failure. But it doesn't actually do anything with them; we just set the "parsed" flag in the object and return success, without even looking at the contents. There could be some value to keeping these unused parameters: - it's consistent with the parse functions for other object types. But we already lost that consistency in 837d395 (Replace parse_blob() with an explanatory comment, 2010-01-18). - As the comment from 837d395 explains, callers are supposed to make sure they have the object content available. So in theory asking for these parameters could serve as a signal. But there are only two callers, and one of them always passes NULL (after doing a streaming check of the object hash). This shows that there aren't likely to be a lot of callers (since everyone either uses the type-generic parse functions, or handles blobs individually), and that they need to take special care anyway (because we usually want to avoid loading whole blobs in memory if we can avoid it). So let's just drop these unused parameters, and likewise the useless return value. While we're touching the header file, let's move the declaration of parse_blob_buffer() right below that explanatory comment, where it's more likely to be seen by people looking for the function. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 91e2ab1 commit c1166ca

File tree

3 files changed

+4
-7
lines changed

3 files changed

+4
-7
lines changed

blob.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ struct blob *lookup_blob(struct repository *r, const struct object_id *oid)
1313
return object_as_type(obj, OBJ_BLOB, 0);
1414
}
1515

16-
int parse_blob_buffer(struct blob *item, void *buffer, unsigned long size)
16+
void parse_blob_buffer(struct blob *item)
1717
{
1818
item->object.parsed = 1;
19-
return 0;
2019
}

blob.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ struct blob {
1111

1212
struct blob *lookup_blob(struct repository *r, const struct object_id *oid);
1313

14-
int parse_blob_buffer(struct blob *item, void *buffer, unsigned long size);
15-
1614
/**
1715
* Blobs do not contain references to other objects and do not have
1816
* structured data that needs parsing. However, code may use the
@@ -21,5 +19,6 @@ int parse_blob_buffer(struct blob *item, void *buffer, unsigned long size);
2119
* parse_blob_buffer() is used (by object.c) to flag that the object
2220
* has been read successfully from the database.
2321
**/
22+
void parse_blob_buffer(struct blob *item);
2423

2524
#endif /* BLOB_H */

object.c

+2-3
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,7 @@ struct object *parse_object_buffer(struct repository *r, const struct object_id
212212
if (type == OBJ_BLOB) {
213213
struct blob *blob = lookup_blob(r, oid);
214214
if (blob) {
215-
if (parse_blob_buffer(blob, buffer, size))
216-
return NULL;
215+
parse_blob_buffer(blob);
217216
obj = &blob->object;
218217
}
219218
} else if (type == OBJ_TREE) {
@@ -292,7 +291,7 @@ struct object *parse_object_with_flags(struct repository *r,
292291
error(_("hash mismatch %s"), oid_to_hex(oid));
293292
return NULL;
294293
}
295-
parse_blob_buffer(lookup_blob(r, oid), NULL, 0);
294+
parse_blob_buffer(lookup_blob(r, oid));
296295
return lookup_object(r, oid);
297296
}
298297

0 commit comments

Comments
 (0)