From: Phillip Wood <phillip.wood123@gmail.com>
To: "Patrick Steinhardt" <ps@pks.im>,
"Евгений Плискин" <eugene.pliskin@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: Unexpected recursion in 'git rm'
Date: Fri, 3 Jul 2026 11:04:58 +0100 [thread overview]
Message-ID: <5827a94f-0f13-4747-8257-b67fb9d79ecd@gmail.com> (raw)
In-Reply-To: <akdzSHrJ4DfdUWoS@pks.im>
On 03/07/2026 09:31, Patrick Steinhardt wrote:
> On Thu, Jul 02, 2026 at 10:49:10AM +0300, Евгений Плискин wrote:
>> Hello.
>>
>> The following git command does recurse directories as contrary to the
>> reference (https://git-scm.com/docs/git-rm):
>>
>> git rm -n *.json
>>
>> Without directory specification before '*.json' this command is not
>> expected to recurse directories, but it really does.
Are there any ".json" files in the directory where you're running this?
As the glob is not quoted, I think maybe what is happening is that there
are no matching files in the current directory so the shell is not
expanding the glob as you expect and is passing it to git which treats
it as Patrick explains below.
Thanks
Phillip
> This is expected behaviour, as the argument to git-rm(1) is a pathspec,
> and "*" matches directory separators by default, see also gitglossary(7)
> under "pathspec":
>
> • the pathspec up to the last slash represents a directory prefix. The
> scope of that pathspec is limited to that subtree.
>
> • the rest of the pathspec is a pattern for the remainder of the
> pathname. Paths relative to the directory prefix will be matched
> against that pattern using fnmatch(3); in particular, * and ? can
> match directory separators.
>
> For example, Documentation/*.jpg will match all .jpg files in the
> Documentation subtree, including Documentation/chapter_1/figure_1.jpg.
>
> Could you maybe clarify which part of git-rm(1) made you think that this
> wouldn't happen?
>
> Thanks!
>
> Patrick
>
next prev parent reply other threads:[~2026-07-03 10:05 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-02 7:49 Unexpected recursion in 'git rm' Евгений Плискин
2026-07-03 7:01 ` Matt Hunter
[not found] ` <1978773121.20260703123754@gmail.com>
2026-07-03 13:04 ` Matt Hunter
2026-07-03 8:31 ` Patrick Steinhardt
2026-07-03 10:04 ` Phillip Wood [this message]
[not found] ` <1756071445.20260703123414@gmail.com>
2026-07-03 12:39 ` Patrick Steinhardt
2026-07-03 15:25 ` Mikael Magnusson
2026-07-03 20:41 ` 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=5827a94f-0f13-4747-8257-b67fb9d79ecd@gmail.com \
--to=phillip.wood123@gmail.com \
--cc=eugene.pliskin@gmail.com \
--cc=git@vger.kernel.org \
--cc=phillip.wood@dunelm.org.uk \
--cc=ps@pks.im \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox