Skip to content

Commit

Permalink
diff-parseopt: convert --submodule
Browse files Browse the repository at this point in the history
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
pclouds authored and gitster committed Mar 6, 2019
1 parent b680ee1 commit 125dcea
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions diff.c
Expand Up @@ -4721,14 +4721,6 @@ static int parse_dirstat_opt(struct diff_options *options, const char *params)
return 1;
}

static int parse_submodule_opt(struct diff_options *options, const char *value)
{
if (parse_submodule_params(options, value))
die(_("Failed to parse --submodule option parameter: '%s'"),
value);
return 1;
}

static const char diff_status_letters[] = {
DIFF_STATUS_ADDED,
DIFF_STATUS_COPIED,
Expand Down Expand Up @@ -5075,6 +5067,20 @@ static int diff_opt_relative(const struct option *opt,
return 0;
}

static int diff_opt_submodule(const struct option *opt,
const char *arg, int unset)
{
struct diff_options *options = opt->value;

BUG_ON_OPT_NEG(unset);
if (!arg)
arg = "log";
if (parse_submodule_params(options, arg))
return error(_("failed to parse --submodule option parameter: '%s'"),
arg);
return 0;
}

static int diff_opt_textconv(const struct option *opt,
const char *arg, int unset)
{
Expand Down Expand Up @@ -5338,6 +5344,10 @@ static void prep_parse_options(struct diff_options *options)
N_("ignore changes to submodules in the diff generation"),
PARSE_OPT_NONEG | PARSE_OPT_OPTARG,
diff_opt_ignore_submodules),
OPT_CALLBACK_F(0, "submodule", options, N_("<format>"),
N_("specify how differences in submodules are shown"),
PARSE_OPT_NONEG | PARSE_OPT_OPTARG,
diff_opt_submodule),
{ OPTION_CALLBACK, 0, "output", options, N_("<file>"),
N_("Output to a specific file"),
PARSE_OPT_NONEG, NULL, 0, diff_opt_output },
Expand Down Expand Up @@ -5387,9 +5397,7 @@ int diff_opt_parse(struct diff_options *options,
if (cm & COLOR_MOVED_WS_ERROR)
return -1;
options->color_moved_ws_handling = cm;
} else if (skip_to_optional_arg_default(arg, "--submodule", &arg, "log"))
return parse_submodule_opt(options, arg);
else if (skip_prefix(arg, "--ws-error-highlight=", &arg))
} else if (skip_prefix(arg, "--ws-error-highlight=", &arg))
return parse_ws_error_highlight_opt(options, arg);
else if (!strcmp(arg, "--ita-invisible-in-index"))
options->ita_invisible_in_index = 1;
Expand Down

0 comments on commit 125dcea

Please sign in to comment.