From: Andreas Schwab <schwab@linux-m68k•org>
To: "Maël Nison" <nison.mael@gmail•com>
Cc: git@vger•kernel.org
Subject: Re: Glob patterns w/ **; zero or more?
Date: Sun, 16 Apr 2023 21:04:59 +0200 [thread overview]
Message-ID: <87ttxfsl5w.fsf@igel.home> (raw)
In-Reply-To: <CANiF4iAaWB9j+Mma0-yfp6GvoQuM4k_OBAXn0keR+vCg8PQjmA@mail.gmail.com> ("Maël Nison"'s message of "Sun, 16 Apr 2023 20:40:43 +0200")
On Apr 16 2023, Maël Nison wrote:
> I noticed that, in a repo with a single `main.c` file, `git ls-files
> './**/main.c'` (note the surrounding quotes, to avoid shell globbing)
> returns no result even though `git ls-files main.c` does. It however
> can find any `main.c` file located in a subdirectory, suggesting `**`
> is interpreted as "one or more" rather than "zero or more". Can you
> confirm it'd be a bug? I checked in both 2.38 and 2.40.
By default, pathspec matching does not take "**" specially, making it
equivalen to "*", but it can match "/". Thus "./**/main.c" is the same
as "*/main.c" (the leading "./" always matches) and matches paths with
at least one "/" in it (thus "*/main.c" does not match "main.c").
If you use ":(glob)./**/main.c", it uses shell glob matching, where "**"
is special and "/**/" can match "/", but "*" does not match "/".
--
Andreas Schwab, schwab@linux-m68k•org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1
"And now for something completely different."
prev parent reply other threads:[~2023-04-16 19:10 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-16 18:40 Glob patterns w/ **; zero or more? Maël Nison
2023-04-16 19:04 ` Andreas Schwab [this message]
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=87ttxfsl5w.fsf@igel.home \
--to=schwab@linux-m68k$(echo .)org \
--cc=git@vger$(echo .)kernel.org \
--cc=nison.mael@gmail$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox