Method: Rugged::Repository#merge_bases
- Defined in:
- ext/rugged/rugged_repo.c
permalink #merge_bases(oid1, oid2, ...) ⇒ Array #merge_bases(ref1, ref2, ...) ⇒ Array #merge_bases(commit1, commit2, ...) ⇒ Array
Find all merge bases, given two or more commits or oids. Returns an empty array if no merge bases are found.
820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 |
# File 'ext/rugged/rugged_repo.c', line 820
static VALUE rb_git_repo_merge_bases(VALUE self, VALUE rb_args)
{
int error = GIT_OK;
size_t i, len = (size_t)RARRAY_LEN(rb_args);
git_repository *repo;
git_oidarray bases = {NULL, 0};
git_oid *input_array;
VALUE rb_bases;
if (len < 2)
rb_raise(rb_eArgError, "wrong number of arguments (%ld for 2+)", RARRAY_LEN(rb_args));
Data_Get_Struct(self, git_repository, repo);
input_array = xmalloc(sizeof(git_oid) * len);
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_bases_many(&bases, repo, len, input_array);
xfree(input_array);
if (error != GIT_ENOTFOUND)
rugged_exception_check(error);
rb_bases = rb_ary_new2(bases.count);
for (i = 0; i < bases.count; ++i) {
rb_ary_push(rb_bases, rugged_create_oid(&bases.ids[i]));
}
git_oidarray_free(&bases);
return rb_bases;
}
|