I wish to add a line to my svn:ignore for, say, the pattern "*.bak".

I'd like this to be done recursively for the whole tree. I can do this as described here:

svn propset svn:ignore '*.bak' . --recursive

However I found that this method will remove any existing ignore rules I have.

Is there some way I can recursively add a new line to the svn:ignore property without removing what is there already?

Many of my subdirectories already have multiple ignore patterns, and I don't want all subdirectories to have the same ignore patters. I'd just like to add a new pattern to every directory.

I hope that is all clear. Thanks for any help!

4

There are 4 best solutions below

2
On

To ignore more than one 'type' or 'pattern' you need to supply a file

svn propset svn:ignore -F patterns.txt

So, to do what you want you'll need to take it one step further and get the prop list, append to it with a temporary file, etc.

Either that or you could write a web client that talks directly to the SVN/Dav server, gets the props and sets them.

2
On

svn propedit edit properties

0
On

The answer given by juj works but will only add the ignore patterns for the directories where such a file already exists so you may have to re-run the script in the future. Also, you get the specific file name in the svn:ignore property (as opposed to the pattern).

An alternative solution that doesn't have the above issues is provided in my following answer: unix.stackexchange post.

2
On

Use find command:

    find . -name "*.bak" \
       -execdir bash -c 'svn -q propset svn:ignore -F <((svn propget svn:ignore; basename "{}") | sort -u) .' \;

I use sort -u for consistency and uniqueness.