threads / discuss / 3321

Quick question

Subject: Quick question

## tl;dr

9 messages between Feb 13, 2006 and Feb 14, 2006.

replies: 8people: 4as markdown or json

Radoslaw Szkodzinski· Feb 13, 2006, 16:36 UTC · lore
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· Feb 13, 2006, 16:54 UTC · re: Radoslaw Szkodzinski · lore

Re: Quick question

On Mon, 13 Feb 2006, Radoslaw Szkodzinski wrote:
Show 8 quoted lines
>
> 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· Feb 13, 2006, 18:26 UTC · re: Linus Torvalds · lore

Re: Quick question

Linus Torvalds wrote:
Show 13 quoted lines
> 
> 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· Feb 13, 2006, 20:17 UTC · re: Radoslaw Szkodzinski · lore

Re: Quick question

Radoslaw Szkodzinski, Mon, Feb 13, 2006 19:26:03 +0100:
Show 11 quoted lines
> 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.
Show 10 quoted lines
> > 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· Feb 14, 2006, 07:52 UTC · re: Linus Torvalds · lore

Re: Quick question

Linus Torvalds <torvalds@osdl.org> writes:
Show 10 quoted lines
> 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.

Junio C Hamano· Feb 14, 2006, 00:40 UTC · re: Radoslaw Szkodzinski · lore

Re: Quick question

Radoslaw Szkodzinski <astralstorm@gorzow.mm.pl> writes:
Show 7 quoted lines
> 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· Feb 14, 2006, 01:50 UTC · re: Junio C Hamano · lore

Re: Quick question

Junio C Hamano wrote:
Show 16 quoted lines
> 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· Feb 14, 2006, 02:03 UTC · re: Radoslaw Szkodzinski · lore

Re: Quick question

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· Feb 14, 2006, 02:21 UTC · re: Junio C Hamano · lore

Re: Quick question

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)

Show 8 quoted lines
> 
>> 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

← back to recent threads