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>
maint
Taylor Blau 2020-09-17 22:59:49 -04:00 committed by Junio C Hamano
parent 59f0d5073f
commit 98bb796191
3 changed files with 34 additions and 34 deletions

View File

@ -119,7 +119,7 @@ static int graph_verify(int argc, const char **argv)
} }


extern int read_replace_refs; extern int read_replace_refs;
static struct split_commit_graph_opts split_opts; static struct commit_graph_opts write_opts;


static int write_option_parse_split(const struct option *opt, const char *arg, static int write_option_parse_split(const struct option *opt, const char *arg,
int unset) int unset)
@ -187,24 +187,24 @@ static int graph_write(int argc, const char **argv)
OPT_BOOL(0, "changed-paths", &opts.enable_changed_paths, OPT_BOOL(0, "changed-paths", &opts.enable_changed_paths,
N_("enable computation for changed paths")), N_("enable computation for changed paths")),
OPT_BOOL(0, "progress", &opts.progress, N_("force progress reporting")), OPT_BOOL(0, "progress", &opts.progress, N_("force progress reporting")),
OPT_CALLBACK_F(0, "split", &split_opts.flags, NULL, OPT_CALLBACK_F(0, "split", &write_opts.split_flags, NULL,
N_("allow writing an incremental commit-graph file"), N_("allow writing an incremental commit-graph file"),
PARSE_OPT_OPTARG | PARSE_OPT_NONEG, PARSE_OPT_OPTARG | PARSE_OPT_NONEG,
write_option_parse_split), write_option_parse_split),
OPT_INTEGER(0, "max-commits", &split_opts.max_commits, OPT_INTEGER(0, "max-commits", &write_opts.max_commits,
N_("maximum number of commits in a non-base split commit-graph")), N_("maximum number of commits in a non-base split commit-graph")),
OPT_INTEGER(0, "size-multiple", &split_opts.size_multiple, OPT_INTEGER(0, "size-multiple", &write_opts.size_multiple,
N_("maximum ratio between two levels of a split commit-graph")), N_("maximum ratio between two levels of a split commit-graph")),
OPT_EXPIRY_DATE(0, "expire-time", &split_opts.expire_time, OPT_EXPIRY_DATE(0, "expire-time", &write_opts.expire_time,
N_("only expire files older than a given date-time")), N_("only expire files older than a given date-time")),
OPT_END(), OPT_END(),
}; };


opts.progress = isatty(2); opts.progress = isatty(2);
opts.enable_changed_paths = -1; opts.enable_changed_paths = -1;
split_opts.size_multiple = 2; write_opts.size_multiple = 2;
split_opts.max_commits = 0; write_opts.max_commits = 0;
split_opts.expire_time = 0; write_opts.expire_time = 0;


trace2_cmd_mode("write"); trace2_cmd_mode("write");


@ -232,7 +232,7 @@ static int graph_write(int argc, const char **argv)
odb = find_odb(the_repository, opts.obj_dir); odb = find_odb(the_repository, opts.obj_dir);


if (opts.reachable) { if (opts.reachable) {
if (write_commit_graph_reachable(odb, flags, &split_opts)) if (write_commit_graph_reachable(odb, flags, &write_opts))
return 1; return 1;
return 0; return 0;
} }
@ -261,7 +261,7 @@ static int graph_write(int argc, const char **argv)
opts.stdin_packs ? &pack_indexes : NULL, opts.stdin_packs ? &pack_indexes : NULL,
opts.stdin_commits ? &commits : NULL, opts.stdin_commits ? &commits : NULL,
flags, flags,
&split_opts)) &write_opts))
result = 1; result = 1;


cleanup: cleanup:

View File

