Skip to content

Commit 63f08e4

Browse files
committed
Make the defaultable fields defaultable
Also, add `git_commit_graph_writer_options_init`!
1 parent 2988f73 commit 63f08e4

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

include/git2/sys/commit_graph.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,13 @@ typedef struct {
115115

116116
/**
117117
* The number of commits in level N is less than X times the number of
118-
* commits in level N + 1.
118+
* commits in level N + 1. Default is 2.
119119
*/
120120
float size_multiple;
121121

122122
/**
123123
* The number of commits in level N + 1 is more than C commits.
124+
* Default is 64000.
124125
*/
125126
size_t max_commits;
126127
} git_commit_graph_writer_options;
@@ -129,7 +130,6 @@ typedef struct {
129130
#define GIT_COMMIT_GRAPH_WRITER_OPTIONS_INIT \
130131
{ \
131132
GIT_COMMIT_GRAPH_WRITER_OPTIONS_VERSION, \
132-
GIT_COMMIT_GRAPH_SPLIT_STRATEGY_SINGLE_FILE, 2.0f, 64000 \
133133
}
134134

135135
/**

src/commit_graph.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1143,6 +1143,18 @@ static int commit_graph_write_filebuf(const char *buf, size_t size, void *data)
11431143
return git_filebuf_write(f, buf, size);
11441144
}
11451145

1146+
int git_commit_graph_writer_options_init(
1147+
git_commit_graph_writer_options *opts,
1148+
unsigned int version)
1149+
{
1150+
GIT_INIT_STRUCTURE_FROM_TEMPLATE(
1151+
opts,
1152+
version,
1153+
git_commit_graph_writer_options,
1154+
GIT_COMMIT_GRAPH_WRITER_OPTIONS_INIT);
1155+
return 0;
1156+
}
1157+
11461158
int git_commit_graph_writer_commit(
11471159
git_commit_graph_writer *w,
11481160
git_commit_graph_writer_options *opts)
@@ -1152,7 +1164,7 @@ int git_commit_graph_writer_commit(
11521164
git_buf commit_graph_path = GIT_BUF_INIT;
11531165
git_filebuf output = GIT_FILEBUF_INIT;
11541166

1155-
/* TODO: support options. */
1167+
/* TODO: support options and fill in defaults. */
11561168
GIT_UNUSED(opts);
11571169

11581170
error = git_buf_joinpath(

tests/core/structinit.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "clar_libgit2.h"
2+
#include <git2/sys/commit_graph.h>
23
#include <git2/sys/config.h>
34
#include <git2/sys/filter.h>
45
#include <git2/sys/odb_backend.h>
@@ -97,6 +98,13 @@ void test_core_structinit__compare(void)
9798
git_clone_options, GIT_CLONE_OPTIONS_VERSION, \
9899
GIT_CLONE_OPTIONS_INIT, git_clone_options_init);
99100

101+
/* commit_graph_writer */
102+
CHECK_MACRO_FUNC_INIT_EQUAL( \
103+
git_commit_graph_writer_options, \
104+
GIT_COMMIT_GRAPH_WRITER_OPTIONS_VERSION, \
105+
GIT_COMMIT_GRAPH_WRITER_OPTIONS_INIT, \
106+
git_commit_graph_writer_options_init);
107+
100108
/* diff */
101109
CHECK_MACRO_FUNC_INIT_EQUAL( \
102110
git_diff_options, GIT_DIFF_OPTIONS_VERSION, \

0 commit comments

Comments
 (0)