libgit2

git_graph_ahead_behind

Version:

Count the number of unique commits between two commit objects

There is no need for branches containing the commits to have any upstream relationship, but it helps to think of one as a branch and the other as its upstream, the ahead and behind values will be what git would report for the branches.

Signature

int git_graph_ahead_behind(size_t *ahead, size_t *behind, git_repository *repo, const git_oid *local, const git_oid *upstream);

Parameters

size_t *
In
ahead

number of unique from commits in upstream

size_t *
In
behind

number of unique from commits in local

In
repo

the repository where the commits exist

In
local

the commit for local

In
upstream

the commit for upstream

Returns

int

Versions