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

Re: [PATCH] diff: Introduce diff.algorithm variable

From
Tay Ray Chuan <rctay89@gmail.com>
Date
Mar 13, 2012, 14:42 UTC
Message-ID
<CALUzUxpR_bPLvnHRJrQ2wVpqJD6Ccg6r3RMa_sCDKHTapnJsdw@mail.gmail.com>
In-Reply-To
<06652d553040ad6b25608dc69d632f1ee38eaeca.1331300343.git.mprivozn@redhat.com>
On Fri, Mar 9, 2012 at 9:48 PM, Michal Privoznik <mprivozn@redhat.com> wrote:
Show 50 quoted lines
> Some users have preference over various diff algorithms. However,
> now they are forced to use appropriate argument every time they
> run git-diff and tools using it. This is impractical. Therefore
> create new variable which can set preferred algorithm. Of course,
> this can be overridden on command line via --diff-algorithm=*.
> Accepted values are myers (default), histogram, minimal, patience.
>
> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
> ---
> This is basically v2 for:
>
>   http://www.spinics.net/lists/git/msg176100.html
>
> As we agreed on list, I've switched from diff.patience to
> diff.algorithm and created new argument --diff-algorithm.
>
> Please keep me CC'ed as I am not signed into the list.
>
>  Documentation/diff-config.txt          |   21 +++++++++++++++++++
>  Documentation/diff-options.txt         |   23 +++++++++++++++++++++
>  contrib/completion/git-completion.bash |   13 +++++++++++
>  diff.c                                 |   35 ++++++++++++++++++++++++++++++++
>  4 files changed, 92 insertions(+), 0 deletions(-)
>
> diff --git a/Documentation/diff-config.txt b/Documentation/diff-config.txt
> index 6aa1be0..1047e81 100644
> --- a/Documentation/diff-config.txt
> +++ b/Documentation/diff-config.txt
> @@ -1,3 +1,24 @@
> +diff.algorithm::
> +    Choose a diff algorithm.  The variants are as follows:
> ++
> +--
> +histogram::
> +    This is the fastest algorithm.
> +
> +myers::
> +    The classical Myers diff algorithm. This is the default.
> +
> +minimal::
> +    Like 'myers', but spend extra time making sure that the diff
> +    is the shortest possible for the set of changes performed.
> +
> +patience::
> +    The patience diff algorithm, which first matches unique lines
> +    with each other.  This sometimes results in more readable (if
> +    longer) patches than the other algorithms.
> +--
> ++
> +

Considering that --minimal isn't really an algorithm, could this be instead made to a "default options to always pass to diff" config? I imagine this would make the codepath involved in this patch much simpler (just reuse the argc/argv opt parsing machinery).

Additionally, it would be useful for users who want to, say, set the context to 5 lines always.

-- 
Cheers,
Ray Chuan
Previous: Junio C HamanoNext: Junio C Hamano
Message 4 of 6 in “diff: Introduce diff.algorithm variable”
  1. diff: Introduce diff.algorithm variableMichal Privoznik, Mar 9, 2012
  2. Junio C HamanoMar 9, 2012
  3. Junio C HamanoMar 12, 2012
  4. Tay Ray ChuanMar 13, 2012
  5. Junio C HamanoMar 13, 2012
  6. Jeff KingMar 13, 2012

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.