ls-files: fix overeager pathspec optimization
authorJunio C Hamano <gitster@pobox.com>
Sat, 9 Jan 2010 07:05:41 +0000 (23:05 -0800)
committerJunio C Hamano <gitster@pobox.com>
Sat, 9 Jan 2010 07:14:50 +0000 (23:14 -0800)
Given pathspecs that share a common prefix, ls-files optimized its call
into recursive directory reader by starting at the common prefix
directory.

If you have a directory "t" with an untracked file "t/junk" in it, but the
top-level .gitignore file told us to ignore "t/", this resulted in:

$ git ls-files -o --exclude-standard
$ git ls-files -o --exclude-standard t/
t/junk
$ git ls-files -o --exclude-standard t/junk
t/junk
$ cd t && git ls-files -o --exclude-standard
junk

We could argue that you are overriding the ignore file by giving a
patchspec that matches or being in that directory, but it is somewhat
unexpected. Worse yet, these behave differently:

$ git ls-files -o --exclude-standard t/ .
$ git ls-files -o --exclude-standard t/
t/junk

This patch changes the optimization so that it notices when the common
prefix directory that it starts reading from is an ignored one.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
No differences found