class Rugged::Blob::HashSignature

Constants

WHITESPACE_DEFAULT
WHITESPACE_IGNORE
WHITESPACE_SMART

Public Class Methods

compare(p1, p2) click to toggle source
static VALUE rb_git_blob_sig_compare(VALUE self, VALUE rb_sig_a, VALUE rb_sig_b)
{
        git_hashsig *sig_a;
        git_hashsig *sig_b;
        int result;

        if (!rb_obj_is_kind_of(rb_sig_a, rb_cRuggedBlobSig) ||
                !rb_obj_is_kind_of(rb_sig_b, rb_cRuggedBlobSig)) {
                rb_raise(rb_eTypeError, "Expected Rugged::Blob::HashSignature");
        }

        Data_Get_Struct(rb_sig_a, git_hashsig, sig_a);
        Data_Get_Struct(rb_sig_b, git_hashsig, sig_b);

        result = git_hashsig_compare(sig_a, sig_b);

        if (result < 0)
                rugged_exception_check(result);

        return INT2FIX(result);
}
new(p1, p2 = v2) click to toggle source
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);
}