summaryrefslogtreecommitdiff
path: root/include/git2/sys
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2021-07-26 16:27:54 -0400
committerGitHub <noreply@github.com>2021-07-26 16:27:54 -0400
commit2370e4910262f941a3bb0f70ce05ff7a90679fe1 (patch)
tree1d3b183d7b14ab3bf4a2d3b11ead833ef073a825 /include/git2/sys
parent43b5075df4c543fc8801ed4b829702d7f9f2c0ad (diff)
parent25b75cd9bc01896a2b74c748ceef7110ea1b165f (diff)
downloadlibgit2-2370e4910262f941a3bb0f70ce05ff7a90679fe1.tar.gz
Merge pull request #5765 from lhchavez/cgraph-revwalks
commit-graph: Use the commit-graph in revwalks
Diffstat (limited to 'include/git2/sys')
-rw-r--r--include/git2/sys/commit_graph.h45
1 files changed, 45 insertions, 0 deletions
diff --git a/include/git2/sys/commit_graph.h b/include/git2/sys/commit_graph.h
new file mode 100644
index 000000000..038c9b739
--- /dev/null
+++ b/include/git2/sys/commit_graph.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) the libgit2 contributors. All rights reserved.
+ *
+ * This file is part of libgit2, distributed under the GNU GPL v2 with
+ * a Linking Exception. For full terms see the included COPYING file.
+ */
+#ifndef INCLUDE_sys_git_commit_graph_h__
+#define INCLUDE_sys_git_commit_graph_h__
+
+#include "git2/common.h"
+#include "git2/types.h"
+
+/**
+ * @file git2/sys/commit_graph.h
+ * @brief Git commit-graph
+ * @defgroup git_commit_graph Git commit-graph APIs
+ * @ingroup Git
+ * @{
+ */
+GIT_BEGIN_DECL
+
+/**
+ * Opens a `git_commit_graph` from a path to an objects directory.
+ *
+ * This finds, opens, and validates the `commit-graph` file.
+ *
+ * @param cgraph_out the `git_commit_graph` struct to initialize.
+ * @param objects_dir the path to a git objects directory.
+ * @return Zero on success; -1 on failure.
+ */
+GIT_EXTERN(int) git_commit_graph_open(git_commit_graph **cgraph_out, const char *objects_dir);
+
+/**
+ * Frees commit-graph data. This should only be called when memory allocated
+ * using `git_commit_graph_open` is not returned to libgit2 because it was not
+ * associated with the ODB through a successful call to
+ * `git_odb_set_commit_graph`.
+ *
+ * @param cgraph the commit-graph object to free. If NULL, no action is taken.
+ */
+GIT_EXTERN(void) git_commit_graph_free(git_commit_graph *cgraph);
+
+GIT_END_DECL
+
+#endif