我想git diff
输出我所有文件的规则差异,除了* .tex。对于* .tex文件,我希望看到git diff --word-diff
的输出。使用git的文字差异胶乳文件
我当时玩的是.gitattributes
和.gitconfig
,但我得到的最远的部分是获得一个.tex文件的部分显示,然后是崩溃。
是否有可能得到此行为?
我.gitattributes
:
*.tex diff=latex
.gitconfig
:
[diff "latex"]
wordRegex = "\\\\[a-zA-Z]+|[{}]|\\\\.|[^\\{}[:space:]]+"
command = ~/bin/word-diff.sh
和word-diff.sh
:
#!/bin/sh
git --no-pager diff --color-words "$2" "$5"
你是怎么想出“$ 2”和“5 $”?我无法在任何地方找到相关信息。 – silvenon
找到了,对不起。对于想知道的其他人,请在[git手册页](http://git-scm.com/docs/git)中搜索GIT_EXTERNAL_DIFF。 – silvenon
作为一个方面的评论,有[应该](http://git-scm.com/docs/gitattributes/1.9.0#_defining_a_custom_hunk_header)一个内置的差异模式“tex”可用,应该给你合理的大块-headers。但这似乎并不适用于我。 –