[patch] improved ignore pattern matching (#57637)
Jan Hudec
bulb at ucw.cz
Mon Nov 27 06:44:35 GMT 2006
On Mon, Nov 27, 2006 at 01:41:24PM +0800, Kent Gibson wrote:
> John Arbash Meinel wrote:
> > Jan Hudec wrote:
> > ...
> >
> >> Well, I fear that users will tend to miss that 'foo/**/bar' does not
> >> match 'foo/bar' (and I think it is not SO uncommon to not want
> >> 'foo/**bar instead). This can be fixed either by making the pattern
> >> '**/' (like zsh does), that would expand to '(|.+/)', or to recognize
> >> both '**/' and '**', translating to '(|.+/)' and '.*' respectively.
> >>
> You sure wouldn't want to use foo/**bar since that would also match
> foo/bazbar - which isn't what you want in this case.
> >
> > Thanks for the clarification. So it does seem we need to understand '**/'
> >
> > I'm not positive that your exact translation is right. But I don't have
> > time to figure it out right now.
> >
> I would translate '**/' to '(.*/)?'.
Yes, this form is probably clearer.
> So 'foo/**/bar' would match 'foo/bar', 'foo/baz/bar', 'foo/.baz/bar',
> 'foo/baz/zoo/bar' and 'foo//bar'.
> I prefer the '.*' over '.+' cos 'foo/**/bar' will match one or more
> '/' between the 'foo' and 'bar', while '.+' will match one and > 2,
> but not 2 - i.e. 'foo//bar' will not match but foo///bar will.
> Not terribly important since N > 1 are not valid paths, but anyway...
Well, the paths are normalized before matching, so it will never see
multiple slashes in a row.
> Jan's '(|.+/)' is equivalent to '(.+/)?' - though not a use of '|'
> that I had seen before.
> I find the '?' form more readable.
>
> Does '(.*/)?' work for you guys?
--------------------------------------------------------------------------------
- Jan Hudec `Bulb' <bulb at ucw.cz>
More information about the bazaar
mailing list