All of lore.kernel.org
 help / color / mirror / 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 13/20] diff-parseopt: convert --word-diff-regex
Date: Tue,  5 Mar 2019 19:30:19 +0700	[thread overview]
Message-ID: <20190305123026.7266-14-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 | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/diff.c b/diff.c
index 14c057f3df..634981723b 100644
--- a/diff.c
+++ b/diff.c
@@ -5092,6 +5092,18 @@ static int diff_opt_word_diff(const struct option *opt,
 	return 0;
 }
 
+static int diff_opt_word_diff_regex(const struct option *opt,
+				    const char *arg, int unset)
+{
+	struct diff_options *options = opt->value;
+
+	BUG_ON_OPT_NEG(unset);
+	if (options->word_diff == DIFF_WORDS_NONE)
+		options->word_diff = DIFF_WORDS_PLAIN;
+	options->word_regex = arg;
+	return 0;
+}
+
 static void prep_parse_options(struct diff_options *options)
 {
 	struct option parseopts[] = {
@@ -5257,6 +5269,9 @@ static void prep_parse_options(struct diff_options *options)
 		OPT_CALLBACK_F(0, "word-diff", options, N_("<mode>"),
 			       N_("show word diff, using <mode> to delimit changed words"),
 			       PARSE_OPT_NONEG | PARSE_OPT_OPTARG, diff_opt_word_diff),
+		OPT_CALLBACK_F(0, "word-diff-regex", options, N_("<regex>"),
+			       N_("use <regex> to decide what a word is"),
+			       PARSE_OPT_NONEG, diff_opt_word_diff_regex),
 
 		OPT_GROUP(N_("Diff other options")),
 		OPT_CALLBACK_F(0, "relative", options, N_("<prefix>"),
@@ -5320,12 +5335,6 @@ int diff_opt_parse(struct diff_options *options,
 		options->use_color = 1;
 		options->word_diff = DIFF_WORDS_COLOR;
 	}
-	else if ((argcount = parse_long_opt("word-diff-regex", av, &optarg))) {
-		if (options->word_diff == DIFF_WORDS_NONE)
-			options->word_diff = DIFF_WORDS_PLAIN;
-		options->word_regex = optarg;
-		return argcount;
-	}
 	else if (!strcmp(arg, "--exit-code"))
 		options->flags.exit_with_status = 1;
 	else if (!strcmp(arg, "--quiet"))
-- 
2.21.0.rc1.337.gdf7f8d0522


  parent reply	other threads:[~2019-03-05 12:31 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 ` Nguyễn Thái Ngọc Duy [this message]
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 ` [PATCH 18/20] diff-parseopt: convert --textconv Nguyễn Thái Ngọc Duy
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

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

  git send-email \
    --in-reply-to=20190305123026.7266-14-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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.