Method: Rugged::Repository#merge_base
- Defined in:
- ext/rugged/rugged_repo.c
#merge_base(oid1, oid2, ...) ⇒ Object #merge_base(ref1, ref2, ...) ⇒ Object #merge_base(commit1, commit2, ...) ⇒ Object
Find a merge base, given two or more commits or oids. Returns nil if a merge base is not found.
779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 |
# File 'ext/rugged/rugged_repo.c', line 779
static VALUE rb_git_repo_merge_base(VALUE self, VALUE rb_args)
{
int error = GIT_OK, i;
git_repository *repo;
git_oid base, *input_array = xmalloc(sizeof(git_oid) * RARRAY_LEN(rb_args));
int len = (int)RARRAY_LEN(rb_args);
if (len < 2)
rb_raise(rb_eArgError, "wrong number of arguments (%d for 2+)", len);
Data_Get_Struct(self, git_repository, repo);
for (i = 0; !error && i < len; ++i) {
error = rugged_oid_get(&input_array[i], repo, rb_ary_entry(rb_args, i));
}
if (error) {
xfree(input_array);
rugged_exception_check(error);
}
error = git_merge_base_many(&base, repo, len, input_array);
xfree(input_array);
if (error == GIT_ENOTFOUND)
return Qnil;
rugged_exception_check(error);
return rugged_create_oid(&base);
}
|