# let git-ls-files suppress the expanding of all files in sub directory

3 messages from 2022-06-30 to 2022-06-30. Participants: lilinchao@oschina.cn, Erik Cervin Edin, Junio C Hamano.
Thread: https://gitlist.dev/t/58087

## lilinchao@oschina.cn, 2022-06-30 06:14

Subject: let git-ls-files suppress the expanding of all files in sub directory
Message-ID: <202206281608475079493@oschina.cn>
URL: https://gitlist.dev/e/202206281608475079493%40oschina.cn

```
As subject said, is this possible for git-ls-files to work like this?:
" $ git ls-files --no-recursion
    a.txt
    b.txt
    dir/
"
instead of:
" $ git ls-files 
    a.txt
    b.txt
    dir/one/two/1.txt
    dir/one/two/2.txt
    dir/one/3.txt
    dir/4.txt
"

Does it make sense?
```

## Erik Cervin Edin, 2022-06-30 23:04

Subject: Re: let git-ls-files suppress the expanding of all files in sub directory
Message-ID: <CA+JQ7M_rd_SdzLOL=a0ok=HL9AZ-q=V2Bc2aTuLRrPW8j7DOqA@mail.gmail.com>
URL: https://gitlist.dev/e/CA%2BJQ7M_rd_SdzLOL%3Da0ok%3DHL9AZ-q%3DV2Bc2aTuLRrPW8j7DOqA%40mail.gmail.com
In-Reply-To: <202206281608475079493@oschina.cn>

```
On Thu, Jun 30, 2022, 8:26 AM lilinchao@oschina.cn <lilinchao@oschina.cn> wrote:
>
> As subject said, is this possible for git-ls-files to work like this?:
> " $ git ls-files --no-recursion
>     a.txt
>     b.txt
>     dir/
> "

An alternative
  git ls-tree --name-only HEAD
is suggested here
https://stackoverflow.com/a/10453994

Maybe that works?

```

## Junio C Hamano, 2022-06-30 23:49

Subject: Re: let git-ls-files suppress the expanding of all files in sub directory
Message-ID: <xmqqv8shaf0v.fsf@gitster.g>
URL: https://gitlist.dev/e/xmqqv8shaf0v.fsf%40gitster.g
In-Reply-To: <CA+JQ7M_rd_SdzLOL=a0ok=HL9AZ-q=V2Bc2aTuLRrPW8j7DOqA@mail.gmail.com>

```
Erik Cervin Edin <erik@cervined.in> writes:

> On Thu, Jun 30, 2022, 8:26 AM lilinchao@oschina.cn <lilinchao@oschina.cn> wrote:
>>
>> As subject said, is this possible for git-ls-files to work like this?:
>> " $ git ls-files --no-recursion
>>     a.txt
>>     b.txt
>>     dir/
>> "
>
> An alternative
>   git ls-tree --name-only HEAD
> is suggested here
> https://stackoverflow.com/a/10453994

The index may have different contents from HEAD, so it won't be a
replacement in general.

The index is a flat list of paths, so it is not like you can
suppressing the expansion (to avoid extra work).  You have to do
more work to omit paths in subdirectories to create such output.


```
