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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Dmitry Gutov <dgutov@xxxxxxxxx> 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.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]