From: Jonathan Tan Date: Wed, 21 Apr 2021 22:02:59 GMT Subject: Re: [PATCH v2 2/8] object.c: add a utility function for "expected type X, got Y" Message-ID: <20210421220300.1022458-1-jonathantanmy@google.com> In-Reply-To: > diff --git a/merge-recursive.c b/merge-recursive.c > index 7618303f7b..b952106203 100644 > --- a/merge-recursive.c > +++ b/merge-recursive.c > @@ -2999,6 +2999,7 @@ static int read_oid_strbuf(struct merge_options *opt, > if (!buf) > return err(opt, _("cannot read object %s"), oid_to_hex(oid)); > if (type != OBJ_BLOB) { > + const char* msg = oid_is_type_or_die_msg(oid, OBJ_BLOB, &type); > free(buf); > return err(opt, _("object %s is not a blob"), oid_to_hex(oid)); > } Stray extra line. > +void oid_is_type_or_die(const struct object_id *oid, > + enum object_type want, > + enum object_type *type) > +{ Thanks - this looks like a good simplification. Why is type a pointer? Maybe it's to better distinguish the values at the call site (one pointer, one not), but this solution is confusing too. > +int oid_is_type_or_error(const struct object_id *oid, > + enum object_type want, > + enum object_type *type) > +{ Same comment.