|
| 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_sys_git_commit_graph_h__ |
| 8 | +#define INCLUDE_sys_git_commit_graph_h__ |
| 9 | + |
| 10 | +#include "git2/common.h" |
| 11 | +#include "git2/types.h" |
| 12 | + |
| 13 | +/** |
| 14 | + * @file git2/commit_graph.h |
| 15 | + * @brief Git commit-graph routines |
| 16 | + * @defgroup git_commit_graph Git commit-graph routines |
| 17 | + * @ingroup Git |
| 18 | + * @{ |
| 19 | + */ |
| 20 | +GIT_BEGIN_DECL |
| 21 | + |
| 22 | +/** |
| 23 | + * Create a new writer for `commit-graph` files. |
| 24 | + * |
| 25 | + * @param out location to store the writer pointer |
| 26 | + * @param objects_info_dir the `objects/info` directory. |
| 27 | + * The `commit-graph` file will be written in this directory. |
| 28 | + * @return 0 or an error code |
| 29 | + */ |
| 30 | +GIT_EXTERN(int) git_commit_graph_writer_new( |
| 31 | + git_commit_graph_writer **out, |
| 32 | + const char *objects_info_dir); |
| 33 | + |
| 34 | +/** |
| 35 | + * Free the commit-graph writer and its resources. |
| 36 | + * |
| 37 | + * @param w the writer to free. If NULL no action is taken. |
| 38 | + */ |
| 39 | +GIT_EXTERN(void) git_commit_graph_writer_free(git_commit_graph_writer *w); |
| 40 | + |
| 41 | +/** |
| 42 | + * Add an `.idx` file (associated to a packfile) to the writer. |
| 43 | + * |
| 44 | + * @param w the writer |
| 45 | + * @param repo the repository that owns the `.idx` file |
| 46 | + * @param idx_path the path of an `.idx` file |
| 47 | + * @return 0 or an error code |
| 48 | + */ |
| 49 | +GIT_EXTERN(int) git_commit_graph_writer_add_index_file( |
| 50 | + git_commit_graph_writer *w, |
| 51 | + git_repository *repo, |
| 52 | + const char *idx_path); |
| 53 | + |
| 54 | +/** |
| 55 | + * Add a revwalk to the writer. This will add all the commits from the revwalk |
| 56 | + * to the commit-graph. |
| 57 | + * |
| 58 | + * @param w the writer |
| 59 | + * @param walk the git_revwalk |
| 60 | + * @return 0 or an error code |
| 61 | + */ |
| 62 | +GIT_EXTERN(int) git_commit_graph_writer_add_revwalk( |
| 63 | + git_commit_graph_writer *w, |
| 64 | + git_revwalk *walk); |
| 65 | + |
| 66 | +/** |
| 67 | + * Write a `commit-graph` file to a file. |
| 68 | + * |
| 69 | + * @param w the writer |
| 70 | + * @return 0 or an error code |
| 71 | + */ |
| 72 | +GIT_EXTERN(int) git_commit_graph_writer_commit( |
| 73 | + git_commit_graph_writer *w); |
| 74 | + |
| 75 | +/** |
| 76 | + * Dump the contents of the `commit-graph` to an in-memory buffer. |
| 77 | + * |
| 78 | + * @param buffer buffer where to store the contents of the `commit-graph`. |
| 79 | + * @param w the writer |
| 80 | + * @return 0 or an error code |
| 81 | + */ |
| 82 | +GIT_EXTERN(int) git_commit_graph_writer_dump( |
| 83 | + git_buf *buffer, |
| 84 | + git_commit_graph_writer *w); |
| 85 | + |
| 86 | +/** @} */ |
| 87 | +GIT_END_DECL |
| 88 | +#endif |
0 commit comments