class Rugged::Object
Public Class Methods
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.
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); }
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.
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); }
Find and return a single object inside repo
as specified by the git revision string str
.
See git-scm.com/docs/git-rev-parse.html#_specifying_revisions or man gitrevisions
for information on the accepted syntax.
Raises a Rugged::InvalidError if str
does not contain a valid revision string.
VALUE rb_git_object_rev_parse(VALUE klass, VALUE rb_repo, VALUE rb_spec) { return rugged_object_rev_parse(rb_repo, rb_spec, 1); }
Find and return the id of the object inside repo
as specified by the git revision string str
.
See git-scm.com/docs/git-rev-parse.html#_specifying_revisions or man gitrevisions
for information on the accepted syntax.
Raises a Rugged::InvalidError if str
does not contain a valid revision string.
VALUE rb_git_object_rev_parse_oid(VALUE klass, VALUE rb_repo, VALUE rb_spec) { return rugged_object_rev_parse(rb_repo, rb_spec, 0); }
Public Instance Methods
# File lib/rugged/object.rb, line 8 def <=>(other) self.oid <=> other.oid end
Returns true only if object
and other are both instances or subclasses of Rugged::Object
and have the same object id, false otherwise.
static VALUE rb_git_object_equal(VALUE self, VALUE other) { git_object *a, *b; if (!rb_obj_is_kind_of(other, rb_cRuggedObject)) return Qfalse; TypedData_Get_Struct(self, git_object, &rugged_object_type, a); TypedData_Get_Struct(other, git_object, &rugged_object_type, b); return git_oid_cmp(git_object_id(a), git_object_id(b)) == 0 ? Qtrue : Qfalse; }
Return the Object
ID (a 40 character SHA1 hash) for object
.
static VALUE rb_git_object_oid_GET(VALUE self) { git_object *object; TypedData_Get_Struct(self, git_object, &rugged_object_type, object); return rugged_create_oid(git_object_id(object)); }
Returns the git object as a Rugged::OdbObject
instance.
static VALUE rb_git_object_read_raw(VALUE self) { git_object *object; TypedData_Get_Struct(self, git_object, &rugged_object_type, object); return rugged_raw_read(git_object_owner(object), git_object_id(object)); }
Returns the object’s type. Can be one of :commit
, :tag
, :tree
or :blob
.
static VALUE rb_git_object_type_GET(VALUE self) { git_object *object; TypedData_Get_Struct(self, git_object, &rugged_object_type, object); return rugged_otype_new(git_object_type(object)); }