# Quick question

9 messages from 2006-02-13 to 2006-02-14. Participants: Radoslaw Szkodzinski, Linus Torvalds, Alex Riesen, Junio C Hamano.
Thread: https://gitlist.dev/t/3321

## Radoslaw Szkodzinski, 2006-02-13 16:36

Subject: Quick question
Message-ID: <43F0B577.4070608@gorzow.mm.pl>
URL: https://gitlist.dev/e/43F0B577.4070608%40gorzow.mm.pl

```
How to display ignored files of the whole project using only core git?

I've tried:

git-ls-files -o -i -X .git/info/exclude

and it only showed me the excluded files in the current directory...

-- 
GPG Key id:  0xD1F10BA2
Fingerprint: 96E2 304A B9C4 949A 10A0  9105 9543 0453 D1F1 0BA2

AstralStorm


```

## Linus Torvalds, 2006-02-13 16:54

Subject: Re: Quick question
Message-ID: <Pine.LNX.4.64.0602130848220.3691@g5.osdl.org>
URL: https://gitlist.dev/e/Pine.LNX.4.64.0602130848220.3691%40g5.osdl.org
In-Reply-To: <43F0B577.4070608@gorzow.mm.pl>

```


On Mon, 13 Feb 2006, Radoslaw Szkodzinski wrote:
>
> How to display ignored files of the whole project using only core git?
> 
> I've tried:
> 
> git-ls-files -o -i -X .git/info/exclude
> 
> and it only showed me the excluded files in the current directory...

Well, since you're telling it to only show excluded files, it will also 
only show excluded directories.

Which is admittedly insane. You don't want to exclude directories. Or 
maybe you do, but then we should add the "/" to the end before we do the 
exclusion.

This patch (untested) will never exclude directories. Which may or may not 
be the right thing. 

Junio? Others? Comments?

		Linus

---
diff --git a/ls-files.c b/ls-files.c
index 7024cf1..b923f92 100644
--- a/ls-files.c
+++ b/ls-files.c
@@ -276,8 +276,6 @@ static void read_directory(const char *p
 				continue;
 			len = strlen(de->d_name);
 			memcpy(fullname + baselen, de->d_name, len+1);
-			if (excluded(fullname) != show_ignored)
-				continue;
 
 			switch (DTYPE(de)) {
 			struct stat st;
@@ -304,6 +302,8 @@ static void read_directory(const char *p
 			case DT_LNK:
 				break;
 			}
+			if (excluded(fullname) != show_ignored)
+				continue;
 			add_name(fullname, baselen + len);
 		}
 		closedir(dir);

```

## Radoslaw Szkodzinski, 2006-02-13 18:26

Subject: Re: Quick question
Message-ID: <43F0CF3B.6040807@gorzow.mm.pl>
URL: https://gitlist.dev/e/43F0CF3B.6040807%40gorzow.mm.pl
In-Reply-To: <Pine.LNX.4.64.0602130848220.3691@g5.osdl.org>

```
Linus Torvalds wrote:
> 
> Well, since you're telling it to only show excluded files, it will also 
> only show excluded directories.
> 
> Which is admittedly insane. You don't want to exclude directories. Or 
> maybe you do, but then we should add the "/" to the end before we do the 
> exclusion.
> 
> This patch (untested) will never exclude directories. Which may or may not 
> be the right thing. 
> 
> Junio? Others? Comments?
> 

For me it seems to do the right thing, although I have no need to exclude directories.
If I really needed to, I'd say something like:

/excluded_dir/*

in .git/info/exclude, and it would show the files as being excluded.

-- 
GPG Key id:  0xD1F10BA2
Fingerprint: 96E2 304A B9C4 949A 10A0  9105 9543 0453 D1F1 0BA2

AstralStorm


```

## Alex Riesen, 2006-02-13 20:17

Subject: Re: Quick question
Message-ID: <20060213201709.GB5935@steel.home>
URL: https://gitlist.dev/e/20060213201709.GB5935%40steel.home
In-Reply-To: <43F0CF3B.6040807@gorzow.mm.pl>

```
Radoslaw Szkodzinski, Mon, Feb 13, 2006 19:26:03 +0100:
> Linus Torvalds wrote:
> > 
> > Well, since you're telling it to only show excluded files, it will also 
> > only show excluded directories.
> > 
> > Which is admittedly insane. You don't want to exclude directories. Or 
> > maybe you do, but then we should add the "/" to the end before we do the 
> > exclusion.
> > 
> > This patch (untested) will never exclude directories. Which may or may not 
> > be the right thing. 

I actually quiet like it how it is.

> > Junio? Others? Comments?
> > 
> 
> For me it seems to do the right thing, although I have no need to exclude directories.
> If I really needed to, I'd say something like:
> 
> /excluded_dir/*
> 
> in .git/info/exclude, and it would show the files as being excluded.
> 

What's wrong with .gitignore in the excluded_dir containing everything
you don't want to see, or even just "*"?

```

## Junio C Hamano, 2006-02-14 00:40

