Skip to content

Commit 5931b6b

Browse files
committed
Merge branch 'jk/doc-backslash-in-exclude'
The patterns used in the .gitignore files use backslash in the way documented for fnmatch(3); document as such to reduce confusion. * jk/doc-backslash-in-exclude: doc: document backslash in gitignore patterns
2 parents 377e8e2 + 8a6d158 commit 5931b6b

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

Documentation/gitignore.adoc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,11 @@ PATTERN FORMAT
111111
one of the characters in a range. See fnmatch(3) and the
112112
FNM_PATHNAME flag for a more detailed description.
113113
114+
- A backslash ("`\`") can be used to escape any character. E.g., "`\*`"
115+
matches a literal asterisk (and "`\a`" matches "`a`", even though
116+
there is no need for escaping there). As with fnmatch(3), a backslash
117+
at the end of a pattern is an invalid pattern that never matches.
118+
114119
Two consecutive asterisks ("`**`") in patterns matched against
115120
full pathname may have special meaning:
116121

t/t3070-wildmatch.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,8 @@ match 1 1 1 1 aaaaaaabababab '*ab'
235235
match 1 1 1 1 'foo*' 'foo\*'
236236
match 0 0 0 0 foobar 'foo\*bar'
237237
match 1 1 1 1 'f\oo' 'f\\oo'
238+
match 0 0 0 0 \
239+
1 1 1 1 'foo\' 'foo\'
238240
match 1 1 1 1 ball '*[al]?'
239241
match 0 0 0 0 ten '[ten]'
240242
match 1 1 1 1 ten '**[!te]'

0 commit comments

Comments
 (0)