misc: Allow Git pre-commit hook to be run from any working directory.

I have an alias to the pre-commit script which I sometimes run manually
e.g. to go over all lint errors.

Before this fix, pre-commit could only be run from $VTTOP.
This commit is contained in:
Michael Berlin 2015-12-07 18:41:07 -08:00
Родитель 3bd15c1368
Коммит 0787d482b4
1 изменённых файлов: 3 добавлений и 2 удалений

Просмотреть файл

@ -5,8 +5,9 @@ set -e
# This is necessary because the Emacs extensions don't set GIT_DIR.
if [ -z "$GIT_DIR" ]; then
GIT_DIR="$(pwd)/.git"
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
GIT_DIR="${DIR}/.."
fi
for hook in $GIT_DIR/../misc/git/hooks/*; do
$hook
$hook
done