Method: Rugged::Repository#read_header
- Defined in:
- ext/rugged/rugged_repo.c
#read_header(oid) ⇒ Hash
Read and return the header information in repo
‘s ODB for the object identified by the given oid
.
Returns a Hash object with the following key/value pairs:
- :type
-
A Symbol denoting the object’s type. Possible values are:
:tree
,:blob
,:commit
or:tag
. - :len
-
A Number representing the object’s length, in bytes.
1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 |
# File 'ext/rugged/rugged_repo.c', line 1181
static VALUE rb_git_repo_read_header(VALUE self, VALUE hex)
{
git_repository *repo;
git_oid oid;
git_odb *odb;
git_otype type;
size_t len;
VALUE rb_hash;
int error;
Data_Get_Struct(self, git_repository, repo);
Check_Type(hex, T_STRING);
error = git_oid_fromstr(&oid, StringValueCStr(hex));
rugged_exception_check(error);
error = git_repository_odb(&odb, repo);
rugged_exception_check(error);
error = git_odb_read_header(&len, &type, odb, &oid);
git_odb_free(odb);
rugged_exception_check(error);
rb_hash = rb_hash_new();
rb_hash_aset(rb_hash, CSTR2SYM("type"), CSTR2SYM(git_object_type2string(type)));
rb_hash_aset(rb_hash, CSTR2SYM("len"), INT2FIX(len));
return rb_hash;
}
|