Debian Codegraph @

pre-commit.d/20warn-problem-files

raw
1 #!/bin/sh
2 set -e
3
4 exclude_internal () {
5 grep -E -v '(^|/)(\.git|\.hg|\.bzr|_darcs)/'
6 }
7
8 if [ "$VCS" = bzr ] || [ "$VCS" = darcs ]; then
9 special=$(find . ! -type d ! -type f ! -type l | exclude_internal) || true
10 hardlinks=$(find . -type f ! -links 1 | exclude_internal ) || true
11 elif [ "$VCS" = hg ]; then
12 special=$(find . ! -type d ! -type f ! -type l | exclude_internal) || true
13 hardlinks=$(find . -type f ! -links 1 -exec hg status {} \; | exclude_internal ) || true
14 elif [ "$VCS" = git ]; then
15 special=$(find . ! -type d ! -type f ! -type l -exec git ls-files --exclude-standard --cached --others {} + | exclude_internal) || true
16 hardlinks=$(find . -type f ! -links 1 -exec git ls-files --exclude-standard --cached --others {} + | exclude_internal) || true
17 else
18 special=""
19 fi
20
21 if [ -n "$special" ] && [ -z "$AVOID_SPECIAL_FILE_WARNING" ]; then
22 echo "etckeeper warning: special files could cause problems with $VCS:" >&2
23 echo "$special" >&2
24 fi
25 if [ -n "$hardlinks" ] && [ -z "$AVOID_SPECIAL_FILE_WARNING" ]; then
26 echo "etckeeper warning: hardlinked files could cause problems with $VCS:" >&2
27 echo "$hardlinks" >&2
28 fi
29
30 true