Re: [PATCH v2 2/3] config: Introduce diff.algorithm variable
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jan 14, 2013, 21:05 UTC
- Message-ID
- <7v38y3a31k.fsf@alter.siamese.dyndns.org>
- In-Reply-To
- <f76708fc2a1dc33f3f9c67688ef5709302b56cbb.1358193364.git.mprivozn@redhat.com>
Michal Privoznik <mprivozn@redhat.com> writes:
> +static long parse_algorithm_value(const char *value)
> +{
> + if (!value || !strcasecmp(value, "myers"))
> + return 0;[diff] algorithm
should probably error out. Also it is rather unusual to parse the keyword values case insensitively.
Show 35 quoted lines
> + else if (!strcasecmp(value, "minimal"))
> + return XDF_NEED_MINIMAL;
> + else if (!strcasecmp(value, "patience"))
> + return XDF_PATIENCE_DIFF;
> + else if (!strcasecmp(value, "histogram"))
> + return XDF_HISTOGRAM_DIFF;
> + else
> + return -1;
> +}
> +
> /*
> * These are to give UI layer defaults.
> * The core-level commands such as git-diff-files should
> @@ -196,6 +211,13 @@ int git_diff_ui_config(const char *var, const char *value, void *cb)
> return 0;
> }
>
> + if (!strcmp(var, "diff.algorithm")) {
> + diff_algorithm = parse_algorithm_value(value);
> + if (diff_algorithm < 0)
> + return -1;
> + return 0;
> + }
> +
> if (git_color_config(var, value, cb) < 0)
> return -1;
>
> @@ -3213,6 +3235,7 @@ void diff_setup(struct diff_options *options)
> options->add_remove = diff_addremove;
> options->use_color = diff_use_color_default;
> options->detect_rename = diff_detect_rename_default;
> + options->xdl_opts |= diff_algorithm;
>
> if (diff_no_prefix) {
> options->a_prefix = options->b_prefix = "";