Improve git hook to remove invalid links

In case a file is moved to another location this change will most likely
end in a dangling link in the home-dir. This change fixes this by
removing links automatically which are off because the target-file has
been moved to another location.
This commit is contained in:
2025-09-09 00:57:17 +02:00
parent 0fb4c5da60
commit ff01db14f4

View File

@@ -46,7 +46,7 @@ That will remove the links pre-commit.
cat <<EOF > .git/hooks/pre-commit
#!/usr/bin/env bash
set -e
git status --short | grep -E '^D' | sed s/...// | while read f
git status --short | grep -E '^D|^R' | sed 's/...//;s/ -> .*//' | while read f
do
test -L "\$HOME/\$f" && rm "\$HOME/\$f"
done