Subject: Re: Quick question
Message-ID: <7vy80eydq0.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7vy80eydq0.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <43F0B577.4070608@gorzow.mm.pl>

```
Radoslaw Szkodzinski <astralstorm@gorzow.mm.pl> writes:

> How to display ignored files of the whole project using only core git?
>
> I've tried:
>
> git-ls-files -o -i -X .git/info/exclude
>
> and it only showed me the excluded files in the current directory...

With the git.git repository itself, I tried:

$ cat /var/tmp/i
*.c
$ git ls-files -i -X /var/tmp/i | head -n 6
apply.c
arm/sha1.c
blob.c
cat-file.c
check-ref-format.c
checkout-index.c

So I am not sure what you mean.  You wanted to "display ignored
files of the whole project", right?  I am getting arm/sha1.c
here in my output, so I do not understand the issue here...

```

## Radoslaw Szkodzinski, 2006-02-14 01:50

Subject: Re: Quick question
Message-ID: <43F13776.9000501@gorzow.mm.pl>
URL: https://gitlist.dev/e/43F13776.9000501%40gorzow.mm.pl
In-Reply-To: <7vy80eydq0.fsf@assigned-by-dhcp.cox.net>

```
Junio C Hamano wrote:
> With the git.git repository itself, I tried:
> 
> $ cat /var/tmp/i
> *.c
> $ git ls-files -i -X /var/tmp/i | head -n 6
> apply.c
> arm/sha1.c
> blob.c
> cat-file.c
> check-ref-format.c
> checkout-index.c
> 
> So I am not sure what you mean.  You wanted to "display ignored
> files of the whole project", right?  I am getting arm/sha1.c
> here in my output, so I do not understand the issue here...
> 

Wrong. I wanted to display files that are ignored and not checked in.
(unlike your example)

That's why I used the -o (--others).

Try your example with git repo's .gitignore and any .o file.
I would like to use it for backup~ hunting purposes in a script
and not have to worry about find and other less portable tools.

-- 
GPG Key id:  0xD1F10BA2
Fingerprint: 96E2 304A B9C4 949A 10A0  9105 9543 0453 D1F1 0BA2

AstralStorm


```

## Junio C Hamano, 2006-02-14 02:03

Subject: Re: Quick question
Message-ID: <7v3bimy9wn.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7v3bimy9wn.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <43F13776.9000501@gorzow.mm.pl>

```
Radoslaw Szkodzinski <astralstorm@gorzow.mm.pl> writes:

> Wrong. I wanted to display files that are ignored and not checked in.
> (unlike your example)

Wow, you have a strong voice.

> That's why I used the -o (--others).

You asked it to show either ignored or others.


> I would like to use it for backup~ hunting purposes in a script
> and not have to worry about find and other less portable tools.

I usually do this for that:

	git ls-files -o '*~'

```

## Radoslaw Szkodzinski, 2006-02-14 02:21

Subject: Re: Quick question
Message-ID: <43F13EC2.7040909@gorzow.mm.pl>
URL: https://gitlist.dev/e/43F13EC2.7040909%40gorzow.mm.pl
In-Reply-To: <7v3bimy9wn.fsf@assigned-by-dhcp.cox.net>

```
Junio C Hamano wrote:
> Wow, you have a strong voice.
>
I didn't want to sound rude at all, of course.

>> That's why I used the -o (--others).
> 
> You asked it to show either ignored or others.
> 

So here's the catch? I don't think so.
But the manpage isn't totally clear in this matter.

When I specify just -o, it gives me files which weren't ignored too.
-o -i gives me only ignored files.
Plain -i returns nothing.

With git directory, compare:
git-ls-files -o -i -X .gitignore

with:
git-ls-files -o

The remainder is:
git-ls-files -o -X .gitignore

I have the documentation built.
(Yes, I'm not including its .gitignore on purpose)

> 
>> I would like to use it for backup~ hunting purposes in a script
>> and not have to worry about find and other less portable tools.
> 
> I usually do this for that:
> 
> 	git ls-files -o '*~'
> 

Also good. I have *~ in ignored too, so I think -o -i will suffice.

-- 
GPG Key id:  0xD1F10BA2
Fingerprint: 96E2 304A B9C4 949A 10A0  9105 9543 0453 D1F1 0BA2

AstralStorm


```

## Junio C Hamano, 2006-02-14 07:52

Subject: Re: Quick question
Message-ID: <7voe1atm19.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7voe1atm19.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <Pine.LNX.4.64.0602130848220.3691@g5.osdl.org>

```
Linus Torvalds <torvalds@osdl.org> writes:

> Which is admittedly insane. You don't want to exclude directories. Or 
> maybe you do, but then we should add the "/" to the end before we do the 
> exclusion.
>
> This patch (untested) will never exclude directories. Which may or may not 
> be the right thing. 
>
> Junio? Others? Comments?
>
> 		Linus

I might have sounded negative or happy with status quo in my
earlier messages but that was not intended.  I am swamped and
have not formed an opinion.

```
