subversion-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ryan Schmidt <>
Subject Re: Global ignores
Date Fri, 08 Oct 2010 02:07:40 GMT
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

> 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.

View raw message