Method: Rugged::Commit#parents
- Defined in:
- ext/rugged/rugged_commit.c
#parents ⇒ Array
Return the parent(s) of this commit as an array of Rugged::Commit objects. An array is always returned even when the commit has only one or zero parents.
commit.parents #=> => [#<Rugged::Commit:0x108828918>]
root.parents #=> []
259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 |
# File 'ext/rugged/rugged_commit.c', line 259
static VALUE rb_git_commit_parents_GET(VALUE self)
{
git_commit *commit;
git_commit *parent;
unsigned int n, parent_count;
VALUE ret_arr, owner;
int error;
TypedData_Get_Struct(self, git_commit, &rugged_object_type, commit);
owner = rugged_owner(self);
parent_count = git_commit_parentcount(commit);
ret_arr = rb_ary_new2((long)parent_count);
for (n = 0; n < parent_count; n++) {
error = git_commit_parent(&parent, commit, n);
rugged_exception_check(error);
rb_ary_push(ret_arr, rugged_object_new(owner, (git_object *)parent));
}
return ret_arr;
}
|