summaryrefslogtreecommitdiff
path: root/src/object.c
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2013-05-01 14:23:01 -0700
committerRussell Belfer <rb@github.com>2013-05-01 14:23:01 -0700
commit8915a140cb996f84eeafadb99b195c33301c7d30 (patch)
treeae3ad5cb84a554ae5040660b571044930b718400 /src/object.c
parent734c6fc13430f770f7e98cf5d23b7f6e470c29ef (diff)
downloadlibgit2-8915a140cb996f84eeafadb99b195c33301c7d30.tar.gz
Report a couple object error conditions
Diffstat (limited to 'src/object.c')
-rw-r--r--src/object.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/object.c b/src/object.c
index b87a07404..43aecf434 100644
--- a/src/object.c
+++ b/src/object.c
@@ -122,8 +122,10 @@ int git_object_lookup_prefix(
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;
+ }
error = git_repository_odb__weakptr(&odb, repo);
if (error < 0)
@@ -311,18 +313,22 @@ int git_object_peel(
git_object *source, *deref = NULL;
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);
if (git_object_type(object) == target_type)
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;
while (!(error = dereference_object(&deref, source))) {