git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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 = "";
Previous: Michal PrivoznikNext: Jeff King
Message 4 of 9 in “Rework git-diff algorithm selection”
  1. 0/3 Rework git-diff algorithm selectionMichal Privoznik, Jan 14, 2013
  2. 1/3 git-completion.bash: Autocomplete --minimal and --histogram for git-diffMichal Privoznik, Jan 14, 2013
  3. 2/3 config: Introduce diff.algorithm variableMichal Privoznik, Jan 14, 2013
  4. Junio C HamanoJan 14, 2013
  5. Jeff KingJan 15, 2013
  6. Junio C HamanoJan 15, 2013
  7. 3/3 diff: Introduce --diff-algorithm command line optionMichal Privoznik, Jan 14, 2013
  8. Junio C HamanoJan 14, 2013
  9. Michal PrivoznikJan 15, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.