# Behavior of git ls-files

2 messages from 2011-03-04 to 2011-03-05. Participants: Steffen Jaeckel, Clemens Buchacher.
Thread: https://gitlist.dev/t/26658

## Steffen Jaeckel, 2011-03-04 17:38

Subject: Behavior of git ls-files
Message-ID: <691824945.20110304183831@stzedn.de>
URL: https://gitlist.dev/e/691824945.20110304183831%40stzedn.de

```
Hi,

I want to list all files in a repository that are tracked, but shall be ignored
when following the patterns in .gitignore
I tried to do this by "git ls-files --exclude-standard -i" but it seems as if it
doesn't properly handle directory entries in .gitignore

The following example shall reproduce this issue:

> $ mkdir test
> $ cd test
> $ git init
> $ mkdir testdir
> $ touch testdir/test
> $ git add testdir/test
> $ git commit -m "add test"
> $ echo "testdir/" > .gitignore
> $ git ls-files --exclude-standard -i

Is the behavior of git ls-files correct or not?

Thanks,
Steffen

```

## Clemens Buchacher, 2011-03-05 08:47

Subject: Re: Behavior of git ls-files
Message-ID: <20110305084733.GA3039@toss>
URL: https://gitlist.dev/e/20110305084733.GA3039%40toss
In-Reply-To: <691824945.20110304183831@stzedn.de>

```
On Fri, Mar 04, 2011 at 06:38:31PM +0100, Steffen Jaeckel wrote:
> 
> Is the behavior of git ls-files correct or not?

Indeed, the behavior is not correct. It does not find any files
which are excluded only due to a directory exclude.

In the cases without -i we do not even have to look at files under
an ignored directory. So the matching rules are not applied
correctly in this case.

We have the same problem with git ls-files -i -o, unless you also
specify --directory (in which case, again, we do not need to look
at files under the ignored directory).

Clemens

```
