diff options
author | lhchavez <lhchavez@lhchavez.com> | 2021-08-26 05:29:34 -0700 |
---|---|---|
committer | lhchavez <lhchavez@lhchavez.com> | 2021-08-26 05:29:34 -0700 |
commit | 63f08e4258122d6f6ea1f04ec8c08779bf300b6c (patch) | |
tree | 36375d662c59faa07a647e697bc4c9150b642dda | |
parent | 2988f7367cda7337e2b293fb12814d272ef9c33b (diff) | |
download | libgit2-63f08e4258122d6f6ea1f04ec8c08779bf300b6c.tar.gz |
Make the defaultable fields defaultable
Also, add `git_commit_graph_writer_options_init`!
-rw-r--r-- | include/git2/sys/commit_graph.h | 4 | ||||
-rw-r--r-- | src/commit_graph.c | 14 | ||||
-rw-r--r-- | tests/core/structinit.c | 8 |
3 files changed, 23 insertions, 3 deletions
diff --git a/include/git2/sys/commit_graph.h b/include/git2/sys/commit_graph.h index 01cf8d1bf..67d95469c 100644 --- a/include/git2/sys/commit_graph.h +++ b/include/git2/sys/commit_graph.h @@ -115,12 +115,13 @@ typedef struct { /** * The number of commits in level N is less than X times the number of - * commits in level N + 1. + * commits in level N + 1. Default is 2. */ float size_multiple; /** * The number of commits in level N + 1 is more than C commits. + * Default is 64000. */ size_t max_commits; } git_commit_graph_writer_options; @@ -129,7 +130,6 @@ typedef struct { #define GIT_COMMIT_GRAPH_WRITER_OPTIONS_INIT \ { \ GIT_COMMIT_GRAPH_WRITER_OPTIONS_VERSION, \ - GIT_COMMIT_GRAPH_SPLIT_STRATEGY_SINGLE_FILE, 2.0f, 64000 \ } /** diff --git a/src/commit_graph.c b/src/commit_graph.c index 78ab436d6..1601c630c 100644 --- a/src/commit_graph.c +++ b/src/commit_graph.c @@ -1143,6 +1143,18 @@ static int commit_graph_write_filebuf(const char *buf, size_t size, void *data) return git_filebuf_write(f, buf, size); } +int git_commit_graph_writer_options_init( + git_commit_graph_writer_options *opts, + unsigned int version) +{ + GIT_INIT_STRUCTURE_FROM_TEMPLATE( + opts, + version, + git_commit_graph_writer_options, + GIT_COMMIT_GRAPH_WRITER_OPTIONS_INIT); + return 0; +} + int git_commit_graph_writer_commit( git_commit_graph_writer *w, git_commit_graph_writer_options *opts) @@ -1152,7 +1164,7 @@ int git_commit_graph_writer_commit( git_buf commit_graph_path = GIT_BUF_INIT; git_filebuf output = GIT_FILEBUF_INIT; - /* TODO: support options. */ + /* TODO: support options and fill in defaults. */ GIT_UNUSED(opts); error = git_buf_joinpath( diff --git a/tests/core/structinit.c b/tests/core/structinit.c index b6377bdde..d24da874d 100644 --- a/tests/core/structinit.c +++ b/tests/core/structinit.c @@ -1,4 +1,5 @@ #include "clar_libgit2.h" +#include <git2/sys/commit_graph.h> #include <git2/sys/config.h> #include <git2/sys/filter.h> #include <git2/sys/odb_backend.h> @@ -97,6 +98,13 @@ void test_core_structinit__compare(void) git_clone_options, GIT_CLONE_OPTIONS_VERSION, \ GIT_CLONE_OPTIONS_INIT, git_clone_options_init); + /* commit_graph_writer */ + CHECK_MACRO_FUNC_INIT_EQUAL( \ + git_commit_graph_writer_options, \ + GIT_COMMIT_GRAPH_WRITER_OPTIONS_VERSION, \ + GIT_COMMIT_GRAPH_WRITER_OPTIONS_INIT, \ + git_commit_graph_writer_options_init); + /* diff */ CHECK_MACRO_FUNC_INIT_EQUAL( \ git_diff_options, GIT_DIFF_OPTIONS_VERSION, \ |