From 054eaf6cd40c88b083aa3413994b23f7f98c0c8f Mon Sep 17 00:00:00 2001 From: Jeroen Schweitzer Date: Sat, 13 Jun 2026 16:31:34 +0200 Subject: [PATCH] post-checkout hook: guard with if + force exit 0 (worktree-safe) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The pql post-checkout hook is untracked (local `pql init` install), so a fresh `git worktree add` has none — and `[ -f x ] && . x` returns 1 when absent (the script's last statement), which worktree add propagates as a hard failure. Use an if-guard and always exit 0: post-checkout is best-effort and must never abort a checkout / worktree creation. (Worth reporting upstream to pql.) Co-Authored-By: Claude Opus 4.8 (1M context) --- .githooks/post-checkout | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.githooks/post-checkout b/.githooks/post-checkout index ae7afdc8..8c960f74 100755 --- a/.githooks/post-checkout +++ b/.githooks/post-checkout @@ -1,6 +1,9 @@ #!/bin/sh # pql: source .pql/hooks/post-checkout (rebuild pql.db on branch checkout). -# Guard on existence so a fresh `git worktree add` — whose toplevel has no -# .pql/hooks yet — doesn't abort the checkout (the hook is best-effort). +# The pql hook is untracked (a local `pql init` install), so a fresh +# `git worktree add` has no .pql/hooks — source it only when present, and +# always exit 0: post-checkout is best-effort and must never abort the +# checkout / worktree creation. hook="$(git rev-parse --show-toplevel)/.pql/hooks/post-checkout" -[ -f "$hook" ] && . "$hook" +if [ -f "$hook" ]; then . "$hook"; fi +exit 0