diff-parseopt: convert -s|--no-patch
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>
Thu, 21 Feb 2019 11:16:09 +0000 (18:16 +0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 21 Feb 2019 23:16:59 +0000 (15:16 -0800)
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
diff.c
diff --git a/diff.c b/diff.c
index 99047fb5fec8d0aa9f00658c45bc8f93edd3bac7..9c8f5336bc3ee04608b81000ccb9b1ec91b7762f 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -4906,6 +4906,9 @@ static void prep_parse_options(struct diff_options *options)
                OPT_BITOP('p', "patch", &options->output_format,
                          N_("generate patch"),
                          DIFF_FORMAT_PATCH, DIFF_FORMAT_NO_OUTPUT),
+               OPT_BIT_F('s', "no-patch", &options->output_format,
+                         N_("suppress diff output"),
+                         DIFF_FORMAT_NO_OUTPUT, PARSE_OPT_NONEG),
                OPT_BITOP('u', NULL, &options->output_format,
                          N_("generate patch"),
                          DIFF_FORMAT_PATCH, DIFF_FORMAT_NO_OUTPUT),
@@ -4983,9 +4986,7 @@ int diff_opt_parse(struct diff_options *options,
                return ac;
 
        /* Output format options */
-       if (!strcmp(arg, "-s") || !strcmp(arg, "--no-patch"))
-               options->output_format |= DIFF_FORMAT_NO_OUTPUT;
-       else if (starts_with(arg, "--stat"))
+       if (starts_with(arg, "--stat"))
                /* --stat, --stat-width, --stat-name-width, or --stat-count */
                return stat_opt(options, av);
        else if (!strcmp(arg, "--compact-summary")) {