public GitObject Lookup(ObjectId id, GitObjectType type = GitObjectType.Any)
{
Ensure.ArgumentNotNull(id, "id");
GitOid oid = id.Oid;
IntPtr obj;
int res;
if (id is AbbreviatedObjectId)
{
res = NativeMethods.git_object_lookup_prefix(out obj, handle, ref oid, (uint)((AbbreviatedObjectId)id).Length, type);
}
else
{
res = NativeMethods.git_object_lookup(out obj, handle, ref oid, type);
}
if (res == (int)GitErrorCode.GIT_ENOTFOUND || res == (int)GitErrorCode.GIT_EINVALIDTYPE)
{
return null;
}
Ensure.Success(res);
if (id is AbbreviatedObjectId)
{
id = GitObject.ObjectIdOf(obj);
}
return GitObject.CreateFromPtr(obj, id, this);
}