MCPcopy Create free account
hub / github.com/libgit2/pygit2 / merge_base_xxx

Function merge_base_xxx

src/repository.c:590–640  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

588typedef int (*git_merge_base_xxx_t)(git_oid *out, git_repository *repo, size_t length, const git_oid input_array[]);
589
590static PyObject *
591merge_base_xxx(Repository *self, PyObject *args, git_merge_base_xxx_t git_merge_base_xxx)
592{
593 PyObject *py_result = NULL;
594 PyObject *py_commit_oid;
595 PyObject *py_commit_oids;
596 git_oid oid;
597 int commit_oid_count;
598 git_oid *commit_oids = NULL;
599 int i = 0;
600 int err;
601
602 if (!PyArg_ParseTuple(args, "O!", &PyList_Type, &py_commit_oids))
603 return NULL;
604
605 commit_oid_count = (int)PyList_Size(py_commit_oids);
606 commit_oids = malloc(commit_oid_count * sizeof(git_oid));
607 if (commit_oids == NULL) {
608 PyErr_SetNone(PyExc_MemoryError);
609 goto out;
610 }
611
612 for (; i < commit_oid_count; i++) {
613 py_commit_oid = PyList_GetItemRef(py_commit_oids, i);
614 if (py_commit_oid == NULL)
615 goto out;
616 err = py_oid_to_git_oid_expand(self->repo, py_commit_oid, &commit_oids[i]);
617 Py_DECREF(py_commit_oid);
618 if (err < 0)
619 goto out;
620 }
621
622 err = (*git_merge_base_xxx)(&oid, self->repo, commit_oid_count, (const git_oid*)commit_oids);
623
624 if (err == GIT_ENOTFOUND) {
625 Py_INCREF(Py_None);
626 py_result = Py_None;
627 goto out;
628 }
629
630 if (err < 0) {
631 py_result = Error_set(err);
632 goto out;
633 }
634
635 py_result = git_oid_to_python(&oid);
636
637out:
638 free(commit_oids);
639 return py_result;
640}
641
642
643PyDoc_STRVAR(Repository_merge_base_many__doc__,

Callers 2

Calls 4

PyList_GetItemRefFunction · 0.85
py_oid_to_git_oid_expandFunction · 0.85
Error_setFunction · 0.85
git_oid_to_pythonFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…