[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

[PATCH] match_glob_list ! enhancement

From: Kyle McKay <mackyle_at_tigris.org>
Date: 2006-11-26 07:09:50 CET

[[[
Add support for negation (!) in pattern glob lists

* subversion/libsvn_subr/svn_string.c
   (svn_cstring_match_glob_list): Add support for negation patterns
]]]

The attached patch adds support for exception globs in both the
svn:ignore property and the global-ignores Config option.

Currently if you want to ignore all files matching a pattern except
for a few, there's no simple way to do this. See the messages below
from the users list for an example of why you might want to do this:

http://subversion.tigris.org/servlets/ReadMsg?listName=users&msgNo=15469

http://subversion.tigris.org/servlets/ReadMsg?listName=users&msgNo=15480

This patch provides the following behavior for the global-ignores and
svn:ignore settings:

1) The total list of ignore patterns is the contents of global-
ignores FOLLOWED BY the contents of the svn:ignore property (this is
NOT a change, but is important to the following steps).

2) The result is initially set to NOT_MATCHED.

3) ALL ignore patterns are then examined in order. (This is a change
-- previously the first match would have prevented the rest of the
patterns from being examined.)

4) As a special case, if the ignore pattern is a single exclamation
point ('!'), the result is changed to NOT_MATCHED. In other words, a
"!" pattern is treated as though it were actually "!*". This special
case is for CVS compatibility.

5) An ignore pattern that starts with "\\" or "\!" has the leading
backslash stripped before doing the glob compare. If such a pattern
matches, the result is changed to MATCHED.

6) An ignore pattern that starts with exclamation point ('!') has the
exclamation point stripped before doing the glob compare. If such a
pattern matches, the result is changed to NOT_MATCHED.

7) All other ignore patterns are used as-is. If such a pattern
matches, the result is changed to MATCHED.

8) The end result is that the last matching glob pattern wins and if
that pattern was preceded by a '!' then the result is NOT_MATCHED.

So to do what Richard S. Hall wanted (see the above mentioned
messages from the users list), the svn:ignore property on his
directory could be set to:

*
!example

Which means that everything except example would be ignored.

Obviously this change is not 100% backwards compatible. If you have
an existing ignore pattern that starts with "!", "\!" or "\\" it will
be interpreted differently after this patch. Such patterns would
need to have a backslash added to the beginning of them to regain
their prior meaning after this patch. Note that other ignore
patterns starting with a '\' character retain their existing meanings.

The '!' character was chosen based on CVS usage so that a "!" pattern
would accomplish the same thing in Subversion as it does in CVS (i.e.
resetting the ignore list).

Kyle

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Received on Sun Nov 26 07:10:21 2006

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.