Method: Rugged.raw_to_hex
- Defined in:
- ext/rugged/rugged.c
.raw_to_hex(buffer) ⇒ Object
Turn a buffer of 20 bytes (representing a SHA1 OID) into its readable hexadecimal representation.
Rugged.raw_to_hex("\330xk\374\227H^\215{\031\262\037\270\214\216\361\361\231\374?")
#=> "d8786bfc97485e8d7b19b21fb88c8ef1f199fc3f"
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 |
# File 'ext/rugged/rugged.c', line 173 static VALUE rb_git_raw_to_hex(VALUE self, VALUE raw) { git_oid oid; char out[40]; Check_Type(raw, T_STRING); if (RSTRING_LEN(raw) != GIT_OID_RAWSZ) rb_raise(rb_eTypeError, "Invalid buffer size for an OID"); git_oid_fromraw(&oid, (const unsigned char *)RSTRING_PTR(raw)); git_oid_fmt(out, &oid); return rb_usascii_str_new(out, 40); } |