Append directories to ignored list in SVN

[亡魂溺海] 提交于 2019-12-23 11:59:57

问题


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?


回答1:


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


来源:https://stackoverflow.com/questions/10648586/append-directories-to-ignored-list-in-svn

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!