From 610bef509db025758a9934bb38b8fcf63bd99a87 Mon Sep 17 00:00:00 2001 From: Thomas Cederholm Date: Wed, 13 May 2026 14:03:19 +0200 Subject: [PATCH] fix: Support git worktrees in pre-commit hook Git passes an absolute path to COMMIT_EDITMSG when committing from a worktree (e.g. .git/worktrees//COMMIT_EDITMSG), so the literal match against ".git/COMMIT_EDITMSG" failed and the path was forwarded to commitlint as an unknown positional argument. Match any path ending in COMMIT_EDITMSG instead. --- bin/commitlint.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bin/commitlint.sh b/bin/commitlint.sh index 9bc13e6..b250e23 100755 --- a/bin/commitlint.sh +++ b/bin/commitlint.sh @@ -2,8 +2,10 @@ ARGS="--config /work/commitlint.config.js" -if [ "$1" == ".git/COMMIT_EDITMSG" ]; then - # Running from pre-commit hook. +if [[ "$1" == *COMMIT_EDITMSG ]]; then + # Running from pre-commit hook. Git passes a relative path from the main + # checkout (.git/COMMIT_EDITMSG) and an absolute path from a worktree + # (.../.git/worktrees//COMMIT_EDITMSG). ARGS="$ARGS --edit $1" else # Use whatever args we were passed.