Есть имя для шаблона поиска gitignore - PullRequest
0 голосов
/ 17 мая 2019

.gitignore строки имеют свои особые правила интерпретации.

https://linux.die.net/man/5/gitignore

• A blank line matches no files, so it can serve as a separator for readability. 
• A line starting with # serves as a comment. 
• An optional prefix ! which negates the pattern; any matching file excluded by a previous pattern will become included again. If a negated pattern matches, this will override lower precedence patterns sources. 
• If the pattern ends with a slash, it is removed for the purpose of the following description, but it would only find a match with a directory. In other words, foo/ will match a directory foo and paths underneath it, but will not match a regular file or a symbolic link foo (this is consistent with the way how pathspec works in general in git). 
• If the pattern does not contain a slash /, git treats it as a shell glob pattern and checks for a match against the pathname without leading directories. 
• Otherwise, git treats the pattern as a shell glob suitable for consumption by fnmatch(3) with the FNM_PATHNAME flag: wildcards in the pattern will not match a / in the pathname. For example, "Documentation/*.html" matches "Documentation/git.html" but not "Documentation/ppc/ppc.html". A leading slash matches the beginning of the pathname; for example, "/*.c" matches "cat-file.c" but not "mozilla-sha1/sha1.c". 

Те же правила используются и другими инструментами, например, ключ files в npm's package.json ожидает тот же формат.

Есть ли название для этого шаблона? Или какое имя будет наиболее подходящим?

1 Ответ

2 голосов
/ 17 мая 2019

Другая официальная документация этих правил находится в git-scm документах.

Я думаю, что самое близкое, на что .gitignore похожа, это glob сопоставление с образцом , которое они упоминают в некоторых документах:

Если шаблон не содержит косую черту /, git обрабатывает его как шаблон глобуса оболочки и проверяет совпадение с именем пути без ведущих каталогов.

Однако, это не совсем то же самое, поэтому они определяют правила.

...