Re: [BUG] ls-files '**' globstar matches one or more directories instead of zero or more directories
On IRC someone pointed me to the glossary section for pathspec, and I find that even more confusing. In the section about ":(glob)" it says: > For example, "**/foo" matches file or directory "foo" anywhere, the same as > pattern "foo". This is not true for ls-files: ":(glob)**/.gitignore" is completely different to ":(glob).gitignore". The only place where it is true is inside .gitignore files, and there the ":(glob)" syntax does not work. -- Alistair Buxton a.j.bux...@gmail.com
Re: [BUG] ls-files '**' globstar matches one or more directories instead of zero or more directories
On 16 April 2017 at 12:25, Duy Nguyenwrote: > git ls-files ':(glob)**/*' > > Without that '**' is a normal '*' and matching just subdirs is expected. But '*/' should match exactly one subdirectory deep. Instead it matches one more more subdirectories. Meaning it behaves the way '**/*/' should. Try the following in the git source repo: shopt -s globstar diff <(ls -1 */.gitignore | sort) <(git ls-files '*/.gitignore' | sort) diff <(ls -1 */**/.gitignore | sort) <(git ls-files '*/.gitignore' | sort) of course it works as expected if you say the magic word: diff <(ls -1 */.gitignore | sort) <(git ls-files ':(glob)*/.gitignore' | sort) -- Alistair Buxton a.j.bux...@gmail.com
Re: [BUG] ls-files '**' globstar matches one or more directories instead of zero or more directories
On Sat, Apr 15, 2017 at 2:17 AM, Alistair Buxtonwrote: > To reproduce, go to any git repository and run: > > diff <(git ls-files '**/*' | sort) <(git ls-files | sort) Actually the '**/' magic only kicks in if you write git ls-files ':(glob)**/*' Without that '**' is a normal '*' and matching just subdirs is expected. -- Duy
Re: [BUG] ls-files '**' globstar matches one or more directories instead of zero or more directories
On Sat, Apr 15, 2017 at 2:17 AM, Alistair Buxtonwrote: > To reproduce, go to any git repository and run: > > diff <(git ls-files '**/*' | sort) <(git ls-files | sort) > > Expected result: No output since both commands should produce identical > output. > > Actual result: '**/*' only matches files at least one directory deep. > > The same happens with eg '**/Makefile' - only Makefiles in > subdirectories are listed. > > I have personally tested with 2.7.8 and 2.12.0. Others on IRC report > that this happens in the next branch. Another data point. t3070-wildmatch.sh has a test for this case match 1 0 'foo' '**/foo' so the pattern matching machinery is _not_ broken. There may be some changes in ls-files (pathspec-related?) that leads to this. But I didn't try to bisect it. -- Duy