Thursday, July 26, 2007

Small script for ignoring files in Subversion

Subversion takes a slightly different, and more general approach to ignoring files and directories. Unlike the .cvsignore with CVS, SVN uses its property mechanism. I just wrote a small script to help me add ignores:

#!/bin/bash

TMPFILE=.newcvsignore

rm -f ${TMPFILE}

# add whatever already is ignored
for i in `svn propget svn:ignore`; do
echo "Adding $i"
echo $i >> ${TMPFILE}
done

# add new things to ignore
for i in $*; do
echo "Adding $i"
echo $i >> ${TMPFILE}
done

svn propset svn:ignore -F ${TMPFILE} .

rm -f ${TMPFILE}

There might be an easier trick to do this, but now at least I have this nice one-liner:

svnignore somefile