Skip to content

Commit 285b2c9

Browse files
pks-tgitster
authored andcommitted
commit-graph: fix type for some write options
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c448978 commit 285b2c9

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

builtin/commit-graph.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,9 +242,9 @@ static int graph_write(int argc, const char **argv, const char *prefix,
242242
N_("allow writing an incremental commit-graph file"),
243243
PARSE_OPT_OPTARG | PARSE_OPT_NONEG,
244244
write_option_parse_split),
245-
OPT_INTEGER(0, "max-commits", &write_opts.max_commits,
245+
OPT_UNSIGNED(0, "max-commits", &write_opts.max_commits,
246246
N_("maximum number of commits in a non-base split commit-graph")),
247-
OPT_INTEGER(0, "size-multiple", &write_opts.size_multiple,
247+
OPT_UNSIGNED(0, "size-multiple", &write_opts.size_multiple,
248248
N_("maximum ratio between two levels of a split commit-graph")),
249249
OPT_EXPIRY_DATE(0, "expire-time", &write_opts.expire_time,
250250
N_("only expire files older than a given date-time")),

commit-graph.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2236,9 +2236,8 @@ static void split_graph_merge_strategy(struct write_commit_graph_context *ctx)
22362236
uint32_t num_commits;
22372237
enum commit_graph_split_flags flags = COMMIT_GRAPH_SPLIT_UNSPECIFIED;
22382238
uint32_t i;
2239-
2240-
int max_commits = 0;
2241-
int size_mult = 2;
2239+
unsigned max_commits = 0;
2240+
unsigned size_mult = 2;
22422241

22432242
if (ctx->opts) {
22442243
max_commits = ctx->opts->max_commits;

commit-graph.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,8 @@ enum commit_graph_split_flags {
160160
};
161161

162162
struct commit_graph_opts {
163-
int size_multiple;
164-
int max_commits;
163+
unsigned size_multiple;
164+
unsigned max_commits;
165165
timestamp_t expire_time;
166166
enum commit_graph_split_flags split_flags;
167167
int max_new_filters;

0 commit comments

Comments
 (0)