Initial commit.
This commit is contained in:
31
etckeeper/pre-commit.d/20warn-problem-files
Executable file
31
etckeeper/pre-commit.d/20warn-problem-files
Executable file
@@ -0,0 +1,31 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
# (Note that when using this, the find expression must end with
|
||||
# -print or -exec, else the excluded directories will actually be
|
||||
# printed!)
|
||||
NOVCS='. -path ./.git -prune -o -path ./.bzr -prune -o -path ./.hg -prune -o -path ./_darcs -prune -o'
|
||||
|
||||
if [ "$VCS" = bzr ] || [ "$VCS" = darcs ]; then
|
||||
special=$(find $NOVCS ! -type d ! -type f ! -type l -print) || true
|
||||
hardlinks=$(find $NOVCS -type f ! -links 1 -print) || true
|
||||
elif [ "$VCS" = hg ]; then
|
||||
special=$(find $NOVCS ! -type d ! -type f ! -type l -print) || true
|
||||
hardlinks=$(find $NOVCS -type f ! -links 1 -exec hg status {} \; -print) || true
|
||||
elif [ "$VCS" = git ]; then
|
||||
special=$(find $NOVCS ! -type d ! -type f ! -type l -exec git ls-files --exclude-standard --cached --others {} + -print) || true
|
||||
hardlinks=$(find $NOVCS -type f ! -links 1 -exec git ls-files --exclude-standard --cached --others {} + -print) || true
|
||||
else
|
||||
special=""
|
||||
fi
|
||||
|
||||
if [ -n "$special" ] && [ -z "$AVOID_SPECIAL_FILE_WARNING" ]; then
|
||||
echo "etckeeper warning: special files could cause problems with $VCS:" >&2
|
||||
echo "$special" >&2
|
||||
fi
|
||||
if [ -n "$hardlinks" ] && [ -z "$AVOID_SPECIAL_FILE_WARNING" ]; then
|
||||
echo "etckeeper warning: hardlinked files could cause problems with $VCS:" >&2
|
||||
echo "$hardlinks" >&2
|
||||
fi
|
||||
|
||||
true
|
||||
Reference in New Issue
Block a user