From: Nguyen Thai Ngoc Duy Date: Tue, 28 Sep 2010 02:38:55 GMT Subject: Re: [PATCH 2/5] pathspec: add tree_recursive_diff parameter Message-ID: In-Reply-To: <7vocbivnfs.fsf@alter.siamese.dyndns.org> 2010/9/28 Junio C Hamano : > Nguyễn Thái Ngọc Duy   writes: > >> When wildcard match is implemented, a full path is needed to do final >> match. What type of diff_tree is performed determines how to treat >> directories: >> >>  - If it's recursive diff, directories are just an intermediate step. >>    All path must end with a file name. Thus, directories will be >>    unconditionally matched. > > Hmm, I am not sure what you mean by this.  If the pathspec says a/b*/c, > you are in "a" and are deciding if you should descend to its subdirectory, > then you would surely want to be able to say: > >  (1) Ah, the subdirectory I am looking at is "bar" and it does match "b*". >     It might contain "c"; I should descend into it. > >  (2) Nope, the subdirectory I am looking at is "frotz" and it can never >     match "b*", so there is no point recursing into it. > I did not go that far, trying to analyse the pattern. When I wrote "immediate step" I was thinking of "*foo" pattern, which effectively means descending to any reachable directories because '*' matches slashes too. I think that's the worst case. Anyway I did not know that I could borrow some optimizations from pathspec_matches() in builtin/grep.c. -- Duy