Re: [PATCH v2 2/8] object.c: add a utility function for "expected type X, got Y"

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> 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.



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux