This post is from the CollabNet VersionOne blog and has not been updated since the original publish date.
Repository Dictated Configuration — Part 3 of 3: Global Ignores
Welcome to the last topic in my three part series on repository dictated configuration (RDC). In part 2 we talked about the new svn:auto-props property. Today we’ll discuss the other new inherited property that involves RDC,
Ignoring Unversioned Items Before 1.8
Once again, this is just a quick refresher, if none of this sounds familiar, then give this section of the Version Control with Subversion book a quick read.
Up until 1.7 there were two ways to prevent the svn add and import subcommands from adding certain items we didn’t want to place under version control (as well as making svn status ignore such unversioned items). Both of these methods still exist in 1.8:
First, is the global-ignores runtime configuration option:
### Set global-ignores to a set of whitespace-delimited globs ### which Subversion will ignore in its 'status' output, and ### while importing or adding files and directories. ### '*' matches leading dots, e.g. '*.rej' matches '.foo.rej'. global-ignores = *.o *.lo *.la *.al .libs *.so *.so.[0-9]* *.a *.pyc *.pyo __pycache__ *.rej *~ #*# .#* .*.swp .DS_Store
Second is the
svn:ignore versioned property. This property, which can be set on any directory, has a value which is expected to be a newline-delimited list of file patterns that Subversion should ignore. These patterns are appended to any ignore patterns defined in the runtime configuration.
The svn:global-ignores Property
In Subversion 1.8, these existing ignore mechanisms are joined by the
svn:global-ignores property. This new property is essentially a more powerful version of the
svn:ignore property. Like the earlier property,
svn:global-ignores can only be set on a directory and should have as a value a set of newline delimited file patterns 1. These patterns are appended to any patterns defined in the global-ignores runtime configuration option together with any applicable
svn:ignore defined patterns, to determine ignorable items. Unlike
svn:ignore however, the
svn:global-ignores property is inheritable and applies to all paths under the directory on which the property is set 2, not just the immediate children of the directory.
The following short example demonstrates how this new property works.
svn:global-ignores patterns are themselves ignored (as are the runtime config global-ignores and the svn:ignore property) when the
--no-ignore option is used. So to see all unversioned items in our working copy, we pass that option to the status subcommand:
1.8.0>svn st --no-ignore ? calc\trunk\doc\README.foo I calc\trunk\file.bar I calc\trunk\file.baz I calc\trunk\file.foo I calc\trunk\file.qux
Here we see that four files are being ignored, while one (README.foo) is unversioned by doesn’t match any ignore patterns. First, let’s look at the svn:ignore property on calc/trunk:
1.8.0>svn pg svn:ignore -vR Properties on 'calc\trunk': svn:ignore *.foo *.moo
That accounts for file.foo. Then we check our runtime configuration and find this snippet:
### Set global-ignores to a set of whitespace-delimited globs ### which Subversion will ignore in its 'status' output, and ### while importing or adding files and directories. ### '*' matches leading dots, e.g. '*.rej' matches '.foo.rej'. global-ignores = *.qux
That accounts for file.qux. But what about file.bar and file.baz? There can be only one option left, the new svn:global-ignores property. Sure enough, on the root of the repository we find that property, with patterns that account for the remaining two ignored files:
1.8.0>svn pg svn:global-ignores -v --show-inherited-props calc\trunk Inherited properties on 'calc\trunk', from '.': svn:global-ignores *.bar *.baz
As we discussed in part 2 regarding svn:auto-props, svn:global-ignores should be set as high up the repository tree as is feasible. And it deserves mention one final time: Be sure you understand the limitations of inherited properties discussed in part 1 — and thus the limitations of RDC via
- It was intended that the ignore patterns in the
svn:global-ignoresproperty could be delimited with any whitespace (similar to the global-ignores runtime configuration option), not just newlines (as with the
svn:ignoreproperty), but there is a bug in 1.8.0 and only newline separated patterns work. ↩
- The caveats I mentioned about inherited properties in part 1 still apply of course! ↩