commit-graph: rename 'split_commit_graph_opts'
In the subsequent commit, additional options will be added to the commit-graph API which have nothing to do with splitting. Rename the 'split_commit_graph_opts' structure to the more-generic 'commit_graph_opts' to encompass both. Likewise, rename the 'flags' member to instead be 'split_flags' to clarify that it only has to do with the behavior implied by '--split'. Suggested-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Taylor Blau committed
Sep 17, 2020 at 22:59 UTC
98bb796191f7234c88b7a97f587d37ffbd130289
3 files changed
+34
-34
builtin/commit-graph.c
+10
-10
@@ -119,7 +119,7 @@ static int graph_verify(int argc, const char **argv)
119
}
120
121
extern int read_replace_refs;
122
-static struct split_commit_graph_opts split_opts;
122
+static struct commit_graph_opts write_opts;
123
124
static int write_option_parse_split(const struct option *opt, const char *arg,
125
int unset)
@@ -187,24 +187,24 @@ static int graph_write(int argc, const char **argv)
187
OPT_BOOL(0, "changed-paths", &opts.enable_changed_paths,
188
N_("enable computation for changed paths")),
189
OPT_BOOL(0, "progress", &opts.progress, N_("force progress reporting")),
190
- OPT_CALLBACK_F(0, "split", &split_opts.flags, NULL,
190
+ OPT_CALLBACK_F(0, "split", &write_opts.split_flags, NULL,
191
N_("allow writing an incremental commit-graph file"),
192
PARSE_OPT_OPTARG | PARSE_OPT_NONEG,
193
write_option_parse_split),
194
- OPT_INTEGER(0, "max-commits", &split_opts.max_commits,
194
+ OPT_INTEGER(0, "max-commits", &write_opts.max_commits,
195
N_("maximum number of commits in a non-base split commit-graph")),
196
- OPT_INTEGER(0, "size-multiple", &split_opts.size_multiple,
196
+ OPT_INTEGER(0, "size-multiple", &write_opts.size_multiple,
197
N_("maximum ratio between two levels of a split commit-graph")),
198
- OPT_EXPIRY_DATE(0, "expire-time", &split_opts.expire_time,
198
+ OPT_EXPIRY_DATE(0, "expire-time", &write_opts.expire_time,
199
N_("only expire files older than a given date-time")),
200
OPT_END(),
201
};
202
203
opts.progress = isatty(2);
204
opts.enable_changed_paths = -1;
205
- split_opts.size_multiple = 2;
206
- split_opts.max_commits = 0;
207
- split_opts.expire_time = 0;
205
+ write_opts.size_multiple = 2;
206
+ write_opts.max_commits = 0;
207
+ write_opts.expire_time = 0;
208
209
trace2_cmd_mode("write");
210
@@ -232,7 +232,7 @@ static int graph_write(int argc, const char **argv)
232
odb = find_odb(the_repository, opts.obj_dir);
233
234
if (opts.reachable) {
235
- if (write_commit_graph_reachable(odb, flags, &split_opts))
235
+ if (write_commit_graph_reachable(odb, flags, &write_opts))
236
return 1;
237
return 0;
238
}
@@ -261,7 +261,7 @@ static int graph_write(int argc, const char **argv)
261
opts.stdin_packs ? &pack_indexes : NULL,
262
opts.stdin_commits ? &commits : NULL,
263
flags,
264
- &split_opts))
264
+ &write_opts))
265
result = 1;
266
267
cleanup:
commit-graph.c
+20
-20
@@ -962,7 +962,7 @@ struct write_commit_graph_context {
962
changed_paths:1,
963
order_by_pack:1;
964
965
- const struct split_commit_graph_opts *split_opts;
965
+ const struct commit_graph_opts *opts;
966
size_t total_bloom_filter_data_size;
967
const struct bloom_filter_settings *bloom_settings;
968
@@ -1286,8 +1286,8 @@ static void close_reachable(struct write_commit_graph_context *ctx)
1286
{
1287
int i;
1288
struct commit *commit;
1289
- enum commit_graph_split_flags flags = ctx->split_opts ?
1290
- ctx->split_opts->flags : COMMIT_GRAPH_SPLIT_UNSPECIFIED;
1289
+ enum commit_graph_split_flags flags = ctx->opts ?
1290
+ ctx->opts->split_flags : COMMIT_GRAPH_SPLIT_UNSPECIFIED;
1291
1292
if (ctx->report_progress)
1293
ctx->progress = start_delayed_progress(
@@ -1476,7 +1476,7 @@ static int add_ref_to_set(const char *refname,
1476
1477
int write_commit_graph_reachable(struct object_directory *odb,
1478
enum commit_graph_write_flags flags,
1479
- const struct split_commit_graph_opts *split_opts)
1479
+ const struct commit_graph_opts *opts)
1480
{
1481
struct oidset commits = OIDSET_INIT;
1482
struct refs_cb_data data;
@@ -1493,7 +1493,7 @@ int write_commit_graph_reachable(struct object_directory *odb,
1493
stop_progress(&data.progress);
1494
1495
result = write_commit_graph(odb, NULL, &commits,
1496
- flags, split_opts);
1496
+ flags, opts);
1497
1498
oidset_clear(&commits);
1499
return result;
@@ -1608,8 +1608,8 @@ static uint32_t count_distinct_commits(struct write_commit_graph_context *ctx)
1608
static void copy_oids_to_commits(struct write_commit_graph_context *ctx)
1609
{
1610
uint32_t i;
1611
- enum commit_graph_split_flags flags = ctx->split_opts ?
1612
- ctx->split_opts->flags : COMMIT_GRAPH_SPLIT_UNSPECIFIED;
1611
+ enum commit_graph_split_flags flags = ctx->opts ?
1612
+ ctx->opts->split_flags : COMMIT_GRAPH_SPLIT_UNSPECIFIED;
1613
1614
ctx->num_extra_edges = 0;
1615
if (ctx->report_progress)
@@ -1894,13 +1894,13 @@ static void split_graph_merge_strategy(struct write_commit_graph_context *ctx)
1894
int max_commits = 0;
1895
int size_mult = 2;
1896
1897
- if (ctx->split_opts) {
1898
- max_commits = ctx->split_opts->max_commits;
1897
+ if (ctx->opts) {
1898
+ max_commits = ctx->opts->max_commits;
1899
1900
- if (ctx->split_opts->size_multiple)
1901
- size_mult = ctx->split_opts->size_multiple;
1900
+ if (ctx->opts->size_multiple)
1901
+ size_mult = ctx->opts->size_multiple;
1902
1903
- flags = ctx->split_opts->flags;
1903
+ flags = ctx->opts->split_flags;
1904
}
1905
1906
g = ctx->r->objects->commit_graph;
@@ -2078,8 +2078,8 @@ static void expire_commit_graphs(struct write_commit_graph_context *ctx)
2078
size_t dirnamelen;
2079
timestamp_t expire_time = time(NULL);
2080
2081
- if (ctx->split_opts && ctx->split_opts->expire_time)
2082
- expire_time = ctx->split_opts->expire_time;
2081
+ if (ctx->opts && ctx->opts->expire_time)
2082
+ expire_time = ctx->opts->expire_time;
2083
if (!ctx->split) {
2084
char *chain_file_name = get_chain_filename(ctx->odb);
2085
unlink(chain_file_name);
@@ -2130,7 +2130,7 @@ int write_commit_graph(struct object_directory *odb,
2130
struct string_list *pack_indexes,
2131
struct oidset *commits,
2132
enum commit_graph_write_flags flags,
2133
- const struct split_commit_graph_opts *split_opts)
2133
+ const struct commit_graph_opts *opts)
2134
{
2135
struct write_commit_graph_context *ctx;
2136
uint32_t i, count_distinct = 0;
@@ -2147,7 +2147,7 @@ int write_commit_graph(struct object_directory *odb,
2147
ctx->append = flags & COMMIT_GRAPH_WRITE_APPEND ? 1 : 0;
2148
ctx->report_progress = flags & COMMIT_GRAPH_WRITE_PROGRESS ? 1 : 0;
2149
ctx->split = flags & COMMIT_GRAPH_WRITE_SPLIT ? 1 : 0;
2150
- ctx->split_opts = split_opts;
2150
+ ctx->opts = opts;
2151
ctx->total_bloom_filter_data_size = 0;
2152
2153
bloom_settings.bits_per_entry = git_env_ulong("GIT_TEST_BLOOM_SETTINGS_BITS_PER_ENTRY",
@@ -2195,15 +2195,15 @@ int write_commit_graph(struct object_directory *odb,
2195
}
2196
}
2197
2198
- if (ctx->split_opts)
2199
- replace = ctx->split_opts->flags & COMMIT_GRAPH_SPLIT_REPLACE;
2198
+ if (ctx->opts)
2199
+ replace = ctx->opts->split_flags & COMMIT_GRAPH_SPLIT_REPLACE;
2200
}
2201
2202
ctx->approx_nr_objects = approximate_object_count();
2203
ctx->oids.alloc = ctx->approx_nr_objects / 32;
2204
2205
- if (ctx->split && split_opts && ctx->oids.alloc > split_opts->max_commits)
2206
- ctx->oids.alloc = split_opts->max_commits;
2205
+ if (ctx->split && opts && ctx->oids.alloc > opts->max_commits)
2206
+ ctx->oids.alloc = opts->max_commits;
2207
2208
if (ctx->append) {
2209
prepare_commit_graph_one(ctx->r, ctx->odb);
commit-graph.h
+4
-4
@@ -105,11 +105,11 @@ enum commit_graph_split_flags {
105
COMMIT_GRAPH_SPLIT_REPLACE = 2
106
};
107
108
-struct split_commit_graph_opts {
108
+struct commit_graph_opts {
109
int size_multiple;
110
int max_commits;
111
timestamp_t expire_time;
112
- enum commit_graph_split_flags flags;
112
+ enum commit_graph_split_flags split_flags;
113
};
114
115
/*
@@ -120,12 +120,12 @@ struct split_commit_graph_opts {
120
*/
121
int write_commit_graph_reachable(struct object_directory *odb,
122
enum commit_graph_write_flags flags,
123
- const struct split_commit_graph_opts *split_opts);
123
+ const struct commit_graph_opts *opts);
124
int write_commit_graph(struct object_directory *odb,
125
struct string_list *pack_indexes,
126
struct oidset *commits,
127
enum commit_graph_write_flags flags,
128
- const struct split_commit_graph_opts *split_opts);
128
+ const struct commit_graph_opts *opts);
129
130
#define COMMIT_GRAPH_VERIFY_SHALLOW (1 << 0)
131