summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2020-02-12 08:34:17 -0500
committerNick Mathewson <nickm@torproject.org>2020-02-12 08:34:17 -0500
commit9b2e0604a92aa319b78f3c22227a395b83698ab0 (patch)
tree5ac93d6c9cd42a918be3b84551bb4d1ab4070274 /scripts
parentbc493ce0f2130c5f2bc37e62600c45665ffc9d57 (diff)
parent99d957696b3274a334448f066ba418b51cc887ee (diff)
downloadtor-9b2e0604a92aa319b78f3c22227a395b83698ab0.tar.gz
tor-9b2e0604a92aa319b78f3c22227a395b83698ab0.zip
Merge remote-tracking branch 'tor-github/pr/1726/head'
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/git/pre-push.git-hook9
1 files changed, 7 insertions, 2 deletions
diff --git a/scripts/git/pre-push.git-hook b/scripts/git/pre-push.git-hook
index 7b06f3734d..efa45b9860 100755
--- a/scripts/git/pre-push.git-hook
+++ b/scripts/git/pre-push.git-hook
@@ -26,7 +26,11 @@ z40=0000000000000000000000000000000000000000
upstream_name=${TOR_UPSTREAM_REMOTE_NAME:-"upstream"}
+# The working directory
workdir=$(git rev-parse --show-toplevel)
+# The .git directory
+# If $workdir is a worktree, then $gitdir is not $workdir/.git
+gitdir=$(git rev-parse --git-dir)
cd "$workdir" || exit 1
@@ -58,7 +62,8 @@ do
fi
# Call the pre-commit hook for the common checks, if it is executable
- if [ -x scripts/git/pre-commit.git-hook ]; then
+ pre_commit=${gitdir}/hooks/pre-commit
+ if [ -x "$pre_commit" ]; then
# Only check the files newly modified in this branch
CHECK_FILTER="git diff --name-only --diff-filter=ACMR $range"
# Use the appropriate owned tor source list to filter the changed
@@ -81,7 +86,7 @@ do
# We want word splitting here, because file names are space
# separated
# shellcheck disable=SC2086
- if ! scripts/git/pre-commit.git-hook $CHECK_FILES ; then
+ if ! "$pre_commit" $CHECK_FILES ; then
exit 1
fi
fi