Method: Rugged.hex_to_raw

Defined in:
ext/rugged/rugged.c

.hex_to_raw(oid) ⇒ Object

Turn a string of 40 hexadecimal characters into the buffer of 20 bytes it represents.

Rugged.hex_to_raw('d8786bfc97485e8d7b19b21fb88c8ef1f199fc3f')
#=> "\330xk\374\227H^\215{\031\262\037\270\214\216\361\361\231\374?"

153
154
155
156
157
158
159
160
161
# File 'ext/rugged/rugged.c', line 153

static VALUE rb_git_hex_to_raw(VALUE self, VALUE hex)
{
	git_oid oid;

	Check_Type(hex, T_STRING);
	rugged_exception_check(git_oid_fromstr(&oid, StringValueCStr(hex)));

	return rb_str_new((const char *)oid.id, 20);
}