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: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: [PATCH 40/76] diff.c: convert --diff-algorithm
Date: Thu, 17 Jan 2019 20:05:39 +0700	[thread overview]
Message-ID: <20190117130615.18732-41-pclouds@gmail.com> (raw)
In-Reply-To: <20190117130615.18732-1-pclouds@gmail.com>

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

diff --git a/diff.c b/diff.c
index ca3f448a8d..2b93f08958 100644
--- a/diff.c
+++ b/diff.c
@@ -4895,6 +4895,24 @@ static int diff_opt_compact_summary(const struct option *opt,
 	return 0;
 }
 
+static int diff_opt_diff_algorithm(const struct option *opt,
+				   const char *arg, int unset)
+{
+	struct diff_options *options = opt->value;
+	long value = parse_algorithm_value(arg);
+
+	BUG_ON_OPT_NEG(unset);
+	if (value < 0)
+		return error(_("option diff-algorithm accepts \"myers\", "
+			       "\"minimal\", \"patience\" and \"histogram\""));
+
+	/* clear out previous settings */
+	DIFF_XDL_CLR(options, NEED_MINIMAL);
+	options->xdl_opts &= ~XDF_DIFF_ALGORITHM_MASK;
+	options->xdl_opts |= value;
+	return 0;
+}
+
 static int diff_opt_dirstat(const struct option *opt,
 			    const char *arg, int unset)
 {
@@ -5158,6 +5176,9 @@ static void prep_parse_options(struct diff_options *options)
 		OPT_BITOP(0, "histogram", &options->xdl_opts,
 			  N_("generate diff using the \"histogram diff\" algorithm"),
 			  XDF_HISTOGRAM_DIFF, XDF_DIFF_ALGORITHM_MASK),
+		OPT_CALLBACK_F(0, "diff-algorithm", options, N_("<algorithm>"),
+			       N_("choose a diff algorithm"),
+			       PARSE_OPT_NONEG, diff_opt_diff_algorithm),
 
 		OPT_GROUP(N_("Diff other options")),
 		OPT_CALLBACK_F(0, "relative", options, N_("<prefix>"),
@@ -5196,17 +5217,7 @@ int diff_opt_parse(struct diff_options *options,
 		return ac;
 
 	/* xdiff options */
-	if ((argcount = parse_long_opt("diff-algorithm", av, &optarg))) {
-		long value = parse_algorithm_value(optarg);
-		if (value < 0)
-			return error("option diff-algorithm accepts \"myers\", "
-				     "\"minimal\", \"patience\" and \"histogram\"");
-		/* clear out previous settings */
-		DIFF_XDL_CLR(options, NEED_MINIMAL);
-		options->xdl_opts &= ~XDF_DIFF_ALGORITHM_MASK;
-		options->xdl_opts |= value;
-		return argcount;
-	} else if (skip_prefix(arg, "--anchored=", &arg)) {
+	if (skip_prefix(arg, "--anchored=", &arg)) {
 		options->xdl_opts = DIFF_WITH_ALG(options, PATIENCE_DIFF);
 		ALLOC_GROW(options->anchors, options->anchors_nr + 1,
 			   options->anchors_alloc);
-- 
2.20.0.482.g66447595a7


  parent reply	other threads:[~2019-01-17 13:09 UTC|newest]

Thread overview: 88+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-17 13:04 [PATCH 00/76] Convert diff opt parser to parse_options() Nguyễn Thái Ngọc Duy
2019-01-17 13:05 ` [PATCH 01/76] parse-options.h: remove extern on function prototypes Nguyễn Thái Ngọc Duy
2019-01-17 13:05 ` [PATCH 02/76] parse-options: add one-shot mode Nguyễn Thái Ngọc Duy
2019-01-17 13:05 ` [PATCH 03/76] parse-options: allow keep-unknown + stop-at-non-opt combination Nguyễn Thái Ngọc Duy
2019-01-17 18:33   ` Stefan Beller
2019-01-17 13:05 ` [PATCH 04/76] parse-options: disable option abbreviation with PARSE_OPT_KEEP_UNKNOWN Nguyễn Thái Ngọc Duy
2019-01-17 13:05 ` [PATCH 05/76] parse-options: add OPT_BITOP() Nguyễn Thái Ngọc Duy
2019-01-17 13:05 ` [PATCH 06/76] parse-options: stop abusing 'callback' for lowlevel callbacks Nguyễn Thái Ngọc Duy
2019-01-17 13:05 ` [PATCH 07/76] parse-options: avoid magic return codes Nguyễn Thái Ngọc Duy
2019-01-17 13:05 ` [PATCH 08/76] parse-options: allow ll_callback with OPTION_CALLBACK Nguyễn Thái Ngọc Duy
2019-01-17 13:05 ` [PATCH 09/76] diff.h: keep forward struct declarations sorted Nguyễn Thái Ngọc Duy
2019-01-17 13:05 ` [PATCH 10/76] diff.h: avoid bit fields in struct diff_flags Nguyễn Thái Ngọc Duy
2019-01-17 13:05 ` [PATCH 11/76] diff.c: prepare to use parse_options() for parsing Nguyễn Thái Ngọc Duy
2019-01-17 13:05 ` [PATCH 12/76] diff.c: convert -u|-p|--patch Nguyễn Thái Ngọc Duy
2019-01-17 13:05 ` [PATCH 13/76] diff.c: convert -U|--unified Nguyễn Thái Ngọc Duy
2019-01-17 13:05 ` [PATCH 14/76] diff.c: convert -W|--[no-]function-context Nguyễn Thái Ngọc Duy
2019-01-17 13:05 ` [PATCH 15/76] diff.c: convert --raw Nguyễn Thái Ngọc Duy
2019-01-17 13:05 ` [PATCH 16/76] diff.c: convert --patch-with-raw Nguyễn Thái Ngọc Duy
2019-01-17 13:05 ` [PATCH 17/76] diff.c: convert --numstat and --shortstat Nguyễn Thái Ngọc Duy
2019-01-17 13:05 ` [PATCH 18/76] diff.c: convert --dirstat and friends Nguyễn Thái Ngọc Duy
2019-01-17 13:05 ` [PATCH 19/76] diff.c: convert --check Nguyễn Thái Ngọc Duy
2019-01-17 13:05 ` [PATCH 20/76] diff.c: convert --summary Nguyễn Thái Ngọc Duy
2019-01-17 13:05 ` [PATCH 21/76] diff.c: convert --patch-with-stat Nguyễn Thái Ngọc Duy
2019-01-17 13:05 ` [PATCH 22/76] diff.c: convert --name-only Nguyễn Thái Ngọc Duy
2019-01-17 13:05 ` [PATCH 23/76] diff.c: convert --name-status Nguyễn Thái Ngọc Duy
2019-01-17 13:05 ` [PATCH 24/76] diff.c: convert -s|--no-patch Nguyễn Thái Ngọc Duy
2019-01-17 13:05 ` [PATCH 25/76] diff.c: convert --stat* Nguyễn Thái Ngọc Duy
2019-01-19  1:21   ` SZEDER Gábor
2019-01-17 13:05 ` [PATCH 26/76] diff.c: convert --[no-]compact-summary Nguyễn Thái Ngọc Duy
2019-01-17 13:05 ` [PATCH 27/76] diff.c: convert --output-* Nguyễn Thái Ngọc Duy
2019-01-17 13:05 ` [PATCH 28/76] diff.c: convert -B|--break-rewrites Nguyễn Thái Ngọc Duy
2019-01-21 12:07   ` Johannes Schindelin
2019-01-17 13:05 ` [PATCH 29/76] diff.c: convert -M|--find-renames Nguyễn Thái Ngọc Duy
2019-01-17 13:05 ` [PATCH 30/76] diff.c: convert -D|--irreversible-delete Nguyễn Thái Ngọc Duy
2019-01-17 13:05 ` [PATCH 31/76] diff.c: convert -C|--find-copies Nguyễn Thái Ngọc Duy
2019-01-17 13:05 ` [PATCH 32/76] diff.c: convert --find-copies-harder Nguyễn Thái Ngọc Duy
2019-01-17 13:05 ` [PATCH 33/76] diff.c: convert --no-renames|--[no--rename-empty Nguyễn Thái Ngọc Duy
2019-01-17 13:05 ` [PATCH 34/76] diff.c: convert --relative Nguyễn Thái Ngọc Duy
2019-01-17 13:05 ` [PATCH 35/76] diff.c: convert --[no-]minimal Nguyễn Thái Ngọc Duy
2019-01-17 13:05 ` [PATCH 36/76] diff.c: convert --ignore-some-changes Nguyễn Thái Ngọc Duy
2019-01-17 13:05 ` [PATCH 37/76] diff.c: convert --[no-]indent-heuristic Nguyễn Thái Ngọc Duy
2019-01-17 13:05 ` [PATCH 38/76] diff.c: convert --patience Nguyễn Thái Ngọc Duy
2019-01-17 13:05 ` [PATCH 39/76] diff.c: convert --histogram Nguyễn Thái Ngọc Duy
2019-01-17 13:05 ` Nguyễn Thái Ngọc Duy [this message]
2019-01-17 13:05 ` [PATCH 41/76] diff.c: convert --anchored Nguyễn Thái Ngọc Duy
2019-01-17 13:05 ` [PATCH 42/76] diff.c: convert --binary Nguyễn Thái Ngọc Duy
2019-01-17 13:05 ` [PATCH 43/76] diff.c: convert --full-index Nguyễn Thái Ngọc Duy
2019-01-17 13:05 ` [PATCH 44/76] diff.c: convert -a|--text Nguyễn Thái Ngọc Duy
2019-01-17 13:05 ` [PATCH 45/76] diff.c: convert -R Nguyễn Thái Ngọc Duy
2019-01-17 13:05 ` [PATCH 46/76] diff.c: convert --[no-]follow Nguyễn Thái Ngọc Duy
2019-01-17 13:05 ` [PATCH 47/76] diff.c: convert --[no-]color Nguyễn Thái Ngọc Duy
2019-01-17 13:05 ` [PATCH 48/76] diff.c: convert --word-diff Nguyễn Thái Ngọc Duy
2019-01-17 13:05 ` [PATCH 49/76] diff.c: convert --word-diff-regex Nguyễn Thái Ngọc Duy
2019-01-17 13:05 ` [PATCH 50/76] diff.c: convert --color-words Nguyễn Thái Ngọc Duy
2019-01-17 13:05 ` [PATCH 51/76] diff.c: convert --exit-code Nguyễn Thái Ngọc Duy
2019-01-17 13:05 ` [PATCH 52/76] diff.c: convert --quiet Nguyễn Thái Ngọc Duy
2019-01-17 13:05 ` [PATCH 53/76] diff.c: convert --ext-diff Nguyễn Thái Ngọc Duy
2019-01-17 13:05 ` [PATCH 54/76] diff.c: convert --textconv Nguyễn Thái Ngọc Duy
2019-01-17 13:05 ` [PATCH 55/76] diff.c: convert --ignore-submodules Nguyễn Thái Ngọc Duy
2019-01-17 13:05 ` [PATCH 56/76] diff.c: convert --submodule Nguyễn Thái Ngọc Duy
2019-01-17 13:05 ` [PATCH 57/76] diff.c: convert --ws-error-highlight Nguyễn Thái Ngọc Duy
2019-01-17 13:05 ` [PATCH 58/76] diff.c: convert --ita-[in]visible-in-index Nguyễn Thái Ngọc Duy
2019-01-17 13:05 ` [PATCH 59/76] diff.c: convert -z Nguyễn Thái Ngọc Duy
2019-01-17 13:05 ` [PATCH 60/76] diff.c: convert -l Nguyễn Thái Ngọc Duy
2019-01-17 13:06 ` [PATCH 61/76] diff.c: convert -S|-G Nguyễn Thái Ngọc Duy
2019-01-17 13:06 ` [PATCH 62/76] diff.c: convert --pickaxe-all|--pickaxe-regex Nguyễn Thái Ngọc Duy
2019-01-17 13:06 ` [PATCH 63/76] diff.c: convert -O Nguyễn Thái Ngọc Duy
2019-01-21 12:14   ` Johannes Schindelin
2019-01-17 13:06 ` [PATCH 64/76] diff.c: convert --find-object Nguyễn Thái Ngọc Duy
2019-01-17 13:06 ` [PATCH 65/76] diff.c: convert --diff-filter Nguyễn Thái Ngọc Duy
2019-01-17 13:06 ` [PATCH 66/76] diff.c: convert --[no-]abbrev Nguyễn Thái Ngọc Duy
2019-01-17 13:06 ` [PATCH 67/76] diff.c: convert --[src|dst]-prefix Nguyễn Thái Ngọc Duy
2019-01-17 13:06 ` [PATCH 68/76] diff.c: convert --line-prefix Nguyễn Thái Ngọc Duy
2019-01-17 13:06 ` [PATCH 69/76] diff.c: convert --no-prefix Nguyễn Thái Ngọc Duy
2019-01-17 13:06 ` [PATCH 70/76] diff.c: convert --inter-hunk-context Nguyễn Thái Ngọc Duy
2019-01-19  1:18   ` SZEDER Gábor
2019-01-17 13:06 ` [PATCH 71/76] diff.c: convert --color-moved Nguyễn Thái Ngọc Duy
2019-01-17 13:06 ` [PATCH 72/76] diff.c: convert --color-moved-ws Nguyễn Thái Ngọc Duy
2019-01-17 13:06 ` [PATCH 73/76] diff.c: allow --no-color-moved-ws Nguyễn Thái Ngọc Duy
2019-01-17 13:06 ` [PATCH 74/76] range-diff: use parse_options() instead of diff_opt_parse() Nguyễn Thái Ngọc Duy
2019-01-17 19:46   ` Stefan Beller
2019-01-18  9:30     ` Duy Nguyen
2019-01-17 13:06 ` [PATCH 75/76] diff --no-index: " Nguyễn Thái Ngọc Duy
2019-01-17 13:06 ` [PATCH 76/76] am: avoid diff_opt_parse() Nguyễn Thái Ngọc Duy
2019-01-17 20:10   ` Johannes Schindelin
2019-01-18  0:19     ` Duy Nguyen
2019-01-17 14:32 ` [PATCH 00/76] Convert diff opt parser to parse_options() Ævar Arnfjörð Bjarmason
2019-01-17 19:50   ` Stefan Beller

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=20190117130615.18732-41-pclouds@gmail.com \
    --to=pclouds@gmail.com \
    --cc=git@vger.kernel.org \
    /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).