1 /*
2  * Copyright (C) the libgit2 contributors. All rights reserved.
3  *
4  * This file is part of libgit2, distributed under the GNU GPL v2 with
5  * a Linking Exception. For full terms see the included COPYING file.
6  */
7 #ifndef INCLUDE_git_graph_h__
8 #define INCLUDE_git_graph_h__
9 
10 #include "common.h"
11 #include "types.h"
12 #include "oid.h"
13 
14 /**
15  * @file git2/graph.h
16  * @brief Git graph traversal routines
17  * @defgroup git_revwalk Git graph traversal routines
18  * @ingroup Git
19  * @{
20  */
21 GIT_BEGIN_DECL
22 
23 /**
24  * Count the number of unique commits between two commit objects
25  *
26  * There is no need for branches containing the commits to have any
27  * upstream relationship, but it helps to think of one as a branch and
28  * the other as its upstream, the `ahead` and `behind` values will be
29  * what git would report for the branches.
30  *
31  * @param ahead number of unique from commits in `upstream`
32  * @param behind number of unique from commits in `local`
33  * @param repo the repository where the commits exist
34  * @param local the commit for local
35  * @param upstream the commit for upstream
36  */
37 GIT_EXTERN(int) git_graph_ahead_behind(size_t *ahead, size_t *behind, git_repository *repo, const git_oid *local, const git_oid *upstream);
38 
39 
40 /**
41  * Determine if a commit is the descendant of another commit.
42  *
43  * Note that a commit is not considered a descendant of itself, in contrast
44  * to `git merge-base --is-ancestor`.
45  *
46  * @param commit a previously loaded commit.
47  * @param ancestor a potential ancestor commit.
48  * @return 1 if the given commit is a descendant of the potential ancestor,
49  * 0 if not, error code otherwise.
50  */
51 GIT_EXTERN(int) git_graph_descendant_of(
52 	git_repository *repo,
53 	const git_oid *commit,
54 	const git_oid *ancestor);
55 
56 /** @} */
57 GIT_END_DECL
58 #endif
59