Skip to content

Commit 04fb962

Browse files
peffttaylorr
authored andcommitted
parse_object(): drop extra "has" check before checking object type
When parsing an object of unknown type, we check to see if it's a blob, so we can use our streaming code path. This uses oid_object_info() to check the type, but before doing so we call repo_has_object_file(). This latter is pointless, as oid_object_info() will already fail if the object is missing. Checking it ahead of time just complicates the code and is a waste of resources (albeit small). Let's drop the redundant check. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Taylor Blau <[email protected]>
1 parent eea7033 commit 04fb962

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

object.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,7 @@ struct object *parse_object_with_flags(struct repository *r,
287287
}
288288

289289
if ((obj && obj->type == OBJ_BLOB && repo_has_object_file(r, oid)) ||
290-
(!obj && repo_has_object_file(r, oid) &&
291-
oid_object_info(r, oid, NULL) == OBJ_BLOB)) {
290+
(!obj && oid_object_info(r, oid, NULL) == OBJ_BLOB)) {
292291
if (!skip_hash && stream_object_signature(r, repl) < 0) {
293292
error(_("hash mismatch %s"), oid_to_hex(oid));
294293
return NULL;

0 commit comments

Comments
 (0)