meta:hooks:pre-commit: Check for broken symlinks

Check that added/moved symlinks are not broken.
This commit is contained in:
2022-05-21 13:23:22 +02:00
parent d136658888
commit 6c802cc70f

View File

@@ -44,3 +44,16 @@ fi
if ! git diff-index --check --cached $against --; then
die
fi
# Check that added symlinks are not broken
git diff --staged --name-only --diff-filter=AR $against \
| {
broken=0
while read -r line; do
if [ -h "$line" ] && [ ! -e "$line" ]; then
broken=1
printf "%s\n" "$line: Broken symlink" >&2
fi
done
(( ! broken )) || die
}