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.
This commit is contained in:
parent
d32987be61
commit
c35dfe8589
2
commit.c
2
commit.c
@ -15,7 +15,7 @@ struct commit *lookup_commit(unsigned char *sha1)
|
|||||||
ret->object.type = commit_type;
|
ret->object.type = commit_type;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
if (obj->parsed && obj->type != commit_type) {
|
if (obj->type != commit_type) {
|
||||||
error("Object %s is a %s, not a commit",
|
error("Object %s is a %s, not a commit",
|
||||||
sha1_to_hex(sha1), obj->type);
|
sha1_to_hex(sha1), obj->type);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
2
tree.c
2
tree.c
@ -80,7 +80,7 @@ struct tree *lookup_tree(unsigned char *sha1)
|
|||||||
ret->object.type = tree_type;
|
ret->object.type = tree_type;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
if (obj->parsed && obj->type != tree_type) {
|
if (obj->type != tree_type) {
|
||||||
error("Object %s is a %s, not a tree",
|
error("Object %s is a %s, not a tree",
|
||||||
sha1_to_hex(sha1), obj->type);
|
sha1_to_hex(sha1), obj->type);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
Loading…
Reference in New Issue
Block a user