* git-ls-files in subdirectories ignore higher-up .gitignore
@ 2006-01-24 17:59 Pavel Roskin
2006-01-25 2:08 ` Junio C Hamano
2006-01-25 6:11 ` Sam Ravnborg
0 siblings, 2 replies; 6+ messages in thread
From: Pavel Roskin @ 2006-01-24 17:59 UTC (permalink / raw)
To: git
Hello!
git-ls-files appears to behave in a way that may be unexpected to the
users. When run in a subdirectory, git-ls-files never reads .gitignore
or whatever is specified by --exclude-per-directory in the parent
directories.
This can be demonstrated in git's own repository:
$ touch t/test.o
$ git-ls-files --others --exclude-per-directory=.gitignore
$ cd t
$ git-ls-files --others --exclude-per-directory=.gitignore
test.o
$
Before I attempt to fix it, I'd like to make sure it's a bug, not a
feature.
--
Regards,
Pavel Roskin
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: git-ls-files in subdirectories ignore higher-up .gitignore
2006-01-24 17:59 git-ls-files in subdirectories ignore higher-up .gitignore Pavel Roskin
@ 2006-01-25 2:08 ` Junio C Hamano
2006-01-25 6:11 ` Sam Ravnborg
1 sibling, 0 replies; 6+ messages in thread
From: Junio C Hamano @ 2006-01-25 2:08 UTC (permalink / raw)
To: Pavel Roskin; +Cc: git
Pavel Roskin <proski@gnu.org> writes:
> This can be demonstrated in git's own repository:
>
> $ touch t/test.o
> $ git-ls-files --others --exclude-per-directory=.gitignore
> $ cd t
> $ git-ls-files --others --exclude-per-directory=.gitignore
> test.o
> $
>
> Before I attempt to fix it, I'd like to make sure it's a bug, not a
> feature.
I am not sure if that is a bug or a feature, but you are right.
We do not bother to go uplevel and look for .gitignore in the
current code.
It would probably be a welcome addition if your fix made these
two sequences work similarly modulo leading paths from the
command output. I think it is natural to expect they are moral
equivalents:
(Sequence 1)
$ touch t/test.o t/garbage
$ git-ls-files -o --exclude-per-directory=.gitignore t/
(Sequence 2)
$ touch t/test.o t/garbage
$ cd t
$ git-ls-files -o --exclude-per-directory=.gitignore
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: git-ls-files in subdirectories ignore higher-up .gitignore
2006-01-24 17:59 git-ls-files in subdirectories ignore higher-up .gitignore Pavel Roskin
2006-01-25 2:08 ` Junio C Hamano
@ 2006-01-25 6:11 ` Sam Ravnborg
2006-02-09 8:16 ` [PATCH] ls-files: honour per-directory ignore file from higher directories Junio C Hamano
1 sibling, 1 reply; 6+ messages in thread
From: Sam Ravnborg @ 2006-01-25 6:11 UTC (permalink / raw)
To: Pavel Roskin; +Cc: git
On Tue, Jan 24, 2006 at 12:59:30PM -0500, Pavel Roskin wrote:
> Hello!
>
> git-ls-files appears to behave in a way that may be unexpected to the
> users. When run in a subdirectory, git-ls-files never reads .gitignore
> or whatever is specified by --exclude-per-directory in the parent
> directories.
>
> This can be demonstrated in git's own repository:
>
> $ touch t/test.o
> $ git-ls-files --others --exclude-per-directory=.gitignore
> $ cd t
> $ git-ls-files --others --exclude-per-directory=.gitignore
> test.o
> $
>
> Before I attempt to fix it, I'd like to make sure it's a bug, not a
> feature.
I for one consider it a bug.
I expect exactly same output if I do
git ls-files t/
or
cd t; git ls-files
Very usefull when I limit grep to some part of the kernel tree for
example.
Sam
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] ls-files: honour per-directory ignore file from higher directories.
2006-01-25 6:11 ` Sam Ravnborg
@ 2006-02-09 8:16 ` Junio C Hamano
2006-02-10 3:38 ` Pavel Roskin
0 siblings, 1 reply; 6+ messages in thread
From: Junio C Hamano @ 2006-02-09 8:16 UTC (permalink / raw)
To: Pavel Roskin; +Cc: Sam Ravnborg, git
When git-ls-files -o --exclude-per-directory=.gitignore is run
from a subdirectory, it did not read from .gitignore from its
parent directory. Reading from them makes output from these two
commands consistent:
$ git ls-files -o --exclude-per-directory=.gitignore Documentation
$ cd Documentation &&
git ls-files -o --exclude-per-directory=.gitignore
Signed-off-by: Junio C Hamano <junkio@cox.net>
---
* If there are positive feedbacks on this one, I consider it
a safe enough candidate to be included in 1.2.0 release.
ls-files.c | 22 +++++++++++++++++++++-
1 files changed, 21 insertions(+), 1 deletions(-)
701ca744e386c2429ca44072ea987bbb4bdac7ce
diff --git a/ls-files.c b/ls-files.c
index 6af3b09..7024cf1 100644
--- a/ls-files.c
+++ b/ls-files.c
@@ -474,8 +474,28 @@ static void show_files(void)
const char *path = ".", *base = "";
int baselen = prefix_len;
- if (baselen)
+ if (baselen) {
path = base = prefix;
+ if (exclude_per_dir) {
+ char *p, *pp = xmalloc(baselen+1);
+ memcpy(pp, prefix, baselen+1);
+ p = pp;
+ while (1) {
+ char save = *p;
+ *p = 0;
+ push_exclude_per_directory(pp, p-pp);
+ *p++ = save;
+ if (!save)
+ break;
+ p = strchr(p, '/');
+ if (p)
+ p++;
+ else
+ p = pp + baselen;
+ }
+ free(pp);
+ }
+ }
read_directory(path, base, baselen);
qsort(dir, nr_dir, sizeof(struct nond_on_fs *), cmp_name);
if (show_others)
--
1.1.6.gbb042
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] ls-files: honour per-directory ignore file from higher directories.
2006-02-09 8:16 ` [PATCH] ls-files: honour per-directory ignore file from higher directories Junio C Hamano
@ 2006-02-10 3:38 ` Pavel Roskin
2006-02-10 4:44 ` Junio C Hamano
0 siblings, 1 reply; 6+ messages in thread
From: Pavel Roskin @ 2006-02-10 3:38 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Sam Ravnborg, git
Hello, Junio!
On Thu, 2006-02-09 at 00:16 -0800, Junio C Hamano wrote:
> When git-ls-files -o --exclude-per-directory=.gitignore is run
> from a subdirectory, it did not read from .gitignore from its
> parent directory. Reading from them makes output from these two
> commands consistent:
You beat me at that. Thank you!
With this patch, the simplified version of cg-clean passes the cogito
testsuite. That's where the original bug was caught.
> * If there are positive feedbacks on this one, I consider it
> a safe enough candidate to be included in 1.2.0 release.
Yes, it would be nice to see it released.
--
Regards,
Pavel Roskin
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] ls-files: honour per-directory ignore file from higher directories.
2006-02-10 3:38 ` Pavel Roskin
@ 2006-02-10 4:44 ` Junio C Hamano
0 siblings, 0 replies; 6+ messages in thread
From: Junio C Hamano @ 2006-02-10 4:44 UTC (permalink / raw)
To: Pavel Roskin; +Cc: Sam Ravnborg, git
Pavel Roskin <proski@gnu.org> writes:
> With this patch, the simplified version of cg-clean passes the cogito
> testsuite. That's where the original bug was caught.
Thanks for testing it.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2006-02-10 4:44 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-01-24 17:59 git-ls-files in subdirectories ignore higher-up .gitignore Pavel Roskin
2006-01-25 2:08 ` Junio C Hamano
2006-01-25 6:11 ` Sam Ravnborg
2006-02-09 8:16 ` [PATCH] ls-files: honour per-directory ignore file from higher directories Junio C Hamano
2006-02-10 3:38 ` Pavel Roskin
2006-02-10 4:44 ` Junio C Hamano
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).