mirror of
https://github.com/libgit2/libgit2.git
synced 2026-06-22 06:26:26 +00:00
commit_graph: move opts to new function
Instead of making the commit and dump functions take individual options structures; provide the options structure to the writer creator. This allows us to add additional information (like OID type) during generation.
This commit is contained in:
@@ -46,54 +46,6 @@ GIT_EXTERN(int) git_commit_graph_open(
|
||||
*/
|
||||
GIT_EXTERN(void) git_commit_graph_free(git_commit_graph *cgraph);
|
||||
|
||||
/**
|
||||
* Create a new writer for `commit-graph` files.
|
||||
*
|
||||
* @param out Location to store the writer pointer.
|
||||
* @param objects_info_dir The `objects/info` directory.
|
||||
* The `commit-graph` file will be written in this directory.
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_commit_graph_writer_new(
|
||||
git_commit_graph_writer **out,
|
||||
const char *objects_info_dir
|
||||
#ifdef GIT_EXPERIMENTAL_SHA256
|
||||
, git_oid_t oid_type
|
||||
#endif
|
||||
);
|
||||
|
||||
/**
|
||||
* Free the commit-graph writer and its resources.
|
||||
*
|
||||
* @param w The writer to free. If NULL no action is taken.
|
||||
*/
|
||||
GIT_EXTERN(void) git_commit_graph_writer_free(git_commit_graph_writer *w);
|
||||
|
||||
/**
|
||||
* Add an `.idx` file (associated to a packfile) to the writer.
|
||||
*
|
||||
* @param w The writer.
|
||||
* @param repo The repository that owns the `.idx` file.
|
||||
* @param idx_path The path of an `.idx` file.
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_commit_graph_writer_add_index_file(
|
||||
git_commit_graph_writer *w,
|
||||
git_repository *repo,
|
||||
const char *idx_path);
|
||||
|
||||
/**
|
||||
* Add a revwalk to the writer. This will add all the commits from the revwalk
|
||||
* to the commit-graph.
|
||||
*
|
||||
* @param w The writer.
|
||||
* @param walk The git_revwalk.
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_commit_graph_writer_add_revwalk(
|
||||
git_commit_graph_writer *w,
|
||||
git_revwalk *walk);
|
||||
|
||||
|
||||
/**
|
||||
* The strategy to use when adding a new set of commits to a pre-existing
|
||||
@@ -108,15 +60,19 @@ typedef enum {
|
||||
} git_commit_graph_split_strategy_t;
|
||||
|
||||
/**
|
||||
* Options structure for
|
||||
* `git_commit_graph_writer_commit`/`git_commit_graph_writer_dump`.
|
||||
* Options structure for `git_commit_graph_writer_new`.
|
||||
*
|
||||
* Initialize with `GIT_COMMIT_GRAPH_WRITER_OPTIONS_INIT`. Alternatively, you
|
||||
* can use `git_commit_graph_writer_options_init`.
|
||||
* Initialize with `GIT_COMMIT_GRAPH_WRITER_OPTIONS_INIT`. Alternatively,
|
||||
* you can use `git_commit_graph_writer_options_init`.
|
||||
*/
|
||||
typedef struct {
|
||||
unsigned int version;
|
||||
|
||||
#ifdef GIT_EXPERIMENTAL_SHA256
|
||||
/** The object ID type that this commit graph contains. */
|
||||
git_oid_t oid_type;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* The strategy to use when adding new commits to a pre-existing commit-graph
|
||||
* chain.
|
||||
@@ -158,29 +114,71 @@ GIT_EXTERN(int) git_commit_graph_writer_options_init(
|
||||
git_commit_graph_writer_options *opts,
|
||||
unsigned int version);
|
||||
|
||||
/**
|
||||
* Create a new writer for `commit-graph` files.
|
||||
*
|
||||
* @param out Location to store the writer pointer.
|
||||
* @param objects_info_dir The `objects/info` directory.
|
||||
* The `commit-graph` file will be written in this directory.
|
||||
* @param options The options for the commit graph writer.
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_commit_graph_writer_new(
|
||||
git_commit_graph_writer **out,
|
||||
const char *objects_info_dir,
|
||||
const git_commit_graph_writer_options *options);
|
||||
|
||||
/**
|
||||
* Free the commit-graph writer and its resources.
|
||||
*
|
||||
* @param w The writer to free. If NULL no action is taken.
|
||||
*/
|
||||
GIT_EXTERN(void) git_commit_graph_writer_free(git_commit_graph_writer *w);
|
||||
|
||||
/**
|
||||
* Add an `.idx` file (associated to a packfile) to the writer.
|
||||
*
|
||||
* @param w The writer.
|
||||
* @param repo The repository that owns the `.idx` file.
|
||||
* @param idx_path The path of an `.idx` file.
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_commit_graph_writer_add_index_file(
|
||||
git_commit_graph_writer *w,
|
||||
git_repository *repo,
|
||||
const char *idx_path);
|
||||
|
||||
/**
|
||||
* Add a revwalk to the writer. This will add all the commits from the revwalk
|
||||
* to the commit-graph.
|
||||
*
|
||||
* @param w The writer.
|
||||
* @param walk The git_revwalk.
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_commit_graph_writer_add_revwalk(
|
||||
git_commit_graph_writer *w,
|
||||
git_revwalk *walk);
|
||||
|
||||
/**
|
||||
* Write a `commit-graph` file to a file.
|
||||
*
|
||||
* @param w The writer
|
||||
* @param opts Pointer to git_commit_graph_writer_options struct.
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_commit_graph_writer_commit(
|
||||
git_commit_graph_writer *w,
|
||||
git_commit_graph_writer_options *opts);
|
||||
git_commit_graph_writer *w);
|
||||
|
||||
/**
|
||||
* Dump the contents of the `commit-graph` to an in-memory buffer.
|
||||
*
|
||||
* @param buffer Buffer where to store the contents of the `commit-graph`.
|
||||
* @param[out] buffer Buffer where to store the contents of the `commit-graph`.
|
||||
* @param w The writer.
|
||||
* @param opts Pointer to git_commit_graph_writer_options struct.
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_commit_graph_writer_dump(
|
||||
git_buf *buffer,
|
||||
git_commit_graph_writer *w,
|
||||
git_commit_graph_writer_options *opts);
|
||||
git_commit_graph_writer *w);
|
||||
|
||||
/** @} */
|
||||
GIT_END_DECL
|
||||
|
||||
Reference in New Issue
Block a user