Whitespace in .gitattributes patterns

回眸只為那壹抹淺笑 提交于 2019-12-22 04:59:53

问题


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?


回答1:


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:]]'


来源:https://stackoverflow.com/questions/18864698/whitespace-in-gitattributes-patterns

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!