Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Whitespace in .gitattributes patterns

I am writing some tools for git that make use of smudge/clean filters, and so I must create entries in the .gitattributes file.

Unfortunately, that file is parsed rather simply by splitting on whitespace, and so it is does not seem possible to me to include an explicit space character in the pattern.

I have been replacing whitespace characters with ?, which matches again zero or one characters.

Ergo, a pattern of has?spaces will match against my target filename of has spaces, but also hasspaces.

Is there a way to only match spaces, or am I stuck with the near-match?

like image 689
Mike Boers Avatar asked Sep 18 '13 05:09

Mike Boers


1 Answers

You can try, as part of your pattern:

[[:space:]]
# as in
has[[:space:]]spaces

The gitattributes man page does mention an example with it.
And the pattern tests also include several examples:

match 1 x ' ' '[[:digit:][:upper:][:space:]]'
like image 154
VonC Avatar answered Oct 02 '22 04:10

VonC