From: Junio C Hamano <gitster@pobox.com>
To: Michal Privoznik <mprivozn@redhat.com>
Cc: git@vger.kernel.org, peff@peff.net, trast@student.ethz.ch
Subject: Re: [PATCH v2 3/3] diff: Introduce --diff-algorithm command line option
Date: Mon, 14 Jan 2013 13:06:39 -0800 [thread overview]
Message-ID: <7vvcaz8of4.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: 1b9015bb45f2ece54dae7baee3cbcdc54b9c7ee9.1358193364.git.mprivozn@redhat.com
Michal Privoznik <mprivozn@redhat.com> writes:
> +--diff-algorithm={patience|minimal|histogram|myers}::
> + Choose a diff algorithm. The variants are as follows:
> ++
> +--
> +`myers`;;
> + The basic greedy diff algorithm.
> +`minimal`;;
> + Spend extra time to make sure the smallest possible diff is
> + produced.
> +`patience`;;
> + Use "patience diff" algorithm when generating patches.
> +`histogram`;;
> + This algorithm extends the patience algorithm to "support
> + low-occurrence common elements".
> +--
> ++
> +For instance, if you configured diff.algorithm variable to a
> +non-default value and want to use the default one, then you
> +have to use `--diff-algorithm=myers` option.
> +
> +You should prefer this option over the `--minimal`, `--patience` and
> +`--histogram` which are kept just for backwards compatibility.
Much better; I'd drop the last paragraph, though.
I also think we really should consider "default" synonym for
whichever happens to be the built-in default (currently myers).
> diff --git a/diff.c b/diff.c
> index e9a7e4d..3e021d5 100644
> --- a/diff.c
> +++ b/diff.c
> @@ -144,7 +144,7 @@ static int git_config_rename(const char *var, const char *value)
> return git_config_bool(var,value) ? DIFF_DETECT_RENAME : 0;
> }
>
> -static long parse_algorithm_value(const char *value)
> +long parse_algorithm_value(const char *value)
> {
> if (!value || !strcasecmp(value, "myers"))
> return 0;
> @@ -3633,6 +3633,16 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
> options->xdl_opts = DIFF_WITH_ALG(options, PATIENCE_DIFF);
> else if (!strcmp(arg, "--histogram"))
> options->xdl_opts = DIFF_WITH_ALG(options, HISTOGRAM_DIFF);
> + else if (!prefixcmp(arg, "--diff-algorithm=")) {
> + long value = parse_algorithm_value(arg+17);
> + 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;
This makes me wonder if other places that use DIFF_WITH_ALG() also
need to worry about clearing NEED_MINIMAL?
next prev parent reply other threads:[~2013-01-14 21:07 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-14 19:58 [PATCH v2 0/3] Rework git-diff algorithm selection Michal Privoznik
2013-01-14 19:58 ` [PATCH v2 1/3] git-completion.bash: Autocomplete --minimal and --histogram for git-diff Michal Privoznik
2013-01-14 19:58 ` [PATCH v2 2/3] config: Introduce diff.algorithm variable Michal Privoznik
2013-01-14 21:05 ` Junio C Hamano
2013-01-15 16:58 ` Jeff King
2013-01-15 17:09 ` Junio C Hamano
2013-01-14 19:58 ` [PATCH v2 3/3] diff: Introduce --diff-algorithm command line option Michal Privoznik
2013-01-14 21:06 ` Junio C Hamano [this message]
2013-01-15 10:07 ` Michal Privoznik
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=7vvcaz8of4.fsf@alter.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=mprivozn@redhat.com \
--cc=peff@peff.net \
--cc=trast@student.ethz.ch \
/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).