> diff --git a/object-file.c b/object-file.c > index 0de699de98..0e8a024eb3 100644 > --- a/object-file.c > +++ b/object-file.c > @@ -2522,7 +2522,8 @@ int read_loose_object(const char *path, > const struct object_id *expected_oid, > enum object_type *type, > unsigned long *size, > - void **contents) > + void **contents, > + unsigned int oi_flags) > { > int ret = -1; > void *map = NULL; > @@ -2530,6 +2531,7 @@ int read_loose_object(const char *path, > git_zstream stream; > char hdr[MAX_HEADER_LEN]; > struct object_info oi = OBJECT_INFO_INIT; > + int allow_unknown = oi_flags & OBJECT_INFO_ALLOW_UNKNOWN_TYPE; > oi.typep = type; > oi.sizep = size; > > @@ -2552,8 +2554,11 @@ int read_loose_object(const char *path, > git_inflate_end(&stream); > goto out; > } > - if (*type < 0) > - die(_("invalid object type")); > + if (!allow_unknown && *type < 0) { > + error(_("header for %s declares an unknown type"), path); > + git_inflate_end(&stream); > + goto out; > + } > > if (*type == OBJ_BLOB && *size > big_file_threshold) { > if (check_stream_oid(&stream, hdr, *size, path, expected_oid) < 0) So instead of dying, we print an error and behave as if the object was invalid for some other reason. Makes sense.