@ -962,7 +962,7 @@ struct write_commit_graph_context {
changed_paths:1, changed_paths:1,
order_by_pack:1; order_by_pack:1;


const struct split_commit_graph_opts *split_opts; const struct commit_graph_opts *opts;
size_t total_bloom_filter_data_size; size_t total_bloom_filter_data_size;
const struct bloom_filter_settings *bloom_settings; const struct bloom_filter_settings *bloom_settings;


@ -1286,8 +1286,8 @@ static void close_reachable(struct write_commit_graph_context *ctx)
{ {
int i; int i;
struct commit *commit; struct commit *commit;
enum commit_graph_split_flags flags = ctx->split_opts ? enum commit_graph_split_flags flags = ctx->opts ?
ctx->split_opts->flags : COMMIT_GRAPH_SPLIT_UNSPECIFIED; ctx->opts->split_flags : COMMIT_GRAPH_SPLIT_UNSPECIFIED;


if (ctx->report_progress) if (ctx->report_progress)
ctx->progress = start_delayed_progress( ctx->progress = start_delayed_progress(
@ -1476,7 +1476,7 @@ static int add_ref_to_set(const char *refname,


int write_commit_graph_reachable(struct object_directory *odb, int write_commit_graph_reachable(struct object_directory *odb,
enum commit_graph_write_flags flags, enum commit_graph_write_flags flags,
const struct split_commit_graph_opts *split_opts) const struct commit_graph_opts *opts)
{ {
struct oidset commits = OIDSET_INIT; struct oidset commits = OIDSET_INIT;
struct refs_cb_data data; struct refs_cb_data data;
@ -1493,7 +1493,7 @@ int write_commit_graph_reachable(struct object_directory *odb,
stop_progress(&data.progress); stop_progress(&data.progress);


result = write_commit_graph(odb, NULL, &commits, result = write_commit_graph(odb, NULL, &commits,
flags, split_opts); flags, opts);


oidset_clear(&commits); oidset_clear(&commits);
return result; return result;
@ -1608,8 +1608,8 @@ static uint32_t count_distinct_commits(struct write_commit_graph_context *ctx)
static void copy_oids_to_commits(struct write_commit_graph_context *ctx) static void copy_oids_to_commits(struct write_commit_graph_context *ctx)
{ {
uint32_t i; uint32_t i;
enum commit_graph_split_flags flags = ctx->split_opts ? enum commit_graph_split_flags flags = ctx->opts ?
ctx->split_opts->flags : COMMIT_GRAPH_SPLIT_UNSPECIFIED; ctx->opts->split_flags : COMMIT_GRAPH_SPLIT_UNSPECIFIED;


ctx->num_extra_edges = 0; ctx->num_extra_edges = 0;
if (ctx->report_progress) if (ctx->report_progress)
@ -1894,13 +1894,13 @@ static void split_graph_merge_strategy(struct write_commit_graph_context *ctx)
int max_commits = 0; int max_commits = 0;
int size_mult = 2; int size_mult = 2;


if (ctx->split_opts) { if (ctx->opts) {
max_commits = ctx->split_opts->max_commits; max_commits = ctx->opts->max_commits;


if (ctx->split_opts->size_multiple) if (ctx->opts->size_multiple)
size_mult = ctx->split_opts->size_multiple; size_mult = ctx->opts->size_multiple;


flags = ctx->split_opts->flags; flags = ctx->opts->split_flags;
} }


g = ctx->r->objects->commit_graph; g = ctx->r->objects->commit_graph;
@ -2078,8 +2078,8 @@ static void expire_commit_graphs(struct write_commit_graph_context *ctx)
size_t dirnamelen; size_t dirnamelen;
timestamp_t expire_time = time(NULL); timestamp_t expire_time = time(NULL);


if (ctx->split_opts && ctx->split_opts->expire_time) if (ctx->opts && ctx->opts->expire_time)
expire_time = ctx->split_opts->expire_time; expire_time = ctx->opts->expire_time;
if (!ctx->split) { if (!ctx->split) {
char *chain_file_name = get_chain_filename(ctx->odb); char *chain_file_name = get_chain_filename(ctx->odb);
unlink(chain_file_name); unlink(chain_file_name);
@ -2130,7 +2130,7 @@ int write_commit_graph(struct object_directory *odb,
struct string_list *pack_indexes, struct string_list *pack_indexes,
struct oidset *commits, struct oidset *commits,
enum commit_graph_write_flags flags, enum commit_graph_write_flags flags,
const struct split_commit_graph_opts *split_opts) const struct commit_graph_opts *opts)
{ {
struct write_commit_graph_context *ctx; struct write_commit_graph_context *ctx;
uint32_t i, count_distinct = 0; uint32_t i, count_distinct = 0;
@ -2147,7 +2147,7 @@ int write_commit_graph(struct object_directory *odb,
ctx->append = flags & COMMIT_GRAPH_WRITE_APPEND ? 1 : 0; ctx->append = flags & COMMIT_GRAPH_WRITE_APPEND ? 1 : 0;
ctx->report_progress = flags & COMMIT_GRAPH_WRITE_PROGRESS ? 1 : 0; ctx->report_progress = flags & COMMIT_GRAPH_WRITE_PROGRESS ? 1 : 0;
ctx->split = flags & COMMIT_GRAPH_WRITE_SPLIT ? 1 : 0; ctx->split = flags & COMMIT_GRAPH_WRITE_SPLIT ? 1 : 0;
ctx->split_opts = split_opts; ctx->opts = opts;
ctx->total_bloom_filter_data_size = 0; ctx->total_bloom_filter_data_size = 0;


bloom_settings.bits_per_entry = git_env_ulong("GIT_TEST_BLOOM_SETTINGS_BITS_PER_ENTRY", 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,
} }
} }


if (ctx->split_opts) if (ctx->opts)
replace = ctx->split_opts->flags & COMMIT_GRAPH_SPLIT_REPLACE; replace = ctx->opts->split_flags & COMMIT_GRAPH_SPLIT_REPLACE;
} }


ctx->approx_nr_objects = approximate_object_count(); ctx->approx_nr_objects = approximate_object_count();
ctx->oids.alloc = ctx->approx_nr_objects / 32; ctx->oids.alloc = ctx->approx_nr_objects / 32;


if (ctx->split && split_opts && ctx->oids.alloc > split_opts->max_commits) if (ctx->split && opts && ctx->oids.alloc > opts->max_commits)
ctx->oids.alloc = split_opts->max_commits; ctx->oids.alloc = opts->max_commits;


if (ctx->append) { if (ctx->append) {
prepare_commit_graph_one(ctx->r, ctx->odb); prepare_commit_graph_one(ctx->r, ctx->odb);

View File

@ -105,11 +105,11 @@ enum commit_graph_split_flags {
COMMIT_GRAPH_SPLIT_REPLACE = 2 COMMIT_GRAPH_SPLIT_REPLACE = 2
}; };


struct split_commit_graph_opts { struct commit_graph_opts {
int size_multiple; int size_multiple;
int max_commits; int max_commits;
timestamp_t expire_time; timestamp_t expire_time;
enum commit_graph_split_flags flags; enum commit_graph_split_flags split_flags;
}; };


/* /*
@ -120,12 +120,12 @@ struct split_commit_graph_opts {
*/ */
int write_commit_graph_reachable(struct object_directory *odb, int write_commit_graph_reachable(struct object_directory *odb,
enum commit_graph_write_flags flags, enum commit_graph_write_flags flags,
const struct split_commit_graph_opts *split_opts); const struct commit_graph_opts *opts);
int write_commit_graph(struct object_directory *odb, int write_commit_graph(struct object_directory *odb,
struct string_list *pack_indexes, struct string_list *pack_indexes,
struct oidset *commits, struct oidset *commits,
enum commit_graph_write_flags flags, enum commit_graph_write_flags flags,
const struct split_commit_graph_opts *split_opts); const struct commit_graph_opts *opts);


#define COMMIT_GRAPH_VERIFY_SHALLOW (1 << 0) #define COMMIT_GRAPH_VERIFY_SHALLOW (1 << 0)