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 /** 8 * License: GPL-2.0(Linking Exception) 9 */ 10 module libgit2.graph; 11 12 13 private static import libgit2.oid; 14 private static import libgit2.types; 15 private import libgit2.common: GIT_EXTERN; 16 17 /* 18 * @file git2/graph.h 19 * @brief Git graph traversal routines 20 * @defgroup git_revwalk Git graph traversal routines 21 * @ingroup Git 22 * @{ 23 */ 24 extern (C): 25 nothrow @nogc: 26 public: 27 28 /** 29 * Count the number of unique commits between two commit objects 30 * 31 * There is no need for branches containing the commits to have any 32 * upstream relationship, but it helps to think of one as a branch and 33 * the other as its upstream, the `ahead` and `behind` values will be 34 * what git would report for the branches. 35 * 36 * Params: 37 * ahead = number of unique from commits in `upstream` 38 * behind = number of unique from commits in `local` 39 * repo = the repository where the commits exist 40 * local = the commit for local 41 * upstream = the commit for upstream 42 * 43 * Returns: 0 or an error code. 44 */ 45 @GIT_EXTERN 46 int git_graph_ahead_behind(size_t* ahead, size_t* behind, libgit2.types.git_repository* repo, const (libgit2.oid.git_oid)* local, const (libgit2.oid.git_oid)* upstream); 47 48 /** 49 * Determine if a commit is the descendant of another commit. 50 * 51 * Note that a commit is not considered a descendant of itself, in contrast 52 * to `git merge-base --is-ancestor`. 53 * 54 * Params: 55 * repo = the repository where the commits exist 56 * commit = a previously loaded commit 57 * ancestor = a potential ancestor commit 58 * 59 * Returns: 1 if the given commit is a descendant of the potential ancestor, 0 if not, error code otherwise. 60 */ 61 @GIT_EXTERN 62 int git_graph_descendant_of(libgit2.types.git_repository* repo, const (libgit2.oid.git_oid)* commit, const (libgit2.oid.git_oid)* ancestor); 63 64 /** 65 * Determine if a commit is reachable from any of a list of commits by 66 * following parent edges. 67 * 68 * Params: 69 * repo = the repository where the commits exist 70 * commit = a previously loaded commit 71 * length = the number of commits in the provided `descendant_array` 72 * descendant_array = oids of the commits 73 * 74 * Returns: 1 if the given commit is an ancestor of any of the given potential descendants, 0 if not, error code otherwise. 75 */ 76 @GIT_EXTERN 77 int git_graph_reachable_from_any(libgit2.types.git_repository* repo, const (libgit2.oid.git_oid)* commit, const (libgit2.oid.git_oid)* descendant_array, size_t length); 78 79 /* @} */