From 4f8bde77fa6b874b8a2e6a52eeab93a00160294a Mon Sep 17 00:00:00 2001 From: Austin Turner Date: Sun, 11 Oct 2026 09:16:34 -0500 Subject: [PATCH] fix(hooks): export skip-worktree entries into the pre-commit snapshot --- .githooks/pre-commit | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.githooks/pre-commit b/.githooks/pre-commit index a61d20f..4d4a636 100755 --- a/.githooks/pre-commit +++ b/.githooks/pre-commit @@ -24,12 +24,14 @@ done # exactly what the commit will contain, so a file formatted on disk but never re-staged cannot # slip through, and unstaged edits cannot block a clean commit. git points GIT_INDEX_FILE at the # right index for `commit -a` and `commit ` too, and checkout-index honours it. Every -# tracked file is exported, so the whole codebase is checked, not only the files being changed. +# tracked file is exported, so the whole codebase is checked, not only the files being changed; +# --ignore-skip-worktree-bits includes paths a sparse checkout or `update-index --skip-worktree` +# leaves out of the working tree. snapshot=$(mktemp -d "${TMPDIR:-/tmp}/pre-commit.XXXXXX") || exit 1 trap 'rm -rf "$snapshot"' EXIT trap 'exit 1' HUP INT TERM -git -C "$root" checkout-index --all --prefix="$snapshot/" || exit 1 +git -C "$root" checkout-index --all --ignore-skip-worktree-bits --prefix="$snapshot/" || exit 1 # Some lint rules resolve imports, so the snapshot shares the installed dependencies. ln -s "$root/node_modules" "$snapshot/node_modules" || exit 1