Alternate glob matcher for .bzrignore

Robert Collins robertc at robertcollins.net
Sun Jan 8 23:21:32 GMT 2006


On Mon, 2006-01-09 at 10:14 +1100, Martin Pool wrote:
> > 
> > In doing some more testing, ('**/' + pat) may not work, because it
> > probably wants at least one directory separator to exist. In regular
> > expression terms we want '(.*/)?'.
> > I could write another globs_to_matcher() which would understand that if
> > there is no '/' in the pattern, it needs to prepend the above to the
> > regular expression.
> > Or we could break the matching into 2 styles of patterns, one with, and
> > one without paths. And then just check 2 regular expressions, one with
> > just the trailing part of the path, and the other with the full path.
> 
> The zsh manpage says
> 
>        A  pathname component of the form ‘(foo/)#’ matches
>        a path  consisting  of  zero  or  more  directories
>        matching the pattern foo.
> 
>        As  a  shorthand,  ‘**/’  is equivalent to ‘(*/)#’;
>        note that this therefore matches files in the  cur‐
>        rent directory as well as subdirectories.  [...]
> 
>        This form does not follow sym‐
>        bolic links; the alternative form ‘***/’ does,  but
>        is  otherwise  identical.   Neither of these can be
>        combined with other forms of  globbing  within  the
>        same  path segment; in that case, the ‘*’ operators
>        revert to their usual effect.
> 
> So note that **foo.c matches 'barfoo.c' (with the star just matching
> characters), but *not* bar/foo.c or bar/barfoo.c.  (Or at least it does
> in zsh, and I think also in rsync, so keeping the same behaviour is
> probably good.)
> 
> Perhaps you should split the glob on / separators, then translate each
> of them into a RE part, handling '**/' as a special case.
> 
> (I'm not suggesting to add the # syntax; it's just used in the
> explanation.)

Do we really want to handle directories differently? Last time that came
up I recall a solid trouncing in my direction for using '/' like that -
like rsync does.

Rob

-- 
GPG key available at: <http://www.robertcollins.net/keys.txt>.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20060109/0a78568b/attachment.pgp 


More information about the bazaar mailing list