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.