Index: svnadmin/hooks/pre-commit =================================================================== --- svnadmin/hooks/pre-commit +++ svnadmin/hooks/pre-commit @@ -104,6 +104,9 @@ # check for newline at end of file detect-nonewline-at-eof.sh "$REPO" "$TXN" || exit 1 +# check for empty files and directories +detect-empty.sh "$REPO" "$TXN" || exit 1 + # check for upper/lowercase filename conflicts on clients case-insensitive.py "$REPO" "$TXN" || exit 1 Index: svnadmin/hooks/scripts/detect-empty.sh =================================================================== --- svnadmin/hooks/scripts/detect-empty.sh +++ svnadmin/hooks/scripts/detect-empty.sh @@ -0,0 +1,34 @@ +#!/bin/sh +# $FreeBSD$ + +REPO=$1 +TXN=$2 + +OIFS=${IFS} +IFS=$'\n' +svnlook log -t "${TXN}" "${REPO}" | grep -q portmgr && exit 0 +for line in $(svnlook changed -t $TXN $REPO) ; do + IFS=${OIFS} + set -- $line + type=$1 + fpath=$2 + case $type in + [^AU]*) continue;; + esac + case $fpath in + */) # directory + if [ $(svnlook tree -t ${TXN} ${REPO} $fpath | wc -l) -eq 1 ]; then + echo "Some directories in your commit are empty: $fpath" 1>&2 + echo "Please fix this and try committing again." 1>&2 + exit 1 + fi + ;; + *) + if [ $(svnlook cat -t ${TXN} ${REPO} $fpath | wc -c) -eq 0 ]; then + echo "Some files in your commit are empty: $fpath" 1>&2 + echo "Please fix this and try committing again." 1>&2 + exit 1 + fi + ;; + esac +done