threads / discuss / 58087

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

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

## tl;dr

3 messages between Jun 30, 2022 and Jun 30, 2022.

replies: 2people: 3as markdown or json

lilinchao@oschina.cn· Jun 30, 2022, 06:14 UTC · lore
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· Jun 30, 2022, 23:04 UTC · re: lilinchao@oschina.cn · lore

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

On Thu, Jun 30, 2022, 8:26 AM lilinchao@oschina.cn <lilinchao@oschina.cn> wrote:
Show 7 quoted lines
>
> 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· Jun 30, 2022, 23:49 UTC · re: Erik Cervin Edin · lore

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

Erik Cervin Edin <erik@cervined.in> writes:
Show 13 quoted lines
> 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.

← back to recent threads