我想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。但這似乎並不適用於我。 –