Skip to content

Instantly share code, notes, and snippets.

@yorah
Created March 27, 2013 15:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yorah/5255190 to your computer and use it in GitHub Desktop.
Save yorah/5255190 to your computer and use it in GitHub Desktop.
API proposal to retrieve both the ahead/behind count, and the actual commits. `git_commit_list` would be an opaque type containing a `git_vector`
typedef struct git_commit_list git_commit_list;
/**
* 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.
*
* @param ahead number of unique from commits in `upstream`
* @param behind number of unique from commits in `local`
* @param repo the repository where the commits exist
* @param local the commit for local
* @param upstream the commit for upstream
*/
GIT_EXTERN(int) git_graph_ahead_behind(
git_commit_list **ahead,
git_commit_list **behind,
git_repository *repo,
const git_oid *local,
const git_oid *upstream);
/**
* Return the count of elements in the list.
*/
GIT_EXTERN(int) git_commit_list_count(git_commit_list *list);
/**
* Return the nth element of the list.
*/
GIT_EXTERN(const git_oid *) git_commit_list_get_byindex(
git_commit_list *list,
size_t pos);
/**
* Free a git_commit_list
*/
GIT_EXTERN(int) git_commit_list_free( git_commit_list *list);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment