Skip to content

scripts/setup-hooks.sh: fails in a git worktree because .git is a file #137

Open

Description

@royosherove

scripts/setup-hooks.sh L8-13:

HOOKS_DIR="${REPO_ROOT}/.git/hooks"
if [[ ! -d "${REPO_ROOT}/.git" ]]; then
  echo "Error: not a git repository. Run from the repo root." >&2
  exit 1
fi

Problem: In a linked worktree (git worktree add), .git is a file, not a directory. The script then prints "not a git repository" and exits 1. Also, git does not read hooks from <worktree>/.git/hooks.

Fix:

git -C "$REPO_ROOT" rev-parse --git-dir >/dev/null 2>&1 || { echo "Error: not a git repository." >&2; exit 1; }
HOOKS_DIR="$(git -C "$REPO_ROOT" rev-parse --path-format=absolute --git-path hooks)"

Found by a code read at commit 1e50295. The code was read, but not run on a real instance.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcrew: in progressIssue Radar work claimed by a Kiro Crew workergood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions