From: Linus Torvalds Date: Sun, 24 Apr 2005 21:22:09 +0000 (-0700) Subject: Verify that the object type matches for tree/commit objects even before parsing. X-Git-Tag: v0.99~756 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=c35dfe858991ee1969870d2da9337a1da567157e;p=git.git Verify that the object type matches for tree/commit objects even before parsing. The type doesn't come from the parsing, the type also has to match the usage. --- diff --git a/commit.c b/commit.c index c0dd689e..c6fdfd49 100644 --- a/commit.c +++ b/commit.c @@ -15,7 +15,7 @@ struct commit *lookup_commit(unsigned char *sha1) ret->object.type = commit_type; return ret; } - if (obj->parsed && obj->type != commit_type) { + if (obj->type != commit_type) { error("Object %s is a %s, not a commit", sha1_to_hex(sha1), obj->type); return NULL; diff --git a/tree.c b/tree.c index 23476da7..3537c115 100644 --- a/tree.c +++ b/tree.c @@ -80,7 +80,7 @@ struct tree *lookup_tree(unsigned char *sha1) ret->object.type = tree_type; return ret; } - if (obj->parsed && obj->type != tree_type) { + if (obj->type != tree_type) { error("Object %s is a %s, not a tree", sha1_to_hex(sha1), obj->type); return NULL;