diff-parseopt: convert --[no-]compact-summary
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
Feb 21, 2019 at 18:16 UTC
7d7942b79678904c7f07a2d5cbb76dd991926373
1 file changed
+19
-6
diff.c
+19
-6
@@ -4841,6 +4841,21 @@ static int parse_objfind_opt(struct diff_options *opt, const char *arg)
4841
return 1;
4842
}
4843
4844
+static int diff_opt_compact_summary(const struct option *opt,
4845
+ const char *arg, int unset)
4846
+{
4847
+ struct diff_options *options = opt->value;
4848
+
4849
+ BUG_ON_OPT_ARG(arg);
4850
+ if (unset) {
4851
+ options->flags.stat_with_summary = 0;
4852
+ } else {
4853
+ options->flags.stat_with_summary = 1;
4854
+ options->output_format |= DIFF_FORMAT_DIFFSTAT;
4855
+ }
4856
+ return 0;
4857
+}
4858
+
4859
static int diff_opt_dirstat(const struct option *opt,
4860
const char *arg, int unset)
4861
{
@@ -4947,6 +4962,9 @@ static void prep_parse_options(struct diff_options *options)
4962
OPT_CALLBACK_F(0, "stat-count", options, N_("<count>"),
4963
N_("generate diffstat with limited lines"),
4964
PARSE_OPT_NONEG, diff_opt_stat),
4965
+ OPT_CALLBACK_F(0, "compact-summary", options, NULL,
4966
+ N_("generate compact summary in diffstat"),
4967
+ PARSE_OPT_NOARG, diff_opt_compact_summary),
4968
OPT_END()
4969
};
4970
@@ -4975,12 +4993,7 @@ int diff_opt_parse(struct diff_options *options,
4993
return ac;
4994
4995
/* Output format options */
4978
- if (!strcmp(arg, "--compact-summary")) {
4979
- options->flags.stat_with_summary = 1;
4980
- options->output_format |= DIFF_FORMAT_DIFFSTAT;
4981
- } else if (!strcmp(arg, "--no-compact-summary"))
4982
- options->flags.stat_with_summary = 0;
4983
- else if (skip_prefix(arg, "--output-indicator-new=", &arg))
4996
+ if (skip_prefix(arg, "--output-indicator-new=", &arg))
4997
options->output_indicators[OUTPUT_INDICATOR_NEW] = arg[0];
4998
else if (skip_prefix(arg, "--output-indicator-old=", &arg))
4999
options->output_indicators[OUTPUT_INDICATOR_OLD] = arg[0];