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

Re: [PATCH] gitignore.txt: elaborate shell glob syntax

From
Duy Nguyen <pclouds@gmail.com>
Date
Feb 1, 2018, 09:59 UTC
Message-ID
<20180201095914.GA6939@ash>
In-Reply-To
<xmqqh8r1r4u1.fsf@gitster-ct.c.googlers.com>
On Wed, Jan 31, 2018 at 03:22:46PM -0800, Junio C Hamano wrote:
> Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:

Argh.. stray patches strike again. It's not supposed to be in this thread but in

https://public-inbox.org/git/%3C20180130101351.GA761@ash%3E/
Show 18 quoted lines
> 
> >     `.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.
> 
> Where the original did not quote single letters at all, this uses a
> pair of single quotes.  Did you make sure it renders well in HTML
> and manpage already or should I do that for you before applying?

I didn't. I thought I didn't add any weird symbols. I was wrong. These are now wrapped as "`stuff`" to be displayed the same way as in nearby paragraphs. Verified both man and HTML pages are rendered well.

> I think what you wrote is accurate enough already, and those who
> want to go to fnmatch(3) would do so not for accuracy but for
> authority ;-) Perhaps s/accurate/detailed/?

Well there are rooms for guessing, for example "matches anything" does not tell you straight that it can match multiple characters. Anyway fixed too.

-- 8< --
Subject: [PATCH v2] 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..ff5d7f9ed6 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: "`*`" 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 detailed
+   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: Junio C HamanoNext: Nguyễn Thái Ngọc Duy
Message 27 of 40 in “Add "git rebase --show-patch"”
  1. 0/2 Add "git rebase --show-patch"Nguyễn Thái Ngọc Duy, Jan 26, 2018
  2. 1/2 am: add --show-patchNguyễn Thái Ngọc Duy, Jan 26, 2018
  3. 2/2 rebase: add --show-patchNguyễn Thái Ngọc Duy, Jan 26, 2018
  4. Phillip WoodJan 26, 2018
  5. Duy NguyenJan 26, 2018
  6. Phillip WoodJan 30, 2018
  7. Eric SunshineJan 26, 2018
  8. Duy NguyenJan 27, 2018
  9. Tim LandscheidtJan 26, 2018
  10. Duy NguyenJan 27, 2018
  11. Ævar Arnfjörð BjarmasonJan 27, 2018
  12. Johannes SchindelinJan 29, 2018
  13. Duy NguyenJan 30, 2018
  14. Johannes SchindelinJan 30, 2018
  15. Junio C HamanoJan 30, 2018
  16. Tim LandscheidtFeb 1, 2018
  17. 0/3 Add "git rebase --show-patch"Nguyễn Thái Ngọc Duy, Jan 31, 2018
  18. 1/3 am: add --show-current-patchNguyễn Thái Ngọc Duy, Jan 31, 2018
  19. Eric SunshineJan 31, 2018
  20. Junio C HamanoJan 31, 2018
  21. Duy NguyenFeb 2, 2018
  22. Eric SunshineFeb 2, 2018
  23. Duy NguyenFeb 2, 2018
  24. Junio C HamanoFeb 2, 2018
  25. gitignore.txt: elaborate shell glob syntaxNguyễn Thái Ngọc Duy, Jan 31, 2018
  26. Junio C HamanoJan 31, 2018
  27. Duy NguyenFeb 1, 2018
  28. 2/3 rebase: add --show-current-patchNguyễn Thái Ngọc Duy, Jan 31, 2018
  29. 3/3 rebase: introduce and use pseudo-ref ORIG_COMMITNguyễn Thái Ngọc Duy, Jan 31, 2018
  30. Junio C HamanoJan 31, 2018
  31. Duy NguyenFeb 1, 2018
  32. Junio C HamanoFeb 2, 2018
  33. Phillip WoodFeb 1, 2018
  34. 0/3 Add "git rebase --show-current-patch"Nguyễn Thái Ngọc Duy, Feb 11, 2018
  35. 1/3 am: add --show-current-patchNguyễn Thái Ngọc Duy, Feb 11, 2018
  36. 2/3 rebase: add --show-current-patchNguyễn Thái Ngọc Duy, Feb 11, 2018
  37. 3/3 rebase: introduce and use pseudo-ref REBASE_HEADNguyễn Thái Ngọc Duy, Feb 11, 2018
  38. Junio C HamanoFeb 22, 2018
  39. Tim LandscheidtFeb 22, 2018
  40. Duy NguyenFeb 23, 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.