Login | Register
My pages Projects Community openCollabNet

Discussions > dev > Re: ignore globbing patterns are not anchored

fsvs
Discussion topic

Back to topic list

Re: ignore globbing patterns are not anchored

Author pmarek
Full name P.Marek
Date 2006-10-27 04:46:45 PDT
Message > Am Sonntag, 15. Oktober 2006 08:24 schrieb Philipp Marek:
>> Do you have a patch that does all this, maybe :-?
> Again it took significantly longer than I had anticipated (partly caused
> by the fact that I forgot to take my notebook power supply with me last
> weekend and could not work while being on the train...), but here it is.
Having no power tends to be disturbing, yes :-)

> I split my changes into two small patches actually, as I added two
> features which are pretty much unrelated.
>
> Consider both patches to be a request for comments. :-)
Ok, you wanted that ...

> dir_ignore
> **********
> changes the matching behaviour of fsvs glob-like filename patterns. With
> dir_ignore,
I believe that dir_ignore is just the name of the patch?

> a glob-like pattern matches the full directory-/filename
> instead of just a prefix as it currently does.
> An exception are patterns which end with a slash, which will match the
> exact full directory-/filename without the slash as well as everything
> the pattern is a prefix of. This is used to exclude directories and their
> contents.
>
> Examples:
>
> ./**/tmp
> will match all files in any subdirectory which are exactly called "tmp".
> ./**/tmp**
> mimics the above pattern's current semantics: match any file or
> directory whose name starts with "tmp".
> ./**/tmp/
> will match all files in all directories which are called "tmp" and the
> directory itself.
> ./**/tmp/**
> will match all files in all directories which are called "tmp" but NOT
> the directory itself, the empty directory "tmp" won't be ignored but
> will be included in the directory
Ok, that's fine.

> This patch works by anchoring all globbing patterns at the end of the
> line, except if they end with a slash. In this case, the PCRE is closed
> with '($|/)' which causes an exact match of the directory name to be
> ignored and everything below the directory as well.
>
> My first try was to simply anchor all patterns except patterns ending
> in '/', but that caused all directories I wanted to ignore to be
> included. (However, without their contents.) It would have been neccessary
> to explicitely exclude the directory as well, so I changed to behaviour
> to the one explained above.
>
> This feature has one drawback: ./**/tmp/ will also ignore all FILES which
> are exactly called "tmp", not only the dirs. :-/
That's not so nice.
How about changing the path generation to include a "/" at the end for
directories? Then this would work, too -- and the pattern would not have
to be "(/|$)".

> However, I consider the
> overall matching behaviour with this patch to be a huge improvement over
> the current situation.
That's right.


> escape_mode
> ***********
> adds support for escaping characters with a backslash '\' and for bracket
> expressions (character classes). This implementation requires the RE to
> be interpreted as a PCRE, it's not correct if the resulting RE is
> interpreted as a POSIX RE.
>
> You can now write stuff like
>
>
> ./**/\[is[_.-]this[​_.-]an_intereres*tin​g\*filename\?[]!]?​
>
> and it should work as expected.
Note that I didn't know what to expect from that for some time ;-)

> I implemented this as altough any pattern
> can be directly written as an PCRE of course, a globbing pattern is
> simpler to read if you eg. just want to use straight character classes.
> Additionally, much more people know how to use globbing patterns than
> PCREs. While the basics of PCREs are also simple and straight forward
> most people do not seem to know that and appear to be frightened by them.
That's correct.

> I'd love to hear your opinion about and your experiences with these small
> patches! :-)
I think that they are a big step forward. I'll give them a try ASAP.
Thank you for this work!


Regards,

Phil

« Previous message in topic | 7 of 11 | Next message in topic »

Messages

Show all messages in topic

ignore globbing patterns are not anchored Gunter Ohrner <G dot Ohrner at post dot rwth-aachen dot de> Gunter Ohrner <G dot Ohrner at post dot rwth-aachen dot de> 2006-10-10 14:48:18 PDT
     Re: ignore globbing patterns are not anchored pmarek P.Marek 2006-10-11 08:19:37 PDT
         Re: ignore globbing patterns are not anchored Gunter Ohrner <G dot Ohrner at post dot rwth-aachen dot de> Gunter Ohrner <G dot Ohrner at post dot rwth-aachen dot de> 2006-10-13 12:15:41 PDT
             Re: ignore globbing patterns are not anchored pmarek P.Marek 2006-10-14 23:24:03 PDT
                 Re: ignore globbing patterns are not anchored Gunter Ohrner <G dot Ohrner at post dot rwth-aachen dot de> Gunter Ohrner <G dot Ohrner at post dot rwth-aachen dot de> 2006-10-15 08:03:09 PDT
                 Re: ignore globbing patterns are not anchored Gunter Ohrner <G dot Ohrner at post dot rwth-aachen dot de> Gunter Ohrner <G dot Ohrner at post dot rwth-aachen dot de> 2006-10-26 09:56:29 PDT
                     Re: ignore globbing patterns are not anchored pmarek P.Marek 2006-10-27 04:46:45 PDT
                         Re: ignore globbing patterns are not anchored pmarek P.Marek 2006-10-27 05:13:19 PDT
                         Re: ignore globbing patterns are not anchored Gunter Ohrner <G dot Ohrner at post dot rwth-aachen dot de> Gunter Ohrner <G dot Ohrner at post dot rwth-aachen dot de> 2006-10-27 12:38:18 PDT
                     Re: ignore globbing patterns are not anchored pmarek P.Marek 2006-10-27 05:13:19 PDT
                         Re: ignore globbing patterns are not anchored Gunter Ohrner <G dot Ohrner at post dot rwth-aachen dot de> Gunter Ohrner <G dot Ohrner at post dot rwth-aachen dot de> 2006-10-27 12:41:41 PDT
Messages per page: