Alternate glob matcher for .bzrignore

John Arbash Meinel john at arbash-meinel.com
Sun Jan 8 23:29:02 GMT 2006


Robert Collins wrote:
> 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
> 

I think I was trying to follow rsync usage rather than zsh usage. Where
'**' is used to include directories and '*' just matches within a directory.
So you would end up with 'baz/**/*.txt' to match all files underneath
baz that end in *.txt.
But you would also have 'baz/**.txt' which would do the same thing.

I would rather not special case '**/' instead of just handling '**' as
the operator. But I'm open to the idea of what operators we want to
support. I guess the problem is that different programs disagree on the
exact definitions. * and ? are pretty standard (though do they match
paths or not?), but ** seems interpreted different ways by zsh and rsync.

John
=:->


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 256 bytes
Desc: OpenPGP digital signature
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20060108/991e73bc/attachment.pgp 


More information about the bazaar mailing list