diff --git a/tools/git/hooks/commit-msg b/tools/git/hooks/commit-msg index c6ebcf342f17..4f7a69951752 100644 --- a/tools/git/hooks/commit-msg +++ b/tools/git/hooks/commit-msg @@ -33,11 +33,11 @@ skip_lint="${SKIP_LINT_COMMIT}" # Get the path to a file containing the commit message: commit_message="$1" -# Determine root directory: -root=$(git rev-parse --show-toplevel) +# Resolve the location of the Git directory: +git_dir=$(git rev-parse --absolute-git-dir) # Define the path to a report generated during the pre-commit hook: -pre_commit_report="${root}/.git/hooks-cache/pre_commit_report.yml" +pre_commit_report="${git_dir}/hooks-cache/pre_commit_report.yml" # FUNCTIONS # diff --git a/tools/git/hooks/pre-commit b/tools/git/hooks/pre-commit index 863afb345236..d5020bfbd6fe 100644 --- a/tools/git/hooks/pre-commit +++ b/tools/git/hooks/pre-commit @@ -50,6 +50,9 @@ skip_editorconfig="${SKIP_LINT_EDITORCONFIG}" # Determine root directory: root=$(git rev-parse --show-toplevel) +# Resolve the location of the Git directory: +git_dir=$(git rev-parse --absolute-git-dir) + # Define the path to a utility for linting filenames: lint_filenames="${root}/lib/node_modules/@stdlib/_tools/lint/filenames/bin/cli" @@ -81,7 +84,7 @@ cppcheck_tests_fixtures_suppressions_list="${root}/etc/cppcheck/suppressions.tes cppcheck_benchmarks_suppressions_list="${root}/etc/cppcheck/suppressions.benchmarks.txt" # Define the path to a directory for caching hook results: -cache_dir="${root}/.git/hooks-cache" +cache_dir="${git_dir}/hooks-cache" # Define the path to a file for storing hook results: cache_file="${cache_dir}/pre_commit_report.yml" diff --git a/tools/git/hooks/pre-push b/tools/git/hooks/pre-push index 57f2d9f7dafe..2a077010b9ae 100755 --- a/tools/git/hooks/pre-push +++ b/tools/git/hooks/pre-push @@ -59,8 +59,11 @@ GIT_CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD) # Determine root directory: root=$(git rev-parse --show-toplevel) +# Resolve the location of the Git directory: +git_dir=$(git rev-parse --absolute-git-dir) + # Define the path to a directory for caching hook results: -cache_dir="${root}/.git/hooks-cache" +cache_dir="${git_dir}/hooks-cache" # Define the path to a file for storing hook results: cache_file="${cache_dir}/pre_push_report.yml"