The options "max-commits" and "size-multiple" are both supposed to be positive integers and are documented as such, but we use a signed integer field to store them. This causes sign comparison warnings in `split_graph_merge_strategy()` because we end up comparing the option values with the observed number of commits. Fix the issue by converting the fields to be unsigned and convert the options to use `OPT_UNSIGNED()` accordingly. This macro has only been introduced recently, which might explain why the option values were signed in the first place. Signed-off-by: Patrick Steinhardt <ps@xxxxxx> --- builtin/commit-graph.c | 4 ++-- commit-graph.c | 5 ++--- commit-graph.h | 4 ++-- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/builtin/commit-graph.c b/builtin/commit-graph.c index 25018a0b9d..145802afb7 100644 --- a/builtin/commit-graph.c +++ b/builtin/commit-graph.c @@ -241,9 +241,9 @@ static int graph_write(int argc, const char **argv, const char *prefix, N_("allow writing an incremental commit-graph file"), PARSE_OPT_OPTARG | PARSE_OPT_NONEG, write_option_parse_split), - OPT_INTEGER(0, "max-commits", &write_opts.max_commits, + OPT_UNSIGNED(0, "max-commits", &write_opts.max_commits, N_("maximum number of commits in a non-base split commit-graph")), - OPT_INTEGER(0, "size-multiple", &write_opts.size_multiple, + OPT_UNSIGNED(0, "size-multiple", &write_opts.size_multiple, N_("maximum ratio between two levels of a split commit-graph")), OPT_EXPIRY_DATE(0, "expire-time", &write_opts.expire_time, N_("only expire files older than a given date-time")), diff --git a/commit-graph.c b/commit-graph.c index 3fc1273ba5..ba04fe75db 100644 --- a/commit-graph.c +++ b/commit-graph.c @@ -2235,9 +2235,8 @@ static void split_graph_merge_strategy(struct write_commit_graph_context *ctx) uint32_t num_commits; enum commit_graph_split_flags flags = COMMIT_GRAPH_SPLIT_UNSPECIFIED; uint32_t i; - - int max_commits = 0; - int size_mult = 2; + size_t max_commits = 0; + size_t size_mult = 2; if (ctx->opts) { max_commits = ctx->opts->max_commits; diff --git a/commit-graph.h b/commit-graph.h index 78ab7b875b..b71cb55697 100644 --- a/commit-graph.h +++ b/commit-graph.h @@ -160,8 +160,8 @@ enum commit_graph_split_flags { }; struct commit_graph_opts { - int size_multiple; - int max_commits; + size_t size_multiple; + size_t max_commits; timestamp_t expire_time; enum commit_graph_split_flags split_flags; int max_new_filters; -- 2.51.0.rc0.215.g125493bb4a.dirty