Monday, November 14, 2011

Cleaning unversioned files from Subversion workspace

While git has a clean command to remove untracked files, it seems subversion doesn't support such a command.

I found Patric Fornasier's Blog explaining how to remove unversioned files in subversion and I was very happy, but it seems theat xargs can';t handle spaces in the file names and so chokes.

So I went ahead and created a simple script to handle whitepsace in the file names based on Patric's piping of commands.

#! /bin/sh

# svn stat --no-ignore | grep ^\? | cut -b 8- | xargs rm -rfv

FILES=`svn stat --no-ignore | grep ^\? | cut -b 9-`

IFS=$(echo "\n\b")

for f in ${FILES}
rm -rfv "${f}"