From: Junio C Hamano <gitster@pobox.com>
To: git@vger.kernel.org
Cc: "Matt Hunter" <m@lfurio.us>, "Windl, Ulrich" <u.windl@ukr.de>
Subject: [PATCH v3] gitignore: rewrite wildcard description
Date: Sat, 28 Nov 2026 11:01:32 -0800 [thread overview]
Message-ID: <xmqqcxrowzjn.fsf_-_@gitster.g> (raw)
In-Reply-To: <xmqqh5hx4jz3.fsf_-_@gitster.g> (Junio C. Hamano's message of "Tue, 03 Nov 2026 14:40:32 -0800")
The documentation for '.gitignore' makes reference to fnmatch(3) and
FNM_PATHNAME to describe how an asterisk "*" and a question mark "?"
behave. Even though it spells out that these wildcard characters
do not match a slash, it does not say if an asterisk matches an
empty string (it does).
Rewrite the section so that the readers would get a more complete
picture without requiring them to know what fnmatch(3) and glob(7)
say.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
Changes since v2 are
- grammofix in log message, i.e., "what fnmatch(3) and glob(7) say"
(not "says").
- we forgot a few rules around bracketed character classes that we
relied on our reference to fnmatch(3) with FNM_PATHNAME to cover,
which we now need to supply ourselves.
- [bracketed list of characters] does not match a slash '/', even if
a slash or a range that includes a slash like ".-0" appears inside
brackets.
- The first character in [bracket] can be "^" or "!" to negate the
meaning of a match.
Documentation/gitignore.adoc | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/Documentation/gitignore.adoc b/Documentation/gitignore.adoc
index 7979e50f18..de010aa5db 100644
--- a/Documentation/gitignore.adoc
+++ b/Documentation/gitignore.adoc
@@ -110,11 +110,19 @@ PATTERN FORMAT
and `a/frotz` that is a directory (all paths are relative from
the `.gitignore` file).
- - An asterisk "`*`" matches anything except a slash.
- The character "`?`" matches any one character except "`/`".
- The range notation, e.g. `[a-zA-Z]`, can be used to match
- one of the characters in a range. See fnmatch(3) and the
- FNM_PATHNAME flag for a more detailed description.
+ - An asterisk "`*`" matches any string (including the empty string),
+ and a question mark "`?`" matches any single character, but these
+ wildcard characters do not match a slash "`/`".
+
+ - A pair of brackets that enclose characters matches any single
+ character from the listed characters, other than a slash "`/`". A
+ range notation inside them, e.g., "`[a-zA-Z]`", behaves as if all
+ the characters in the range were listed there instead, and a
+ leading "`!`" or "`^`" negates the match (still excluding "`/`").
+ Note that even a range that apparently includes a slash, like
+ "`[.-0]`" or "`[/]`", does not match a slash "`/`". Wildcard
+ characters "`*`" and "`?`" lose their special meaning inside a pair
+ of brackets, e.g., "`[*]`" matches an asterisk and nothing else.
- A backslash ("`\`") can be used to escape any character. E.g., "`\*`"
matches a literal asterisk (and "`\a`" matches "`a`", even though
Interdiff against v1:
diff --git a/Documentation/gitignore.adoc b/Documentation/gitignore.adoc
index 87f37c2b0c..de010aa5db 100644
--- a/Documentation/gitignore.adoc
+++ b/Documentation/gitignore.adoc
@@ -114,12 +114,15 @@ PATTERN FORMAT
and a question mark "`?`" matches any single character, but these
wildcard characters do not match a slash "`/`".
- - A pair of brackets that enclose characters match one of the listed
- characters, and a range notation inside them, e.g., "`[a-zA-Z]`",
- would behave as if all the characters in the range were listed there
- instead. Wildcard characters "`*`" and "`?`" lose their special
- meaning inside a pair of brackets, e.g., "`[*]`" would match an
- asterisk and nothing else.
+ - A pair of brackets that enclose characters matches any single
+ character from the listed characters, other than a slash "`/`". A
+ range notation inside them, e.g., "`[a-zA-Z]`", behaves as if all
+ the characters in the range were listed there instead, and a
+ leading "`!`" or "`^`" negates the match (still excluding "`/`").
+ Note that even a range that apparently includes a slash, like
+ "`[.-0]`" or "`[/]`", does not match a slash "`/`". Wildcard
+ characters "`*`" and "`?`" lose their special meaning inside a pair
+ of brackets, e.g., "`[*]`" matches an asterisk and nothing else.
- A backslash ("`\`") can be used to escape any character. E.g., "`\*`"
matches a literal asterisk (and "`\a`" matches "`a`", even though
--
2.56.1-817-g003c1d851b
next prev parent reply other threads:[~2026-11-28 19:01 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-30 10:46 Q: .gitignore and asterisk "*" Windl, Ulrich
2026-10-30 16:59 ` Junio C Hamano
2026-11-03 7:33 ` Tuomas Ahola
2026-11-03 12:00 ` [EXT] " Windl, Ulrich
2026-11-03 17:13 ` Junio C Hamano
2026-11-03 17:29 ` Tuomas Ahola
2026-11-03 22:40 ` [PATCH v2] gitignore: rewrite wildcard description Junio C Hamano
2026-11-28 7:13 ` Matt Hunter
2026-11-28 19:03 ` Junio C Hamano
2026-11-28 19:01 ` Junio C Hamano [this message]
2026-11-29 9:16 ` [PATCH v3] " Matt Hunter
2026-11-29 19:50 ` Junio C Hamano
2026-11-30 4:53 ` Matt Hunter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqcxrowzjn.fsf_-_@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=m@lfurio.us \
--cc=u.windl@ukr.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.