diff-parseopt: convert --exit-code
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>
Tue, 5 Mar 2019 12:30:21 +0000 (19:30 +0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 6 Mar 2019 23:02:22 +0000 (08:02 +0900)
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 5180c2f5a96d977ea5250794e4201a252545201d..3f80e06de58c55c2a1cd8b1ed8a5d2b999695180 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -5297,6 +5297,8 @@ static void prep_parse_options(struct diff_options *options)
                         N_("treat all files as text")),
                OPT_BOOL('R', NULL, &options->flags.reverse_diff,
                         N_("swap two inputs, reverse the diff")),
+               OPT_BOOL(0, "exit-code", &options->flags.exit_with_status,
+                        N_("exit with 1 if there were differences, 0 otherwise")),
                { OPTION_CALLBACK, 0, "output", options, N_("<file>"),
                  N_("Output to a specific file"),
                  PARSE_OPT_NONEG, NULL, 0, diff_opt_output },
@@ -5346,9 +5348,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 (!strcmp(arg, "--exit-code"))
-               options->flags.exit_with_status = 1;
-       else if (!strcmp(arg, "--quiet"))
+       } else if (!strcmp(arg, "--quiet"))
                options->flags.quick = 1;
        else if (!strcmp(arg, "--ext-diff"))
                options->flags.allow_external = 1;