You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@subversion.apache.org by "Feldhacker, Chris" <Fe...@principal.com> on 2010/10/07 20:29:49 UTC

Global ignores

Where can I find more complete information on global-ignores and the expected format/syntax of the patterns?

The svnbook just indicates:
The global-ignores option is a list of whitespace-delimited globs which describe the names of files and directories that Subversion should not display unless they are versioned. 
The default value is *.o *.lo *.la #*# .*.rej *.rej .*~ *~ .#* .DS_Store

At first I assumed this just performed wild-card matching, but looking at the default list within the config file that was created on my machine (Windows) I see this:

global-ignores = *.o *.lo *.la *.al .libs *.so *.so.[0-9]* *.a *.pyc *.pyo
   *.rej *~ #*# .#* .*.swp .DS_Store

Based on the presence of the "[0-9]" set, I assume something a bit more than just wild-card matching must be performed but apparently something less than full regular expressions...

The wikipedia entry for "glob" indicates this is just a generic term that refers to a limited pattern-matching facility, which seems to vary by programming language or shell, and "there is no definite syntax for globs..."


So, where can I find more complete information on the "glob" syntax that Subversion uses for the global-ignores option, and is it consistent across OSes?
Thanks!



-----Message Disclaimer-----

This e-mail message is intended only for the use of the individual or
entity to which it is addressed, and may contain information that is
privileged, confidential and exempt from disclosure under applicable law.
If you are not the intended recipient, any dissemination, distribution or
copying of this communication is strictly prohibited. If you have
received this communication in error, please notify us immediately by
reply email to Connect@principal.com and delete or destroy all copies of
the original message and attachments thereto. Email sent to or from the
Principal Financial Group or any of its member companies may be retained
as required by law or regulation.

Nothing in this message is intended to constitute an Electronic signature
for purposes of the Uniform Electronic Transactions Act (UETA) or the
Electronic Signatures in Global and National Commerce Act ("E-Sign")
unless a specific statement to the contrary is included in this message.

While this communication may be used to promote or market a transaction
or an idea that is discussed in the publication, it is intended to provide
general information about the subject matter covered and is provided with
the understanding that The Principal is not rendering legal, accounting,
or tax advice. It is not a marketed opinion and may not be used to avoid
penalties under the Internal Revenue Code. You should consult with
appropriate counsel or other advisors on all matters pertaining to legal,
tax, or accounting obligations and requirements.

Re: Global ignores

Posted by Ryan Schmidt <su...@ryandesign.com>.
On Oct 7, 2010, at 15:29, Feldhacker, Chris wrote:

> Where can I find more complete information on global-ignores and the expected format/syntax of the patterns?
> 
> The svnbook just indicates:
> The global-ignores option is a list of whitespace-delimited globs which describe the names of files and directories that Subversion should not display unless they are versioned. 
> The default value is *.o *.lo *.la #*# .*.rej *.rej .*~ *~ .#* .DS_Store

You must be reading an old version of the book; the current version shows "The default value is *.o *.lo *.la *.al .libs *.so *.so.[0-9]* *.a *.pyc *.pyo *.rej *~ #*# .#* .*.swp .DS_Store ."

http://svnbook.red-bean.com/nightly/en/svn.advanced.confarea.html#id531554


> At first I assumed this just performed wild-card matching, but looking at the default list within the config file that was created on my machine (Windows) I see this:
> 
> global-ignores = *.o *.lo *.la *.al .libs *.so *.so.[0-9]* *.a *.pyc *.pyo
>   *.rej *~ #*# .#* .*.swp .DS_Store
> 
> Based on the presence of the "[0-9]" set, I assume something a bit more than just wild-card matching must be performed but apparently something less than full regular expressions...
> 
> The wikipedia entry for "glob" indicates this is just a generic term that refers to a limited pattern-matching facility, which seems to vary by programming language or shell, and "there is no definite syntax for globs..."
> 
> 
> So, where can I find more complete information on the "glob" syntax that Subversion uses for the global-ignores option, and is it consistent across OSes?

I could not find documentation about the specifics of the glob format in the Subversion book, so I dove into the code. In subversion/libsvn/subr/svn_string.c I found the funciton svn_cstring_match_glob_list which just calls through to APR's apr_fnmatch function. And in APR's source file include/apr_fnmatch.h there is a long comment describing how it works:


/**
 * Try to match the string to the given pattern, return APR_SUCCESS if
 *    match, else return APR_FNM_NOMATCH.  Note that there is no such thing as
 *    an illegal pattern.
 *
 * With all flags unset, a pattern is interpreted as such:
 *
 * PATTERN: Backslash followed by any character, including another
 *          backslash.<br/>
 * MATCHES: That character exactly.
 * 
 * <p>
 * PATTERN: ?<br/>
 * MATCHES: Any single character.
 * </p>
 * 
 * <p>
 * PATTERN: *<br/>
 * MATCHES: Any sequence of zero or more characters. (Note that multiple
 *          *s in a row are equivalent to one.)
 * 
 * PATTERN: Any character other than \?*[ or a \ at the end of the pattern<br/>
 * MATCHES: That character exactly. (Case sensitive.)
 * 
 * PATTERN: [ followed by a class description followed by ]<br/>
 * MATCHES: A single character described by the class description.
 *          (Never matches, if the class description reaches until the
 *          end of the string without a ].) If the first character of
 *          the class description is ^ or !, the sense of the description
 *          is reversed.  The rest of the class description is a list of
 *          single characters or pairs of characters separated by -. Any
 *          of those characters can have a backslash in front of them,
 *          which is ignored; this lets you use the characters ] and -
 *          in the character class, as well as ^ and ! at the
 *          beginning.  The pattern matches a single character if it
 *          is one of the listed characters or falls into one of the
 *          listed ranges (inclusive, case sensitive).  Ranges with
 *          the first character larger than the second are legal but
 *          never match. Edge cases: [] never matches, and [^] and [!]
 *          always match without consuming a character.
 * 
 * Note that these patterns attempt to match the entire string, not
 * just find a substring matching the pattern.
 *
 * @param pattern The pattern to match to
 * @param strings The string we are trying to match
 * @param flags flags to use in the match.  Bitwise OR of:
 * <pre>
 *              APR_FNM_NOESCAPE       Disable backslash escaping
 *              APR_FNM_PATHNAME       Slash must be matched by slash
 *              APR_FNM_PERIOD         Period must be matched by period
 *              APR_FNM_CASE_BLIND     Compare characters case-insensitively.
 * </pre>
 */


In svn_cstring_match_glob_list, Subversion calls apr_fnmatch with no flags set.