Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何为*.tex文件自动使用git diff--word diff选项,而不是其他文件?_Git_Latex_Git Diff - Fatal编程技术网

如何为*.tex文件自动使用git diff--word diff选项,而不是其他文件?

如何为*.tex文件自动使用git diff--word diff选项,而不是其他文件?,git,latex,git-diff,Git,Latex,Git Diff,有没有办法对LaTeX文件(*.tex)使用--word diff,并保持其他文件类型的标准行差异 我想要实现的是使用git diff命令,让git在*.tex文件上自动显示单词差异,而无需每次写入git diff--word diff。同时,我希望git显示其他文件类型的标准行差异。这可能吗?请参阅。但是,要仅为*.tex文件自动获取word差异,您必须将其与附加信息放在一起以及其他一些文档中 另外,至少在我当前的git版本(2.7.4)中,tex文件的内置正则表达式被破坏: (此正则表达式直

有没有办法对LaTeX文件(*.tex)使用
--word diff
,并保持其他文件类型的标准行差异

我想要实现的是使用
git diff
命令,让git在*.tex文件上自动显示单词差异,而无需每次写入
git diff--word diff
。同时,我希望git显示其他文件类型的标准行差异。这可能吗?

请参阅。但是,要仅为
*.tex
文件自动获取word差异,您必须将其与附加信息放在一起以及其他一些文档中

另外,至少在我当前的git版本(2.7.4)中,tex文件的内置正则表达式被破坏:

(此正则表达式直接来自gitattributes文档),再加上一个配置项和一个驱动程序:

$ git config --get diff.tex.command
git-word-diff-driver
$ cat ~/scripts/git-word-diff-driver
#! /bin/sh
#
# args are:
# path old-file old-hex old-mode new-file new-hex new-mode
git diff --word-diff $2 $5
exit 0
(此脚本可能会有所改进,但它显示了总体思路。
exit 0
是必需的,因为如果文件不同,正如它们倾向于的那样,
git diff
有一个非零出口。幸运的是,没有必要防止无休止的递归,因为
git diff--word diff path1 path2
不会重新调用gitattributes驱动程序。)

$ cat .gitattributes
*.tex   diff=tex
$ git config --get diff.tex.wordregex
\\[a-zA-Z]+|[{}]|\\.|[^\{}[:space:]]+
$ git config --get diff.tex.command
git-word-diff-driver
$ cat ~/scripts/git-word-diff-driver
#! /bin/sh
#
# args are:
# path old-file old-hex old-mode new-file new-hex new-mode
git diff --word-diff $2 $5
exit 0