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

2 messages, 2 authors, 2016-06-16 · open the first message on its own page

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

From: Junio C Hamano <hidden>
Date: 2016-06-16 02:19:23

Dmitry Gutov [off-list ref] writes:
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.

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

From: Dmitry Gutov <hidden>
Date: 2016-06-16 02:19:23

Hi Junio,

On 05/14/2016 09:40 PM, Junio C Hamano wrote:
The variable belongs to UI config, meant for Porcelain "git diff",
together with things like "diff.color", "diff.context", etc.
OK, that makes sense. You might want to fix the man page, though, it 
says, like the 'git diff' one, "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=default option.".
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.
Thanks, but we don't distribute any custom Git porcelains with Emacs. We 
usually can't rely on bash being available either. Doing an extra 
process call from Emacs for this niche a feature doesn't seem like a 
great idea either. To clarify, the problem is that `M-x vc-diff' doesn't 
honor the diff.algorithm option.

I'll have to see why we using 'git diff-index' there directly. Maybe we 
could switch to 'git diff'.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help