Git is able to detect change in file permissions (for your reference https://medium.com/@tahteche/how-git-treats-changes-in-file-permissions-f71874ca239d). below is my code for pre-commit (git hooks).
git diff --summary | grep "mode change"
if [ $? -eq 0 ]
then
echo "file permission changed. please verify and restore the permissions"
exit 1
else
echo "no file permissions changed. Good to proceed. Keep it up"
fi
I want to detect before commit if any file permission have been changed. If file permission change is detected, then it should not commit the changes ad should throw an error.