svnignore v 1.0.0-beta 8 November 2009

1. INTRODUCTION

svnignore is a command-line utility to simplify working with svn ignore lists.

When your source code repository is configured with neat ignore lists, svn status should display only the files that have changed, or new files that you have added. All the build files and execution artefacts will be ignored. This makes it very easy to see which changes you have made, but more importantly, it makes it much simpler to see which files should belong to the repository, but don't.

If you're like me, you often forget to add a new file to the repository, and only realise this omission when trying to build the code on another machine. With ignore lists, when you run 'svn status', you see exactly what has been modified or added.

Of course, if you've made lots of changes, you might still miss a line starting with a ?. Here svnignore is very useful also: calling 'svnignore' without options shows all the files that are unknown - neither part of the repository nor ignored.

As a rule of thumb, I try to have no unknown files in my repository at all. Any unknown files are either added to the repository, if they're important (svn add FILE), or ignored (svnignore -a FILE).

As a special bonus, if I want to ignore all the unknown files, I can do it in one command: svnignore -a. But more about this under usage.

2. LICENSE

The MIT License

Copyright (c) 2009 Craig Mason-Jones

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

3. INSTALLATION

At the moment svnignore still has to be built from the source. It's not a very complicated source, consisting as it does of a single file! The reason the source file is so small is that it utilizes a number of other libraries, which makes the work really easy:

3.1 DEPENDENCIES

You will need the following libraries to build svnignore

3.1.1 APR

The apache portable runtime can be downloaded from http://apr.apache.org. More simply, install with 'sudo apt-get install libapr1-dev'. We need the development version, since we are developing against it.

3.1.2 libsvn

I installed libsubversion on my Ubuntu box with 'sudo apt-get libsvn-dev'. We need the development version since we will be building against it.

3.1.3 libsvncpp

SvnCpp is a c++ wrapping around the subversion libraries. It is actually a sub-section of the RapidSvn code, so if you're particularly enthusiastic, you can checkout RapidSvn and find the svncpp directory, and build that separately from there. (For some reason, this is what I had to do under Ubuntu 9.04, but it could well have been an obscurity of my box.) Under Ubuntu 9.10, I used 'sudo apt-get install libsvncpp-dev'. Again, the dev package is required since we are building against it.

You can find a fuller discussion on doing this on a Mac under BUILDING ON MAC.

3.2 BUILDING FROM DISTRIBUTION

First, you will need to download the distrubiton: https://sourceforge.net/projects/svnignore/files/svnignore-1.0.0-beta.tar.gz/download

Building from the Distribution should be as simple as building any autoconf-configured distribution:

$ tar -xvzf svnignore-1.0.0-beta.tar.gz
$ cd svnignore-1.0.0-beta
$ ./configure && make
$ sudo make install

3.3 BUILDING FROM SUBVERSION

To build the full system from subversion, you will need to checkout the repository:

$ svn co https://svnignore.svn.sourceforge.net/svnroot/svnignore/trunk svnignore --username [YOUR_USERNAME] --password [YOUR_PASSWORD]
$ cd svnignore
$ aclocal
$ automake --add-missing
$ autoconf
$ ./configure ∓& make
$ sudo make install

Note that you need the auto-tools when building from the repository. I've also left some files out (that automake will add), since it seems silly to put them into the repository if automake can provide them.

3.4 BUILDING ON MAC

This is the guidance for installing on Mac OS X (Snow Leopard, though it should work on any other as well).

3.4.1 DEPENDENCIES

apr

I guess you can download and install apr from sources. If you're using MacPorts, you can probably also use 'sudo port install apr'.

svn

Does svn come with OSX? If not, you should be able to install it from source. Sorry, both apr and svn are just on my system, so I'm not too sure how they got there, or if I installed / built them at some point.

svncpp

