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

Re: 'git diff-index' doesn't honor the 'diff.algorithm' variable

From
Junio C Hamano <gitster@pobox.com>
Date
May 14, 2016, 18:40 UTC
Message-ID
<xmqqshxk7aa8.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<9d15b6c8-ed97-7352-3df1-efab1b4ffadb@yandex.ru>
Dmitry Gutov <dgutov@yandex.ru> writes:
Show 8 quoted lines
> Hi all,
>
> Subj. ...even though it's explicitly mentioned in the subcommand's man
> page. Git version 2.7.4 here.
>
> To elaborate:
>
> - Call 'git config --global diff.algorithm histogram'.

The variable belongs to UI config, meant for Porcelain "git diff", together with things like "diff.color", "diff.context", etc.

As the point of lower-level plumbing commands in the diff family, i.e. diff-files, diff-index and diff-tree, are about giving stable output, which are _not_ affected by random end-user configuration, for scripted use, it is very much deliberate design decision that they ignore the UI config variables.

A script that calls diff-index, if it wants to honor end-users' UI config variables, is allowed to use 'git config' to read them and turn them into appropriate command line options. e.g.

    algo=$(git config diff.algorithm)
    case "$algo" in
    minimal|histogram|patience) algo=--$algo ;;
    *) algo= ;;
    esac
    ...
    git diff-index $algo ... other args ...
or something like that.
Previous: Dmitry GutovNext: Dmitry Gutov
Message 2 of 5 in “'git diff-index' doesn't honor the 'diff.algorithm' variable”
  1. Dmitry GutovMay 13, 2016
  2. Junio C HamanoMay 14, 2016
  3. Dmitry GutovMay 15, 2016
  4. Junio C HamanoMay 15, 2016
  5. Dmitry GutovMay 15, 2016

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.