All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Windl, Ulrich" <u.windl@ukr.de>
To: Tuomas Ahola <taahol@utu.fi>, Junio C Hamano <gitster@pobox.com>
Cc: "git@vger.kernel.org" <git@vger.kernel.org>
Subject: RE: [EXT] Re: Q: .gitignore and asterisk "*"
Date: Tue, 3 Nov 2026 12:00:05 +0000	[thread overview]
Message-ID: <ea470151c8c6448caec64f26c3d35498@ukr.de> (raw)
In-Reply-To: <20261103073317.DATcL%taahol@utu.fi>

[-- Attachment #1: Type: text/plain, Size: 4589 bytes --]

Hi!

I think the original " matches anything except a slash." "kind of suggests" that is has to match "something" (non-zero length) to succeed, while the proposed "string of any length" would include zero-size for me.
Still, the latest proposal is just as clear IMHO.

Kind regards,
Ulrich Windl
 
Klinikum der Universität Regensburg
IT / Infrastruktur
 
Franz-Josef-Strauß-Allee 11
D-93053 Regensburg

Tel: +49 941 944-13816
Softphone: +49 941 944-801142
FAX: +49 941 944-5882

> -----Original Message-----
> From: Tuomas Ahola <taahol@utu.fi>
> Sent: Tuesday, November 3, 2026 8:33 AM
> To: Junio C Hamano <gitster@pobox.com>
> Cc: Windl, Ulrich <u.windl@ukr.de>; git@vger.kernel.org
> Subject: [EXT] Re: Q: .gitignore and asterisk "*"
> 
> Junio C Hamano <gitster@pobox.com> wrote:
> 
> > "Windl, Ulrich" <u.windl@ukr.de> writes:
> >
> > > I think the documentation for gitignore(5) could be improved regarding
> "*":
> > > It's nor clear whether "*" matches an empty string.
> > > So when I have
> > > foo.log
> > > foo.msg
> > > foo.sh
> > > foo-whatever.log
> > > foo-whetever.msg
> > > Would e.g. "foo*.log" cover all the logs?
> > >
> > > The manual says:
> > >        •   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.
> >
> > Very good point.
> >
> > The reference to fnmatch(3) may not make readers to consult the
> > documentation for the library function.  The system they are on may
> > not even have "man".  fnmatch(3) often refers to glob(7), which
> > typically would say that a '*' (not between brackets) matches any
> > string, including the empty string.  The reference to FNM_PATHNAME
> > we have there is an attempt to refer back to fnmatch(3) that would
> > typically say that the wildcard does not match a slash.
> >
> > How about rewriting the entry like so to reduce external references?
> >
> > ----- >8 -----
> > Subject: gitignore: rewrite wildcard description
> >
> > 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)
> > says.
> >
> > Signed-off-by: Junio C Hamano <gitster@pobox.com>
> > ---
> >  Documentation/gitignore.adoc | 15 ++++++++++-----
> >  1 file changed, 10 insertions(+), 5 deletions(-)
> >
> > diff --git c/Documentation/gitignore.adoc
> w/Documentation/gitignore.adoc
> > index 7979e50f18..671a5a4c99 100644
> > --- c/Documentation/gitignore.adoc
> > +++ w/Documentation/gitignore.adoc
> > @@ -110,11 +110,16 @@ 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 string of any length, and a question mark
> 
> It's not unreasonable at all to call the empty string "a string of no length",
> so it is still a bit ambiguous whether it qualifies as a string of any length.
> I would suggest s/of any length/of length of zero or more/.
> 
> > +   "`?`" 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 backslash ("`\`") can be used to escape any character. E.g., "`\*`"
> >     matches a literal asterisk (and "`\a`" matches "`a`", even though

[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5581 bytes --]

  reply	other threads:[~2026-11-03 12:00 UTC|newest]

Thread overview: 7+ 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     ` Windl, Ulrich [this message]
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

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=ea470151c8c6448caec64f26c3d35498@ukr.de \
    --to=u.windl@ukr.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=taahol@utu.fi \
    /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.