Anytime you want to set a configuration per file extension, a good place to start is gitattributes
.
In a .gitattributes
files, you can set a directive per file, or per file extension.
However, the *.js -whitespace I mentioned in 2009 might not apply during a merge.
Since ignore-all-space
is first a git diff
option, you might need to set up a diff driver in a .gitattributes
(again, only for *.js
files), emulating --word-diff-regex
Use <regex>
to decide what a word is, instead of considering runs of non-whitespace to be a word
Every non-overlapping match of the 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.
For example (to be tweaked in order to match what you need in a javascript file for a diff without spaces)
*.js diff=js
[diff "js"]
wordRegex = "[^[:space:]]+"