A build / port of libsvncpp doesn't exist for Mac, and isn't available in MacPorts. However, it's quite possible to build the parts of it that we require:

  1. Download rapidsvn package from: http://www.rapidsvn.org/download/release/0.12/rapidsvn-0.12.0-1.tar.gz
  2. Untar to a working directory (let's say /opt/src):
    $ mv ~/Downloads/rapidsvn-0.12.0-1.tar.gz /opt/src
    (you will need the appropriate permissions on /opt/src)
    $ cd /opt/src
    $ tar -xvzf rapidsvn-0.12.0-1.tar.gz
    $ cd rapidsvn-0.12.0-1
    $ ./configure
    $ make

    NOTE: this make will fail - this is because there seems to be a problem building rapidsvn on Mac, but this needn't concern us: we're only interested in the svncpp library, which will have succeeded (at least, it did for me :-)

  3. Install the svncpp library
    $ cd src/svncpp
    $ sudo make install

3.4.2 BUILDING svnignore ON MAC

After you've install libsvncpp using the instructions under DEPENDENCIES above, you will need to tell the svnignore configure script where the svncpp include files are. I unpacked my rapidsvn to /opt/src/rapidsvn-0.12.0-1, so the configure command I used with svnignore was

$ ./configure --with-svncpp-include=/opt/src/rapidsvn-0.12.0-1/include

A warning here: you need to specify the include directory as an absolute path. Don't use ../src/rapidsvn-0.12.0-1/include, for instance - the build won't work.
(The configure script can find the svncpp library since we have installed it when we did the 'sudo make install' in the src/svncpp directory of rapidsvn.)

After this:

$ make
$ sudo make install

and svnignore will (hopefully) be working on your Mac.

4. USAGE

Once installed, you can use svnignore from the command line by typing 'svnignore'.

svnignore performs one of five functions:

  • listing unknown files in a repository (no option command),
  • adding files to the list of ignored files in a repository (-a command),
  • list ignored files in a repository directory (-l command) (*)
  • editing the list of ignored files in a repository directory (-e command) (*)
  • show svnignore help

(*) these last two functions are actually just a wrapper around 'svn propget svn:ignore' and 'svn propedit svn:ignore' respectively.

4.1 LISTING UNKNOWN FILES

By default, svnignore will list all unknown files in a repository, recursing through the repository directory. Each file is listed on a separate line preceded by a question mark, as though part of an 'svn status' command.

4.1.1 LISTING OPTIONS

When listing files, svnignore supports the following options:

-d,--dir [DIRECTORY]

svnignore works with the repository in the given DIRECTORY. Without this option, svnignore works from the current working directory.

-N,--no-recurse

svnignore only shows unknown files in the current directory, and does not recurse into subdirectories.

-q,--quiet

Each file is printed on a separate line without a preceding question mark.

4.2 ADDING IGNORED FILES

When adding ignored files, use the -a or --add command line options. Adding ignore files supports two modes: 'pattern' mode and 'default' mode.

4.2.1 PATTERN ADDING MODE

The pattern mode is used by listing the file patterns to ignore. For example:

svnignore -a test.output test.log

Will add test.output and test.log to the ignore list.

You can also use patterns:

svnignore -a *.log

Note that the pattern mode doesn't add the pattern to the ignore list, but it adds everything that matches the pattern right now. In other words, if in future a new file called future_file.log is added to the directory, it will be unknown, not ignored, until you add it to the ignore list itself.

4.2.2 DEFAULT ADDING MODE

In default adding mode, all the listed unknown files are added to the svn:ignore list. This can make life easy, but be sure you're not adding something that you didn't mean to. To use the default mode, simply provide no patterns:

svnignore -a

4.2.3 ADDING OPTIONS

Whe adding files to be ignored, svnignore supports the following options:

-d,--dir [DIRECTORY]

svnignore works with the repository in the given DIRECTORY. Without this option, svnignore works from the current working directory.

-N,--no-recurse

svnignore only adds unknown files in the current directory, and does not recurse into subdirectories. This option is ignored if patterns were provided.

-q,--quiet

svnignore prints no output.

4.3 LIST IGNORED FILES

To list all the files that are ignored in a particular directory, use:

svnignore -l

The list command can take the -d [DIRECTORY] option as described under 4.1.1

Note that the list command is just a wrapper around the svn command line option: svn propget svn:ignore

4.4 EDIT IGNORED FILES LIST

To edit the list of files that are ignored in a particular directory, use:

svnignore -e

The edit command can take the -d [DIRECTORY] option as described under 4.1.1

Note that the edit command is just a wrapper around the svn command line option: svn propedit svn:ignore. It therefore requires the same environment variables set that svn requires.

4.5 HELP

To view the help for svnignore use the -?, --help option:

svnignore -?

5. CREDITS

See the AUTHORS file in the distribution.