Re: [PATCH 2/2] fast-import: allow to tag newly created objects
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Aug 23, 2011, 18:32 UTC
- Message-ID
- <7vy5ykq8rb.fsf@alter.siamese.dyndns.org>
- In-Reply-To
- <1314015019-6636-3-git-send-email-divanorama@gmail.com>
Dmitry Ivankov <divanorama@gmail.com> writes:
Show 11 quoted lines
> } 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.