From 8bf87e88909601b2cdd92bb8b75250fc5bd46591 Mon Sep 17 00:00:00 2001 From: Harshit Singh Bhandari Date: Fri, 5 Jun 2026 03:29:12 +0530 Subject: [PATCH] Make pre-commit hook installation and execution work in git worktrees (#1643) - Closes #1641. - This PR replaces the existing hook pathname computation for `make pre-commit` with `git rev-parse --git-path hooks/...`, which resolves to the shared hooks directory in both the main checkout and any worktree. --- Makefile | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index cebc907e..fae34241 100644 --- a/Makefile +++ b/Makefile @@ -319,12 +319,13 @@ check-licenses: .PHONY: pre-commit pre-commit: - cp scripts/pre-commit.fmt .git/hooks - touch .git/hooks/pre-commit - cat .git/hooks/pre-commit | grep -v 'hooks/pre-commit\.fmt' > /tmp/pre-commit.new || true - echo 'PRECOMMIT_NOFMT=$${PRECOMMIT_NOFMT} $$(git rev-parse --show-toplevel)/.git/hooks/pre-commit.fmt' >> /tmp/pre-commit.new - mv /tmp/pre-commit.new .git/hooks/pre-commit - chmod +x .git/hooks/pre-commit + $(eval HOOKS_DIR := $(shell git rev-parse --git-path hooks)) + cp scripts/pre-commit.fmt $(HOOKS_DIR)/ + touch $(HOOKS_DIR)/pre-commit + cat $(HOOKS_DIR)/pre-commit | grep -v 'hooks/pre-commit\.fmt' > /tmp/pre-commit.new || true + echo 'PRECOMMIT_NOFMT=$${PRECOMMIT_NOFMT} $$(git rev-parse --git-path hooks/pre-commit.fmt)' >> /tmp/pre-commit.new + mv /tmp/pre-commit.new $(HOOKS_DIR)/pre-commit + chmod +x $(HOOKS_DIR)/pre-commit .PHONY: serve-docs serve-docs: