Method: Rugged::Blob::HashSignature.new

Defined in:
ext/rugged/rugged_blob.c

.new(*args) ⇒ Object


641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
# File 'ext/rugged/rugged_blob.c', line 641

static VALUE rb_git_blob_sig_new(int argc, VALUE *argv, VALUE klass)
{
	int error, opts = 0;
	git_hashsig *sig;
	VALUE rb_blob, rb_options;

	if (rb_scan_args(argc, argv, "11", &rb_blob, &rb_options) == 2) {
		Check_Type(rb_options, T_FIXNUM);
		opts = FIX2INT(rb_options);
	}

	if (rb_obj_is_kind_of(rb_blob, rb_cRuggedBlob)) {
		git_blob *blob;
		TypedData_Get_Struct(rb_blob, git_blob, &rugged_object_type, blob);

		error = git_hashsig_create(&sig,
				git_blob_rawcontent(blob),
				git_blob_rawsize(blob),
				opts);
	} else {
		Check_Type(rb_blob, T_STRING);
		error = git_hashsig_create(&sig, RSTRING_PTR(rb_blob), RSTRING_LEN(rb_blob), opts);
	}

	rugged_exception_check(error);

	return Data_Wrap_Struct(klass, NULL, &git_hashsig_free, sig);
}