Также используйте запятую как разделитель слов в diff
Как добавить , в качестве разделителя слов для git diff -word-diff?
Например, я хотел бы, чтобы diff распознал, что
function(A,B,C) -> function(A, B, C)
только добавляет пробелы вместо замены всей строки.
Ответ 1
Используйте --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.
Я никогда не использовал его, но думаю, что git diff --word-diff-regex="[^[:space:],]+" может работать.
Ответ 2
В дополнение к ответу KurzedMetal: без кавычек он работает еще лучше, так как он не нарушает автозаполнение bashs при нажатии TAB.
git diff --word-diff-regex=[^[:space:],]+
Ответ 3
Вы также можете попробовать -w/--ignore-all-space, хотя это может игнорировать больше пробелов, чем вам нравится.