Re: [PATCH 2/2] fast-import: allow to tag newly created objects

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

 



Dmitry Ivankov <divanorama@xxxxxxxxx> writes:

>  	} else if (!get_sha1(from, sha1)) {
> -		type = sha1_object_info(sha1, NULL);
> -		if (type < 0)
> -			die("Not a valid object: %s", from);
> +		struct object_entry *oe = find_object(sha1);
> +		if (!oe) {
> +			type = sha1_object_info(sha1, NULL);
> +			if (type < 0)
> +				die("Not a valid object: %s", from);
> +		} else
> +			type = oe->type;

It might be just a "taste" thing, but I would have expected the above to
be written like so:

	struct object_entry *oe = find_object(sha1);
	if (!oe)
		type = sha1_object_info(sha1, NULL);
	else
		type = oe->type;
	if (type < 0)
		die("Not a valid object: %s", from);

The point being that find_object()->type and the return value of
sha1_object_info() are supposed to be compatible and interchangeably used,
which is exactly why the same variable "type" gets assigned and later be
used in the same codeflow, so they should get the same error checking,
even if it happens to be that the current implementation of find_object()
never returns an object with invalid type in it.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[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]