From: Tian Yuchen Date: Fri, 20 Mar 2026 17:32:25 GMT Subject: Re: [PATCH] path-walk: fix NULL pointer dereference in error message Message-ID: <9d0746d8-2194-4a13-812b-9b46d04c189a@gmail.com> In-Reply-To: Although this isn’t covered in this patch, I’d still like to add a few more comments. Please allow me to elaborate a bit further: This is the implementation of object_as_type() in object.c: > void *object_as_type(struct object *obj, enum object_type type, int quiet) > { > if (obj->type == type) > return obj; > else if (obj->type == OBJ_NONE) { > if (type == OBJ_COMMIT) > init_commit_node((struct commit *) obj); > else > obj->type = type; > return obj; > } > else { > if (!quiet) > error(_("object %s is a %s, not a %s"), > oid_to_hex(&obj->oid), > type_name(obj->type), type_name(type)); > return NULL; > } > } There are at least two possible scenarios: the object doesn't exist, or the type doesn't match, right? Then the message 'failed to find object' is misleading when user encounters the second scenario. Wouldn’t it be confusing if a user saw this message, checked the object using 'git cat-file -t', and discovered that the object actually exists? Regards, Yuchen