Method: Rugged::Object.lookup
- Defined in:
- ext/rugged/rugged_object.c
permalink .new(repo, oid) ⇒ Object .lookup(repo, oid) ⇒ Object
Find and return the git object inside repo
with the given oid
.
oid
can either have be the complete, 40 character string or any unique prefix.
247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 |
# File 'ext/rugged/rugged_object.c', line 247
VALUE rb_git_object_lookup(VALUE klass, VALUE rb_repo, VALUE rb_hex)
{
git_object *object;
git_otype type;
git_oid oid;
int error;
int oid_length;
git_repository *repo;
type = class2otype(klass);
if (type == GIT_OBJ_BAD)
type = GIT_OBJ_ANY;
Check_Type(rb_hex, T_STRING);
oid_length = (int)RSTRING_LEN(rb_hex);
rugged_check_repo(rb_repo);
if (oid_length > GIT_OID_HEXSZ)
rb_raise(rb_eTypeError, "The given OID is too long");
Data_Get_Struct(rb_repo, git_repository, repo);
error = git_oid_fromstrn(&oid, RSTRING_PTR(rb_hex), oid_length);
rugged_exception_check(error);
if (oid_length < GIT_OID_HEXSZ)
error = git_object_lookup_prefix(&object, repo, &oid, oid_length, type);
else
error = git_object_lookup(&object, repo, &oid, type);
rugged_exception_check(error);
return rugged_object_new(rb_repo, object);
}
|