libgit2

git_merge_bases_many

Version:

Find all merge bases given a list of commits

This behaves similar to git merge-base.

Given three commits a, b, and c, merge_base_many will compute a hypothetical commit m, which is a merge between b and c.

For example, with the following topology:

       o---o---o---o---C
      /
     /   o---o---o---B
    /   /
---2---1---o---o---o---A

the result of merge_base_many given a, b, and c is 1. This is because the equivalent topology with the imaginary merge commit m between b and c is:

       o---o---o---o---o
      /                 
\
     /   o---o---o---o---M
    /   /
---2---1---o---o---o---A

and the result of merge_base_many given a and m is 1.

If you're looking to recieve the common ancestor between all the given commits, use merge_base_octopus.

Signature

int git_merge_bases_many(git_oidarray *out, git_repository *repo, size_t length, const git_oid *input_array);

Parameters

In
out

array in which to store the resulting ids

In
repo

the repository where the commits exist

size_t
In
length

The number of commits in the provided input_array

In
input_array

oids of the commits

Returns

int

Zero on success; GIT_ENOTFOUND or -1 on failure.

Versions