]> git.ipfire.org Git - thirdparty/git.git/commitdiff
parse_object(): drop extra "has" check before checking object type
authorJeff King <peff@peff.net>
Thu, 17 Nov 2022 22:37:58 +0000 (17:37 -0500)
committerTaylor Blau <me@ttaylorr.com>
Fri, 18 Nov 2022 18:59:31 +0000 (13:59 -0500)
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 <peff@peff.net>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
object.c

index 8a74eb85e94603458e0fe7eafbc58a40a3380b10..16eb944e98c7b7d13b41d4748f132070a4e684ef 100644 (file)
--- a/object.c
+++ b/object.c
@@ -287,8 +287,7 @@ struct object *parse_object_with_flags(struct repository *r,
        }
 
        if ((obj && obj->type == OBJ_BLOB && repo_has_object_file(r, oid)) ||
-           (!obj && repo_has_object_file(r, oid) &&
-            oid_object_info(r, oid, NULL) == OBJ_BLOB)) {
+           (!obj && oid_object_info(r, oid, NULL) == OBJ_BLOB)) {
                if (!skip_hash && stream_object_signature(r, repl) < 0) {
                        error(_("hash mismatch %s"), oid_to_hex(oid));
                        return NULL;