git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
To: git@vger.kernel.org
Cc: "Junio C Hamano" <gitster@pobox.com>,
	"Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: [PATCH 18/20] diff-parseopt: convert --textconv
Date: Tue,  5 Mar 2019 19:30:24 +0700	[thread overview]
Message-ID: <20190305123026.7266-19-pclouds@gmail.com> (raw)
In-Reply-To: <20190305123026.7266-1-pclouds@gmail.com>

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

diff --git a/diff.c b/diff.c
index b460fa010b..a27bca527d 100644
--- a/diff.c
+++ b/diff.c
@@ -5062,6 +5062,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)
 {
@@ -5303,6 +5318,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 },
@@ -5352,12 +5370,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.21.0.rc1.337.gdf7f8d0522


  parent reply	other threads:[~2019-03-05 12:32 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-05 12:30 [PATCH 00/20] nd/diff-parseopt part 3 Nguyễn Thái Ngọc Duy
2019-03-05 12:30 ` [PATCH 01/20] diff-parseopt: convert --[no-]indent-heuristic Nguyễn Thái Ngọc Duy
2019-03-05 12:30 ` [PATCH 02/20] diff-parseopt: convert --patience Nguyễn Thái Ngọc Duy
2019-03-05 12:30 ` [PATCH 03/20] diff-parseopt: convert --histogram Nguyễn Thái Ngọc Duy
2019-03-05 12:30 ` [PATCH 04/20] diff-parseopt: convert --diff-algorithm Nguyễn Thái Ngọc Duy
2019-03-05 12:30 ` [PATCH 05/20] diff-parseopt: convert --anchored Nguyễn Thái Ngọc Duy
2019-03-05 12:30 ` [PATCH 06/20] diff-parseopt: convert --binary Nguyễn Thái Ngọc Duy
2019-03-05 12:30 ` [PATCH 07/20] diff-parseopt: convert --full-index Nguyễn Thái Ngọc Duy
2019-03-05 12:30 ` [PATCH 08/20] diff-parseopt: convert -a|--text Nguyễn Thái Ngọc Duy
2019-03-05 12:30 ` [PATCH 09/20] diff-parseopt: convert -R Nguyễn Thái Ngọc Duy
2019-03-05 12:30 ` [PATCH 10/20] diff-parseopt: convert --[no-]follow Nguyễn Thái Ngọc Duy
2019-03-05 12:30 ` [PATCH 11/20] diff-parseopt: convert --[no-]color Nguyễn Thái Ngọc Duy
2019-03-05 12:30 ` [PATCH 12/20] diff-parseopt: convert --word-diff Nguyễn Thái Ngọc Duy
2019-03-05 12:30 ` [PATCH 13/20] diff-parseopt: convert --word-diff-regex Nguyễn Thái Ngọc Duy
2019-03-05 12:30 ` [PATCH 14/20] diff-parseopt: convert --color-words Nguyễn Thái Ngọc Duy
2019-03-05 12:30 ` [PATCH 15/20] diff-parseopt: convert --exit-code Nguyễn Thái Ngọc Duy
2019-03-05 12:30 ` [PATCH 16/20] diff-parseopt: convert --quiet Nguyễn Thái Ngọc Duy
2019-03-05 15:42   ` Eric Sunshine
2019-03-06  9:25     ` Duy Nguyen
2019-03-05 12:30 ` [PATCH 17/20] diff-parseopt: convert --ext-diff Nguyễn Thái Ngọc Duy
2019-03-05 12:30 ` Nguyễn Thái Ngọc Duy [this message]
2019-03-05 12:30 ` [PATCH 19/20] diff-parseopt: convert --ignore-submodules Nguyễn Thái Ngọc Duy
2019-03-05 12:30 ` [PATCH 20/20] diff-parseopt: convert --submodule Nguyễn Thái Ngọc Duy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190305123026.7266-19-pclouds@gmail.com \
    --to=pclouds@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).