git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Missing ? wildcard character in gitignore documentation

From
Duy Nguyen <pclouds@gmail.com>
Date
Jan 30, 2018, 10:13 UTC
Message-ID
<20180130101351.GA761@ash>
In-Reply-To
<000f01d39918$70009eb0$5001dc10$@nexbridge.com>
On Mon, Jan 29, 2018 at 10:47:10AM -0500, Randall S. Becker wrote:
Show 11 quoted lines
> The implication of support for ? is there through the following paragraph from the gitignore documentation:
> 
>     "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" or
>     "tools/perf/Documentation/perf.html"."
> 
> Of course you have to go read fnmatch(3), so it might be good for
> expand on this here :).
I agree. How about something like this?
-- 8< --
Subject: [PATCH] gitignore.txt: elaborate shell glob syntax

`fnmatch(3)` is a great mention if the intended audience is programmers. For normal users it's probably better to spell out what a shell glob is.

This paragraph is updated to roughly tell (or remind) what the main wildcards are supposed to do. All the details are still hidden away behind the `fnmatch(3)` wall because bringing the whole specification here may be too much.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 Documentation/gitignore.txt | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/Documentation/gitignore.txt b/Documentation/gitignore.txt
index 63260f0056..0f4b1360bd 100644
--- a/Documentation/gitignore.txt
+++ b/Documentation/gitignore.txt
@@ -102,12 +102,11 @@ PATTERN FORMAT
    (relative to the toplevel of the work tree if not from a
    `.gitignore` file).
 
- - 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/{asterisk}.html" matches
-   "Documentation/git.html" but not "Documentation/ppc/ppc.html"
-   or "tools/perf/Documentation/perf.html".
+ - Otherwise, Git treats the pattern as a shell glob: '{asterisk}'
+   matches anything except '/', '?' matches any one character except
+   '/' and '[]' matches one character in a selected range. See
+   fnmatch(3) and the FNM_PATHNAME flag for a more accurate
+   description.
 
  - A leading slash matches the beginning of the pathname.
    For example, "/{asterisk}.c" matches "cat-file.c" but not
-- 
2.16.1.205.g271f633410

-- 8< --
Previous: Jack FNext: Ævar Arnfjörð Bjarmason
Message 4 of 6 in “Missing ? wildcard character in gitignore documentation”
  1. Jack FJan 29, 2018
  2. Randall S. BeckerJan 29, 2018
  3. Jack FJan 29, 2018
  4. Duy NguyenJan 30, 2018
  5. Ævar Arnfjörð BjarmasonJan 30, 2018
  6. Duy NguyenJan 30, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.