#!/bin/bash # # svnignore.sh - helper app for managing svn:ignore properties # Copyright (C) 2007 Clifford Wolf # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. if [ "$SVNIGNORE_EDIT" = "add" ]; then echo "$SVNIGNORE_DATA" | while read x; do if [ -n "$x" ] && ! grep -Fxq "$x" "$1"; then echo "$x" >> "$1" fi done exit 0 fi if [ "$SVNIGNORE_EDIT" = "del" ]; then tmp=`mktemp` echo "$SVNIGNORE_DATA" | while read x; do grep -Fxv "$x" "$1" > $tmp grep . $tmp > "$1" done rm $tmp exit 0 fi mode="$1"; shift export SVNIGNORE_DATA="" add_data() { if [ "$SVNIGNORE_DATA" = "" ]; then SVNIGNORE_DATA="$1" else SVNIGNORE_DATA="$SVNIGNORE_DATA $1" fi } for x in "$@"; do if [[ "$x" == */* ]]; then ( cd "${x%/*}" && $0 $mode "${x##*/}"; ) else add_data "$x" fi done case "$mode" in add|radd) export SVNIGNORE_EDIT="add" ;; del|rdel) export SVNIGNORE_EDIT="del" ;; *) echo "Usage: $0 { add | radd | del | rdel } pattern(s)" >&2 exit 1 ;; esac if [ -n "$SVNIGNORE_DATA" ]; then if [ "$mode" = "radd" -o "$mode" = "rdel" ]; then find $PWD -type d | grep -Ev '/\.svn($|/)' | while read dn; do svn pe --editor-cmd "$0" svn:ignore "$dn"; done else svn pe --editor-cmd "$0" svn:ignore $PWD fi fi exit 0