Commit 8915a140 by Russell Belfer

Report a couple object error conditions

parent 734c6fc1
...@@ -122,8 +122,10 @@ int git_object_lookup_prefix( ...@@ -122,8 +122,10 @@ int git_object_lookup_prefix(
assert(repo && object_out && id); assert(repo && object_out && id);
if (len < GIT_OID_MINPREFIXLEN) if (len < GIT_OID_MINPREFIXLEN) {
giterr_set(GITERR_OBJECT, "Ambiguous lookup - OID prefix is too short");
return GIT_EAMBIGUOUS; return GIT_EAMBIGUOUS;
}
error = git_repository_odb__weakptr(&odb, repo); error = git_repository_odb__weakptr(&odb, repo);
if (error < 0) if (error < 0)
...@@ -311,18 +313,22 @@ int git_object_peel( ...@@ -311,18 +313,22 @@ int git_object_peel(
git_object *source, *deref = NULL; git_object *source, *deref = NULL;
int error; int error;
if (target_type != GIT_OBJ_TAG &&
target_type != GIT_OBJ_COMMIT &&
target_type != GIT_OBJ_TREE &&
target_type != GIT_OBJ_BLOB &&
target_type != GIT_OBJ_ANY)
return GIT_EINVALIDSPEC;
assert(object && peeled); assert(object && peeled);
if (git_object_type(object) == target_type) if (git_object_type(object) == target_type)
return git_object_dup(peeled, (git_object *)object); return git_object_dup(peeled, (git_object *)object);
if (target_type != GIT_OBJ_TAG &&
target_type != GIT_OBJ_COMMIT &&
target_type != GIT_OBJ_TREE &&
target_type != GIT_OBJ_BLOB &&
target_type != GIT_OBJ_ANY) {
giterr_set(GITERR_OBJECT, "Cannot peel to object type %d",
(int)target_type);
return GIT_EINVALIDSPEC;
}
source = (git_object *)object; source = (git_object *)object;
while (!(error = dereference_object(&deref, source))) { while (!(error = dereference_object(&deref, source))) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment