aboutsummaryrefslogtreecommitdiffstats
path: root/tools/pre-commit
diff options
context:
space:
mode:
authorJoão Valverde <joao.valverde@tecnico.ulisboa.pt>2016-08-18 00:05:05 +0100
committerJoão Valverde <j@v6e.pt>2016-08-17 23:50:24 +0000
commit9cbcdee7538b8b22eb27e68d0697c3a15635960f (patch)
tree01ac0acec3b807eccef9b3cbd76c43fecfbf3fbd /tools/pre-commit
parente3daf4a66d5f14148494c28649fb78136807e417 (diff)
pre-commit: Make version check work with git-worktree
By disabling it outside the main working tree this time. Change-Id: I2075b07370e3cc1395c6de9695e40b0a952e3eab Reviewed-on: https://code.wireshark.org/review/17122 Petri-Dish: João Valverde <j@v6e.pt> Reviewed-by: João Valverde <j@v6e.pt>
Diffstat (limited to 'tools/pre-commit')
-rwxr-xr-xtools/pre-commit8
1 files changed, 5 insertions, 3 deletions
diff --git a/tools/pre-commit b/tools/pre-commit
index d084262fa0..35895a4cf1 100755
--- a/tools/pre-commit
+++ b/tools/pre-commit
@@ -33,7 +33,7 @@ esac
PYBIN=${WS_GITHOOK_PYTHON:-$pyvar}
# Path to hook script in the .git directory
-hook_script="$(git rev-parse --git-path hooks/pre-commit)"
+hook_script=${GIT_DIR:-.git}/hooks/pre-commit
# Always start in the root directory of the source tree, this allows for
# invocations via relative paths (such as ../tools/pre-commit):
@@ -41,8 +41,10 @@ cd "$(git rev-parse --show-toplevel)"
# Check for newer (actually, different) versions of the pre-commit script
# (but only if invoked as hook, i.e. the commit ID is not given as argument).
-if [ -z "$1" ] && ! cmp -s "$hook_script" tools/pre-commit; then
- echo "Pre-commit hook script is outdated, please update!"
+if [ -z "$1" ] && [ -f "$hook_script" ]; then
+ if ! cmp -s "$hook_script" tools/pre-commit; then
+ echo "Pre-commit hook script is outdated, please update!"
+ fi
fi
exit_status=0