git_odb_object * Repository_read_raw(git_repository *repo, const git_oid *oid, size_t len) { git_odb *odb; git_odb_object *obj; int err; err = git_repository_odb(&odb, repo); if (err < 0) { Error_set(err); return NULL; } err = git_odb_read_prefix(&obj, odb, oid, (unsigned int)len); git_odb_free(odb); if (err < 0) { Error_set_oid(err, oid, len); return NULL; } return obj; }
PyObject * lookup_object_prefix(Repository *repo, const git_oid *oid, size_t len, git_otype type) { int err; git_object *obj; Object *py_obj = NULL; err = git_object_lookup_prefix(&obj, repo->repo, oid, (unsigned int)len, type); if (err < 0) return Error_set_oid(err, oid, len); switch (git_object_type(obj)) { case GIT_OBJ_COMMIT: py_obj = PyObject_New(Object, &CommitType); break; case GIT_OBJ_TREE: py_obj = PyObject_New(Object, &TreeType); break; case GIT_OBJ_BLOB: py_obj = PyObject_New(Object, &BlobType); break; case GIT_OBJ_TAG: py_obj = PyObject_New(Object, &TagType); break; default: assert(0); } if (py_obj) { py_obj->obj = obj; py_obj->repo = repo; Py_INCREF(repo); } return (PyObject*)py_obj; }