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

Function Repository_merge_analysis

src/repository.c:685–746  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

683 "The second value is the user's preference from 'merge.ff'");
684
685PyObject *
686Repository_merge_analysis(Repository *self, PyObject *args)
687{
688 char *our_ref_name = "HEAD";
689 PyObject *py_their_head;
690 PyObject *py_result = NULL;
691 git_oid head_id;
692 git_reference *our_ref;
693 git_annotated_commit *commit;
694 git_merge_analysis_t analysis;
695 git_merge_preference_t preference;
696 int err = 0;
697
698 if (!PyArg_ParseTuple(args, "O|z",
699 &py_their_head,
700 &our_ref_name))
701 return NULL;
702
703 err = git_reference_lookup(&our_ref, self->repo, our_ref_name);
704 if (err < 0) {
705 PyObject *py_err = Error_set_str(err, our_ref_name);
706 return py_err;
707 }
708
709 err = py_oid_to_git_oid_expand(self->repo, py_their_head, &head_id);
710 if (err < 0)
711 goto out;
712
713 err = git_annotated_commit_lookup(&commit, self->repo, &head_id);
714 if (err < 0) {
715 py_result = Error_set(err);
716 goto out;
717 }
718
719 err = git_merge_analysis_for_ref(&analysis, &preference, self->repo, our_ref, (const git_annotated_commit **) &commit, 1);
720 git_annotated_commit_free(commit);
721 if (err < 0) {
722 py_result = Error_set(err);
723 goto out;
724 }
725
726 // Convert analysis to MergeAnalysis enum
727 PyObject *analysis_enum = pygit2_enum(MergeAnalysisEnum, analysis);
728 if (!analysis_enum) {
729 py_result = NULL;
730 goto out;
731 }
732
733 // Convert preference to MergePreference enum
734 PyObject *preference_enum = pygit2_enum(MergePreferenceEnum, preference);
735 if (!preference_enum) {
736 py_result = NULL;
737 Py_DECREF(analysis_enum);
738 goto out;
739 }
740
741 py_result = Py_BuildValue("(OO)", analysis_enum, preference_enum);
742

Callers

nothing calls this directly

Calls 4

Error_set_strFunction · 0.85
py_oid_to_git_oid_expandFunction · 0.85
Error_setFunction · 0.85
pygit2_enumFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…