Signed-off-by: Nguyễn Thái Ngọc Duy <pclo...@gmail.com>
---
 diff.c | 25 +++++++++++++++++++------
 1 file changed, 19 insertions(+), 6 deletions(-)

diff --git a/diff.c b/diff.c
index 78b5d93fa5..611b73d06a 100644
--- a/diff.c
+++ b/diff.c
@@ -5066,6 +5066,21 @@ static int diff_opt_relative(const struct option *opt,
        return 0;
 }
 
+static int diff_opt_textconv(const struct option *opt,
+                            const char *arg, int unset)
+{
+       struct diff_options *options = opt->value;
+
+       BUG_ON_OPT_ARG(arg);
+       if (unset) {
+               options->flags.allow_textconv = 0;
+       } else {
+               options->flags.allow_textconv = 1;
+               options->flags.textconv_set_via_cmdline = 1;
+       }
+       return 0;
+}
+
 static int diff_opt_unified(const struct option *opt,
                            const char *arg, int unset)
 {
@@ -5307,6 +5322,9 @@ static void prep_parse_options(struct diff_options 
*options)
                         N_("disable all output of the program")),
                OPT_BOOL(0, "ext-diff", &options->flags.allow_external,
                         N_("allow an external diff helper to be executed")),
+               OPT_CALLBACK_F(0, "textconv", options, NULL,
+                              N_("run external text conversion filters when 
comparing binary files"),
+                              PARSE_OPT_NOARG, diff_opt_textconv),
                { OPTION_CALLBACK, 0, "output", options, N_("<file>"),
                  N_("Output to a specific file"),
                  PARSE_OPT_NONEG, NULL, 0, diff_opt_output },
@@ -5356,12 +5374,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, "--textconv")) {
-               options->flags.allow_textconv = 1;
-               options->flags.textconv_set_via_cmdline = 1;
-       } else if (!strcmp(arg, "--no-textconv"))
-               options->flags.allow_textconv = 0;
-       else if (skip_to_optional_arg_default(arg, "--ignore-submodules", &arg, 
"all")) {
+       } else if (skip_to_optional_arg_default(arg, "--ignore-submodules", 
&arg, "all")) {
                options->flags.override_submodule_config = 1;
                handle_ignore_submodules_arg(options, arg);
        } else if (skip_to_optional_arg_default(arg, "--submodule", &arg, 
"log"))
-- 
2.20.0.482.g66447595a7

Reply via email to