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:
@@ -46,7 +46,7 @@ That will remove the links pre-commit.
|
|||||||
cat <<EOF > .git/hooks/pre-commit
|
cat <<EOF > .git/hooks/pre-commit
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -e
|
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
|
do
|
||||||
test -L "\$HOME/\$f" && rm "\$HOME/\$f"
|
test -L "\$HOME/\$f" && rm "\$HOME/\$f"
|
||||||
done
|
done
|
||||||
|
|||||||
Reference in New Issue
Block a user