Git 的特殊文件扩展名的替代差异算法

Alternative diff algorithm for special file extension for Git

我想对特殊文件扩展名使用替代差异算法,例如“.java”和其他文件的标准差异算法。

我可以通过 .gitattributes 文件:

*.java diff=javadiffprogramm

.gitconfig 文件:

[diff "javadiffprogramm"]
    command = pathToDiffProgram.

我的问题是"javadiffprogramm"的输入参数格式是什么,diff的结果应该输出到哪里?diff的结果格式如“ @@ -1,7 +1,6 @@...".

关于这个主题的一些问题:

这在 the git man page 中记录为 GIT_EXTERNAL_DIFF

GIT_EXTERNAL_DIFF

When the environment variable GIT_EXTERNAL_DIFF is set, the program named by it is called, instead of the diff invocation described above. For a path that is added, removed, or modified, GIT_EXTERNAL_DIFF is called with 7 parameters:

path old-file old-hex old-mode new-file new-hex new-mode

文档继续解释这些参数是什么。

输出应该是 STDOUT。