在逗号中也使用逗号作为单词分隔符 [英] Also use comma as a word separator in diff
本文介绍了在逗号中也使用逗号作为单词分隔符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何将,
添加为git diff --word-diff的字词分隔符?
实例我希望diff能够识别出:
函数(A,B,C) - >函数(A,B,C)
只添加空格而不是替换整行。 / p>
解决方案使用
- word-diff-regex
: --word-diff-regex =< regex>
使用< regex>来决定一个单词是什么,而不是考虑运行
非空白词作为单词。也意味着--word-diff,除非
已被启用。
< regex>的每个非重叠匹配被认为是一个词。
这些匹配之间的任何内容都被认为是空白,
被忽略(!)用于找出差异。您可能想要
在正则表达式中追加| [^ [:space:]]以确保
匹配所有非空白字符。包含
换行符的匹配在换行符处被无提示地截断(!)。
也可以通过diff驱动程序或配置
选项设置正则表达式,请参阅gitattributes(1)或git-config(1)。明确给出
将覆盖任何diff驱动程序或配置设置。比较驱动程序
覆盖配置设置。
我从来没有使用过它,但我猜测 git diff --word-diff -regex =[^ [:space:],] +
可能有用。
How can I add ,
as a word separator for git diff --word-diff?
For instance I would like the diff to recognize that
function(A,B,C) -> function(A, B, C)
only has added the spaces instead of replacing the whole line.
解决方案
Use --word-diff-regex
:
--word-diff-regex=<regex>
Use <regex> to decide what a word is, instead of considering runs
of non-whitespace to be a word. Also implies --word-diff unless it
was already enabled.
Every non-overlapping match of the <regex> is considered a word.
Anything between these matches is considered whitespace and
ignored(!) for the purposes of finding differences. You may want to
append |[^[:space:]] to your regular expression to make sure that
it matches all non-whitespace characters. A match that contains a
newline is silently truncated(!) at the newline.
The regex can also be set via a diff driver or configuration
option, see gitattributes(1) or git-config(1). Giving it explicitly
overrides any diff driver or configuration setting. Diff drivers
override configuration settings.
I never used it but i guess that git diff --word-diff-regex="[^[:space:],]+"
may work.
这篇关于在逗号中也使用逗号作为单词分隔符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文