On 2009-02-12, Peter Baumann <waste.manager@xxxxxx> wrote: > On Wed, Feb 11, 2009 at 11:40:44AM -0800, Linus Torvalds wrote: >> On Wed, 11 Feb 2009, Peter Baumann wrote: >> >> > after reading Junio's nice blog today where he >> > explained how to use git grep efficiently, I saw him >> > using a glob to match for the interesting files: >> > >> > $ git grep -e ';;' -- '*.c' >> > >> > Is it possible to have the same feature in git diff and the revision >> > machinery? >> >> Not really. Git has two different kinds of path limiters, and they are >> really really different. >> >> - the "walk current index/directory recursively" kind that "git ls-files" >> uses, which takes a 'fnmatch()' type path regexp (not a real regexp, >> but the kind you're used to with shell) >> >> NOTE! On purpose, we don't set the FNM_PATHNAME, so "*.c" here is >> different from *.c in shell (it's more like "**.c" in tcsh). IOW, * >> matches '/' too, and will walk subdirectories. >> > > Hm. But if git does only anchor the * at the current directory, wouldn't > this solve (or at least reduce) the performance problems you described in the > later paragraph? Having the "**.c" do a recurisve search for every .c > file would then be used to do a recusrive search. I think Linus meant that it's expensive to look for all *.c files at any depth in the tree, for every commit in repository. You can have either a prefix matcher to limit the search *within* a tree so you can afford to walk all revs in the repo, or you stick to just one tree (or a few explicitly named ones). You seem to be saying 'fine, I know, and I'm willing to indicate that I'm accepting this cost by using a different syntax'. But the syntax is not the point. You can certainly do that right now, if you really wish to. Just don't try it on a large repo :-) git grep -e pattern $(git rev-list --all) -- *.c Make suitable modifications to the '--all' in the git rev-list to limit the revs you want to search. Regardless of whether there is a simple syntax to support it or not, this is probably not what you want, most of the time :-) Sitaram -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html