diff-parseopt: convert --ignore-submodules

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Nguyễn Thái Ngọc Duy committed Mar 5, 2019 at 19:30 UTC b680ee1495fb55e2a4236456971b3d427989eb55
1 file changed +17 -3
diff.c
+17 -3
@@ -5013,6 +5013,19 @@ static int diff_opt_follow(const struct option *opt,
5013 return 0;
5014 }
5015
5016 +static int diff_opt_ignore_submodules(const struct option *opt,
5017 + const char *arg, int unset)
5018 +{
5019 + struct diff_options *options = opt->value;
5020 +
5021 + BUG_ON_OPT_NEG(unset);
5022 + if (!arg)
5023 + arg = "all";
5024 + options->flags.override_submodule_config = 1;
5025 + handle_ignore_submodules_arg(options, arg);
5026 + return 0;
5027 +}
5028 +
5029 static enum parse_opt_result diff_opt_output(struct parse_opt_ctx_t *ctx,
5030 const struct option *opt,
5031 const char *arg, int unset)
@@ -5321,6 +5334,10 @@ static void prep_parse_options(struct diff_options *options)
5334 OPT_CALLBACK_F(0, "textconv", options, NULL,
5335 N_("run external text conversion filters when comparing binary files"),
5336 PARSE_OPT_NOARG, diff_opt_textconv),
5337 + OPT_CALLBACK_F(0, "ignore-submodules", options, N_("<when>"),
5338 + N_("ignore changes to submodules in the diff generation"),
5339 + PARSE_OPT_NONEG | PARSE_OPT_OPTARG,
5340 + diff_opt_ignore_submodules),
5341 { OPTION_CALLBACK, 0, "output", options, N_("<file>"),
5342 N_("Output to a specific file"),
5343 PARSE_OPT_NONEG, NULL, 0, diff_opt_output },
@@ -5370,9 +5387,6 @@ int diff_opt_parse(struct diff_options *options,
5387 if (cm & COLOR_MOVED_WS_ERROR)
5388 return -1;
5389 options->color_moved_ws_handling = cm;
5373 - } else if (skip_to_optional_arg_default(arg, "--ignore-submodules", &arg, "all")) {
5374 - options->flags.override_submodule_config = 1;
5375 - handle_ignore_submodules_arg(options, arg);
5390 } else if (skip_to_optional_arg_default(arg, "--submodule", &arg, "log"))
5391 return parse_submodule_opt(options, arg);
5392 else if (skip_prefix(arg, "--ws-error-highlight=", &arg))