Skip to content

Commit 836c8ce

Browse files
peffgitster
authored andcommitted
builtins: always pass prefix to parse_options()
Our builtins receive a "prefix" argument as part of their cmd_foo() function. We should always pass this to parse_options() if we're calling it, as it may be used for OPT_FILENAME() options. In the cases here, there's no option that would use it, so we're not fixing any bug. This is just future-proofing and setting a good example (plus quelling some -Wunused-parameter warnings). Note in the case of revert/cherry-pick, that we plumb the prefix through to run_sequencer(), as those builtins are just thin wrappers around it. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 9dc607f commit 836c8ce

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

builtin/mktag.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ int cmd_mktag(int argc, const char **argv, const char *prefix)
8181
int tagged_type;
8282
struct object_id result;
8383

84-
argc = parse_options(argc, argv, NULL,
84+
argc = parse_options(argc, argv, prefix,
8585
builtin_mktag_options,
8686
builtin_mktag_usage, 0);
8787

builtin/revert.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ static void verify_opt_compatible(const char *me, const char *base_opt, ...)
9494
die(_("%s: %s cannot be used with %s"), me, this_opt, base_opt);
9595
}
9696

97-
static int run_sequencer(int argc, const char **argv, struct replay_opts *opts)
97+
static int run_sequencer(int argc, const char **argv, const char *prefix,
98+
struct replay_opts *opts)
9899
{
99100
const char * const * usage_str = revert_or_cherry_pick_usage(opts);
100101
const char *me = action_name(opts);
@@ -141,7 +142,7 @@ static int run_sequencer(int argc, const char **argv, struct replay_opts *opts)
141142
options = parse_options_concat(options, cp_extra);
142143
}
143144

144-
argc = parse_options(argc, argv, NULL, options, usage_str,
145+
argc = parse_options(argc, argv, prefix, options, usage_str,
145146
PARSE_OPT_KEEP_ARGV0 |
146147
PARSE_OPT_KEEP_UNKNOWN_OPT);
147148

@@ -246,7 +247,7 @@ int cmd_revert(int argc, const char **argv, const char *prefix)
246247

247248
opts.action = REPLAY_REVERT;
248249
sequencer_init_config(&opts);
249-
res = run_sequencer(argc, argv, &opts);
250+
res = run_sequencer(argc, argv, prefix, &opts);
250251
if (res < 0)
251252
die(_("revert failed"));
252253
replay_opts_release(&opts);
@@ -260,7 +261,7 @@ int cmd_cherry_pick(int argc, const char **argv, const char *prefix)
260261

261262
opts.action = REPLAY_PICK;
262263
sequencer_init_config(&opts);
263-
res = run_sequencer(argc, argv, &opts);
264+
res = run_sequencer(argc, argv, prefix, &opts);
264265
if (res < 0)
265266
die(_("cherry-pick failed"));
266267
replay_opts_release(&opts);

0 commit comments

Comments
 (0)