Skip to content

Commit ce9baf2

Browse files
Denton-Lgitster
authored andcommitted
push: unset PARSE_OPT_OPTARG for --recurse-submodules
When the usage for `git push` is shown, it includes the following lines --recurse-submodules[=(check|on-demand|no)] control recursive pushing of submodules which seem to indicate that the argument for --recurse-submodules is optional. However, we cannot actually run that optiion without an argument: $ git push --recurse-submodules fatal: recurse-submodules missing parameter Unset PARSE_OPT_OPTARG so that it is clear that this option requires an argument. Since the parse-options machinery guarantees that an argument is present now, assume that `arg` is set in the else of option_parse_recurse_submodules(). Reported-by: Andrew White <[email protected]> Signed-off-by: Denton Liu <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent af6b65d commit ce9baf2

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

builtin/push.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -434,10 +434,8 @@ static int option_parse_recurse_submodules(const struct option *opt,
434434

435435
if (unset)
436436
*recurse_submodules = RECURSE_SUBMODULES_OFF;
437-
else if (arg)
438-
*recurse_submodules = parse_push_recurse_submodules_arg(opt->long_name, arg);
439437
else
440-
die("%s missing parameter", opt->long_name);
438+
*recurse_submodules = parse_push_recurse_submodules_arg(opt->long_name, arg);
441439

442440
return 0;
443441
}
@@ -552,9 +550,8 @@ int cmd_push(int argc, const char **argv, const char *prefix)
552550
0, CAS_OPT_NAME, &cas, N_("<refname>:<expect>"),
553551
N_("require old value of ref to be at this value"),
554552
PARSE_OPT_OPTARG | PARSE_OPT_LITERAL_ARGHELP, parseopt_push_cas_option },
555-
{ OPTION_CALLBACK, 0, "recurse-submodules", &recurse_submodules, "(check|on-demand|no)",
556-
N_("control recursive pushing of submodules"),
557-
PARSE_OPT_OPTARG, option_parse_recurse_submodules },
553+
OPT_CALLBACK(0, "recurse-submodules", &recurse_submodules, "(check|on-demand|no)",
554+
N_("control recursive pushing of submodules"), option_parse_recurse_submodules),
558555
OPT_BOOL_F( 0 , "thin", &thin, N_("use thin pack"), PARSE_OPT_NOCOMPLETE),
559556
OPT_STRING( 0 , "receive-pack", &receivepack, "receive-pack", N_("receive pack program")),
560557
OPT_STRING( 0 , "exec", &receivepack, "receive-pack", N_("receive pack program")),

0 commit comments

Comments
 (0)