Why doesn’t Subversion add respect svn:ignore?

I use Subversion for source control on my personal projects, and I’ve got to say it’s so easy to set up and use there’s no excuse for not using source control.  There’s one thing that really bothers me though.

When setting up a .NET project, I have a few steps I have to follow due to the small clashes with the default project templates I have.  I have to rearrange a few files after VS creates the project, then I get to adding files.  One of the first things I do is set up svn:ignore on each directory; I want it to ignore *.suo, *.user, bin, obj, and occasionally a few other files/directories.  Every time I do this, I double-check with svn status to make sure that nothing I don’t want is showing up, then I feel like it’s safe to do svn add directory.  I mean, I told svn I’d like to ignore those files, right? so it should ignore them, right?  Wrong.

So, for every project, I have to either add every file then use "svn delete –force" to remove just the files that I told it to ignore in the first place, or I have to manually add every file and directory in my project, being careful not to add anything that I’m ignoring.  This is frustrating, to say the least.  At first, I thought it was because the directory wasn’t yet under source control or the svn:ignore setting hadn’t been committed, but I’ve tried committing all directories and property changes first to no avail.

The part of it that’s most aggravating is the fact that "svn add" has a –no-ignore argument; what on Earth is it there for if the command already disregards svn:ignore?  I hope I’m just missing something stupid; I’m going dig around the internet and see what I can find.

*update* According to a blog I found, it has to do with the OS doing wildcard expansion, not Subversion.  That actually makes a lot of sense, because the OS has no idea about svn:ignore.  Apparently the default add behavior is to act as if –noignore is specified (which seems dumb to me), so when you pass it a list of files it just adds all of them.  The solution?  Set up the ignore traits on the directory, then use "svn add –force ."  I have no idea why the –force is required.  It looks like this got added to the SVN book very recently.

One thought on “Why doesn’t Subversion add respect svn:ignore?

  1. I think –force is needed when current working directory has already been added to svn, otherwise it’s not necessary.

Comments are closed.