4

I have a big directories tree involving many subdirectories. In many of the directories I used the svn propedit svn:ignore ., and ignored files and/or directories in the given directory. Now, I want to ignore, in all subdirectories the directories called foo. In this answer, it is suggested to invoke:

svn propset --recursive svn:ignore foo .

from the tree's root. The problem is, that once invoking this, it overrides all predefined ignores in the various subdirectories - and this is undesired. Essentially I would like to append to the ignore list of each directory in the tree, a line with entry foo in it. Does SVN supports this kind of action? If not, then I was thinking of scripting this task, and add to the file dir-prop-base (which seems to hold the ignore list) in each ./sub/directory/.svn (where . is the tree's root) the needed line. Is it safe to do it?, namely manually mess with .svn content?

Community
  • 1
  • 1
Dror
  • 12,174
  • 21
  • 90
  • 160

1 Answers1

6

I recommend using a bash script for this task. But instead of manipulating the files directly, stay with the svn command tools. This solution is simple and safe. The following script might do the job, if executed with find -type d ! -path "*/.svn*" -exec /tmp/add_svn_ignore.sh {} + from the working directory:

#! /bin/bash
ignore="foo"
for pathname in "$@"; do
    lines="$( svn propget svn:ignore "$pathname" )"
    grep -F -x -q "$ignore" - <<< "$lines" ||
    svn propset svn:ignore "$lines"$'\n'"$ignore" "$pathname"
done
nosid
  • 48,932
  • 13
  • 112
  • 139
  • Thanks for your reply! I tried it and it seems like the `find` command you suggested is wrong, I get `find: illegal option` error for each letter of "type" and finally `find: d: No such file or directory`. I'm using OS X in case it matters. Thanks again. – Dror May 22 '12 at 06:31
  • 1
    I am using _GNU find_. On OS X, _find_ requires a path before the first option. Try `find . -type d ...` instead of `find -type d ...`. – nosid May 22 '12 at 06:37