Skip to content

Commit cc74afb

Browse files
szedergitster
authored andcommitted
multi-pack-index: simplify handling of unknown --options
Although parse_options() can handle unknown --options just fine, none of 'git multi-pack-index's subcommands rely on it, but do it on their own: they invoke parse_options() with the PARSE_OPT_KEEP_UNKNOWN flag, then check whether there are any unparsed arguments left, and print usage and quit if necessary. Drop that PARSE_OPT_KEEP_UNKNOWN flag to let parse_options() handle unknown options instead, which has the additional benefit that it prints not only the usage but an "error: unknown option `foo'" message as well. Do leave the unparsed arguments check to catch any unexpected non-option arguments, though, e.g. 'git multi-pack-index write foo'. Signed-off-by: SZEDER Gábor <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e4a4b31 commit cc74afb

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

builtin/multi-pack-index.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ static int cmd_multi_pack_index_write(int argc, const char **argv)
134134
opts.flags |= MIDX_PROGRESS;
135135
argc = parse_options(argc, argv, NULL,
136136
options, builtin_multi_pack_index_write_usage,
137-
PARSE_OPT_KEEP_UNKNOWN);
137+
0);
138138
if (argc)
139139
usage_with_options(builtin_multi_pack_index_write_usage,
140140
options);
@@ -176,7 +176,7 @@ static int cmd_multi_pack_index_verify(int argc, const char **argv)
176176
opts.flags |= MIDX_PROGRESS;
177177
argc = parse_options(argc, argv, NULL,
178178
options, builtin_multi_pack_index_verify_usage,
179-
PARSE_OPT_KEEP_UNKNOWN);
179+
0);
180180
if (argc)
181181
usage_with_options(builtin_multi_pack_index_verify_usage,
182182
options);
@@ -202,7 +202,7 @@ static int cmd_multi_pack_index_expire(int argc, const char **argv)
202202
opts.flags |= MIDX_PROGRESS;
203203
argc = parse_options(argc, argv, NULL,
204204
options, builtin_multi_pack_index_expire_usage,
205-
PARSE_OPT_KEEP_UNKNOWN);
205+
0);
206206
if (argc)
207207
usage_with_options(builtin_multi_pack_index_expire_usage,
208208
options);
@@ -232,7 +232,7 @@ static int cmd_multi_pack_index_repack(int argc, const char **argv)
232232
argc = parse_options(argc, argv, NULL,
233233
options,
234234
builtin_multi_pack_index_repack_usage,
235-
PARSE_OPT_KEEP_UNKNOWN);
235+
0);
236236
if (argc)
237237
usage_with_options(builtin_multi_pack_index_repack_usage,
238238
options);

0 commit comments

Comments
 (0)