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

Re: git ls-files wildcard behavior considered harmful

From
Duy Nguyen <pclouds@gmail.com>
Date
Mar 30, 2015, 23:16 UTC
Message-ID
<CACsJy8BDoXHS6nj7pEe0i8T=bMD8aG5FwuXABKgPOQBeMOr+Vw@mail.gmail.com>
In-Reply-To
<20150330230459.GA13927@kitenet.net>
On Tue, Mar 31, 2015 at 6:04 AM, Joey Hess <id@joeyh.name> wrote:
Show 18 quoted lines
> I was very surprised to learn the other day that git ls-files 'foo*'
> will expand wildcards (including character classes), in the absence of
> expansion by the shell. (git version 2.1.4)
>
> joey@darkstar:~/tmp/aaa>git ls-files 'foo*bar'
> foo*bar
> foobazbar
> joey@darkstar:~/tmp/aaa>git ls-files '[abc]'
> [abc]
> a
> b
>
> As far as I can see this behavior is not documented on the man page,
> except for a tiny mention in the --with-tree documentation, where
> it says "<file> (i.e. path pattern)".
>
> Since I wanted to avoid this wildcard expension, I tried slash-escaping
> the wildcard characters.
You can do "git --literal-pathspecs ls-files ..." or set GIT_LITERAL_PATHSPECS.
-- 
Duy
Previous: Joey HessNext: Joey Hess
Message 2 of 6 in “git ls-files wildcard behavior considered harmful”
  1. Joey HessMar 30, 2015
  2. Duy NguyenMar 30, 2015
  3. Joey HessMar 30, 2015
  4. Jeff KingMar 31, 2015
  5. Duy NguyenMar 31, 2015
  6. Jonathan NiederMar 30, 2015

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.