# Question: how to have ls-files use the .gitignore in the index

2 messages from 2012-04-02 to 2012-04-06. Participants: Holding, Lawrence, Kevin.
Thread: https://gitlist.dev/t/30132

## Holding, Lawrence, 2012-04-02 23:07

Subject: Question: how to have ls-files use the .gitignore in the index
Message-ID: <A5E8E180685CEF45AB9E737A010799805DFACA@cdnz-ex1.corp.cubic.cub>
URL: https://gitlist.dev/e/A5E8E180685CEF45AB9E737A010799805DFACA%40cdnz-ex1.corp.cubic.cub

```
I have a pre-commit hook that checks the index for files that match the
ignores / excludes in the repository. But sometimes this will run on a
repository where not all the folders are up-to-date with the tip, and
will then test against the working tree versions of these files and not
those in the index.

from pre-commit:

	if git ls-files -i --exclude-standard | grep .
	then
	    exit 1
	fi 

Is there an option to have ls-files use the excludes in the index
without checking out the whole file tree?

Thanks,

```

## Kevin, 2012-04-06 11:21

Subject: Re: Question: how to have ls-files use the .gitignore in the index
Message-ID: <20120406112113.GA4528@ikke-laptop.buyways.nl>
URL: https://gitlist.dev/e/20120406112113.GA4528%40ikke-laptop.buyways.nl
In-Reply-To: <A5E8E180685CEF45AB9E737A010799805DFACA@cdnz-ex1.corp.cubic.cub>

```
What I would do is check out the file from the index to a temporary
file, and use that as an exclude file.

You can probably use git checkout-index in combination with --temp to
create the file.

Kevin

On Tue, Apr 03, 2012 at 11:07:08AM +1200, Holding, Lawrence wrote:
> I have a pre-commit hook that checks the index for files that match the
> ignores / excludes in the repository. But sometimes this will run on a
> repository where not all the folders are up-to-date with the tip, and
> will then test against the working tree versions of these files and not
> those in the index.
> 
> from pre-commit:
> 
> 	if git ls-files -i --exclude-standard | grep .
> 	then
> 	    exit 1
> 	fi 
> 
> Is there an option to have ls-files use the excludes in the index
> without checking out the whole file tree?
> 
> Thanks,

```
