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

Re: ls-tree and wildcards

From
Nguyen Thai Ngoc Duy <pclouds@gmail.com>
Date
May 12, 2012, 15:40 UTC
Message-ID
<CACsJy8A73D_39ND-aqF0nECcKqjLHeqvEJ_XbT3BJd-0cLV1Nw@mail.gmail.com>
In-Reply-To
<4FAE7CBD.3020605@rotorised.com>
On Sat, May 12, 2012 at 10:07 PM, Ryan McCue <lists@rotorised.com> wrote:
Show 19 quoted lines
> Good evening folks,
>
> I'm attempting to grab relevant information for files in a tree matching a
> given pattern with wildcards. The help for ls-tree indicates that it can
> accept a pattern of files to match, however I'm not able to see that.
>
> $ git ls-tree origin/master
> ...
> 100644 blob 8c391e8fb44a38e1389a710ebf8af79612e592a6    screenshot-1.png
> 100644 blob ecb7159c1c02567e9cd5da83c254c538d331f733    screenshot-2.png
> 100644 blob f58eea7e27f98c01038262b823aa73ccd64cb01e    screenshot-3.png
> 100644 blob 07e64def408145660cee657a46947077374762cc    screenshot-4.png
> $ git ls-tree origin/master screenshot*
> $
>
> (I've also tried quoting to ensure it's not bash playing up)
>
> Is there some issue with the command I'm issuing? The documentation seems to
> indicate that I should be getting back the files which match the pattern.

I don't think it ever does. There's a mention of "patterns" in ls-tree man page, which is misleading. We have the facilities to do that now ("lstree -r patterns" actually) but that might break backward compatibility. For now I guess you can just do

GIT_INDEX_FILE=/tmp/some-temporary-index git read-tree origin/master GIT_INDEX_FILE=/tmp/some-temporary-index ls-files <patterns>

A question that might help us understand your use case and give a better advice, or improve the system: why do you need that?

-- 
Duy
Previous: Ryan McCueNext: Ryan McCue
Message 2 of 6 in “ls-tree and wildcards”
  1. Ryan McCueMay 12, 2012
  2. Nguyen Thai Ngoc DuyMay 12, 2012
  3. Ryan McCueMay 12, 2012
  4. Junio C HamanoMay 14, 2012
  5. Nguyen Thai Ngoc DuyMay 15, 2012
  6. Junio C HamanoMay 15, 2012

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.