static VALUE rb_git_blob_rawsize(VALUE self) { git_blob *blob; RUGGED_OBJ_UNWRAP(self, git_blob, blob); return INT2FIX(git_blob_rawsize(blob)); }
/* * Rugged Tree */ static VALUE rb_git_tree_entrycount(VALUE self) { git_tree *tree; RUGGED_OBJ_UNWRAP(self, git_tree, tree); return INT2FIX(git_tree_entrycount(tree)); }
static VALUE rb_git_commit_author_GET(VALUE self) { git_commit *commit; RUGGED_OBJ_UNWRAP(self, git_commit, commit); return rugged_signature_new(git_commit_author(commit)); }
static VALUE rb_git_commit_time_GET(VALUE self) { git_commit *commit; RUGGED_OBJ_UNWRAP(self, git_commit, commit); return ULONG2NUM(git_commit_time(commit)); }
static VALUE rb_git_commit_message_short_GET(VALUE self) { git_commit *commit; RUGGED_OBJ_UNWRAP(self, git_commit, commit); return rugged_str_new2(git_commit_message_short(commit), NULL); }
static VALUE rb_git_tag_tagger_GET(VALUE self) { git_tag *tag; RUGGED_OBJ_UNWRAP(self, git_tag, tag); return rugged_signature_new(git_tag_tagger(tag)); }
static VALUE rb_git_tag_name_GET(VALUE self) { git_tag *tag; RUGGED_OBJ_UNWRAP(self, git_tag, tag); return rugged_str_new2(git_tag_name(tag), NULL); }
static VALUE rb_git_tag_target_type_GET(VALUE self) { git_tag *tag; RUGGED_OBJ_UNWRAP(self, git_tag, tag); return rugged_str_new2(git_object_type2string(git_tag_type(tag)), NULL); }
static VALUE rb_git_commit_author_SET(VALUE self, VALUE rb_sig) { git_commit *commit; RUGGED_OBJ_UNWRAP(self, git_commit, commit); git_commit_set_author(commit, rugged_signature_get(rb_sig)); return Qnil; }
static VALUE rb_git_tree_clear(VALUE self) { git_tree *tree; RUGGED_OBJ_UNWRAP(self, git_tree, tree); git_tree_clear_entries(tree); return Qnil; }
static VALUE rb_git_tag_tagger_SET(VALUE self, VALUE rb_sig) { git_tag *tag; RUGGED_OBJ_UNWRAP(self, git_tag, tag); git_tag_set_tagger(tag, rugged_signature_get(rb_sig)); return Qnil; }
static VALUE rb_git_commit_message_SET(VALUE self, VALUE val) { git_commit *commit; RUGGED_OBJ_UNWRAP(self, git_commit, commit); Check_Type(val, T_STRING); git_commit_set_message(commit, RSTRING_PTR(val)); return Qnil; }
static VALUE rb_git_tag_name_SET(VALUE self, VALUE val) { git_tag *tag; RUGGED_OBJ_UNWRAP(self, git_tag, tag); Check_Type(val, T_STRING); git_tag_set_name(tag, RSTRING_PTR(val)); return Qnil; }
static VALUE rb_git_tag_target_GET(VALUE self) { git_tag *tag; VALUE owner; RUGGED_OBJ_UNWRAP(self, git_tag, tag); RUGGED_OBJ_OWNER(self, owner); return rugged_object_new(owner, (git_object*)git_tag_target(tag)); }
static VALUE rb_git_commit_tree_SET(VALUE self, VALUE val) { git_commit *commit; git_tree *tree; RUGGED_OBJ_UNWRAP(self, git_commit, commit); tree = (git_tree *)rugged_object_get(git_object_owner((git_object *)commit), val, GIT_OBJ_TREE); git_commit_set_tree(commit, tree); return Qnil; }
static VALUE rb_git_blob_content_SET(VALUE self, VALUE rb_contents) { git_blob *blob; RUGGED_OBJ_UNWRAP(self, git_blob, blob); Check_Type(rb_contents, T_STRING); git_blob_set_rawcontent(blob, RSTRING_PTR(rb_contents), RSTRING_LEN(rb_contents)); return Qnil; }
static VALUE rb_git_tag_target_SET(VALUE self, VALUE val) { git_tag *tag; git_object *target; RUGGED_OBJ_UNWRAP(self, git_tag, tag); target = rugged_object_get(git_object_owner((git_object *)tag), val, GIT_OBJ_ANY); git_tag_set_target(tag, target); return Qnil; }
static VALUE rb_git_commit_tree_GET(VALUE self) { git_commit *commit; const git_tree *tree; VALUE owner; RUGGED_OBJ_UNWRAP(self, git_commit, commit); RUGGED_OBJ_OWNER(self, owner); tree = git_commit_tree(commit); return tree ? rugged_object_new(owner, (git_object *)tree) : Qnil; }
static VALUE rb_git_blob_content_GET(VALUE self) { git_blob *blob; int size; RUGGED_OBJ_UNWRAP(self, git_blob, blob); size = git_blob_rawsize(blob); if (size == 0) return rb_str_new2(""); return rb_str_new(git_blob_rawcontent(blob), size); }
static VALUE rb_git_tree_get_entry(VALUE self, VALUE entry_id) { git_tree *tree; RUGGED_OBJ_UNWRAP(self, git_tree, tree); if (TYPE(entry_id) == T_FIXNUM) return rb_git_createentry(self, git_tree_entry_byindex(tree, FIX2INT(entry_id))); else if (TYPE(entry_id) == T_STRING) return rb_git_createentry(self, git_tree_entry_byname(tree, RSTRING_PTR(entry_id))); else rb_raise(rb_eTypeError, "entry_id must be either an index or a filename"); }
static VALUE rb_git_tag_target_GET(VALUE self) { git_tag *tag; git_object *target; int error; VALUE owner; RUGGED_OBJ_UNWRAP(self, git_tag, tag); RUGGED_OBJ_OWNER(self, owner); error = git_tag_target(&target, tag); rugged_exception_check(error); return rugged_object_new(owner, target); }
static VALUE rb_git_commit_parents_GET(VALUE self) { git_commit *commit; git_commit *parent; unsigned int n; VALUE ret_arr, owner; RUGGED_OBJ_UNWRAP(self, git_commit, commit); RUGGED_OBJ_OWNER(self, owner); ret_arr = rb_ary_new(); for (n = 0; (parent = git_commit_parent(commit, n)) != NULL; n++) { rb_ary_store(ret_arr, n, rugged_object_new(owner, (git_object *)parent)); } return ret_arr; }
static VALUE rb_git_tree_add_entry(VALUE self, VALUE rb_oid, VALUE rb_filename, VALUE rb_mode) { git_tree_entry *new_entry; git_oid oid; git_tree *tree; int error; RUGGED_OBJ_UNWRAP(self, git_tree, tree); Check_Type(rb_oid, T_STRING); Check_Type(rb_filename, T_STRING); Check_Type(rb_mode, T_FIXNUM); error = git_oid_mkstr(&oid, RSTRING_PTR(rb_oid)); rugged_exception_check(error); error = git_tree_add_entry(&new_entry, tree, &oid, RSTRING_PTR(rb_filename), FIX2INT(rb_mode)); rugged_exception_check(error); return rb_git_createentry(self, new_entry); }
static VALUE rb_git_blob_content_GET(VALUE self) { git_blob *blob; int size; RUGGED_OBJ_UNWRAP(self, git_blob, blob); size = git_blob_rawsize(blob); if (size == 0) return rugged_str_ascii("", 0); /* * since we don't really ever know the encoding of a blob * lets default to the binary encoding (ascii-8bit) * If there is a way to tell, we should just pass 0/null here instead * * we're skipping the use of STR_NEW because we don't want our string to * eventually end up converted to Encoding.default_internal because this * string could very well be binary data */ return rugged_str_ascii(git_blob_rawcontent(blob), size); }