Is there a find incantation that would allow me to visit all directories under SVN version control? I am trying to use the execdir switch to add to the svn:ignore property in each one of these directories. Something like:

find . -type d -execdir svn propset svn:ignore -F <((svn propget svn:ignore; echo "new ignore pattern") | sort -u) .' \;

but I can't get to limit find to only SVN directories.

  • Is the problem that you have a forest of checkouts and only want to hit the checkouts, or that your checkouts have unversioned directories in them that you want to skip? – Gilles 'SO- stop being evil' Jan 7 '14 at 23:26

With older versions of svn where you had a .svn directory in each directory under revision control, you could do:

find . -name .svn -type d -prune -execdir bash -c '
  cd -P .. &&
    propset svn:ignore -F <(
      (svn propget svn:ignore; echo "new ignore pattern") | sort -u) .' bash {} \;

With the newer ones, where you only have one .svn and a sqlite3 db in there:

find . -path '*/.svn/wc.db' -execdir bash -c '
  cd -P .. &&
    sqlite3 .svn/wc.db "select local_relpath from NODES where kind == \"dir\"" |
      while IFS= read -r dir; do
        [ -d "$dir" ] &&
          propset svn:ignore -F <(
            (svn propget svn:ignore "$dir"; echo "new ignore pattern") | sort -u
          )  "$dir"
      done' bash {} \;
| improve this answer | |
  • I believe my script below should work for both old and new SVN clients though I've only tried for 1.7.9 – Marcus Junius Brutus Jan 7 '14 at 17:57
  • @MarcusJuniusBrutus, yes using svn info to check if a directory is under revision control is a more generic/saner approach (though you have issues with your shell syntax for which I add suggested an alternative). Mine above would be slightly more efficient in that it would avoid running a svn info command per directory. – Stéphane Chazelas Jan 7 '14 at 18:05

In the end, I used the following script. The folder .svn has to be explicitly excluded as svn info .svn has an exit code of 0 and confuses the script.

#!/usr/bin/env bash
if [ $# -ne 1 ]
    echo "usage is $0 <new ignore pattern>"
    for d in $(find . ! -name ".svn" -type d)
        svn info "$d" &> /dev/null
        if [ $? -eq 0 ]
            svn -q propset svn:ignore -F <((svn propget svn:ignore ; echo "$PATTERN") | sort -u) "$d"
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.