Skip to content

fix(hooks): test fixtures write core.bare=true to the main checkout's git config #251

Closed

Description

@DevSecNinja

Problem

In a linked worktree, git commit exports GIT_DIR=<main>/.git/worktrees/<name> and GIT_INDEX_FILE to the pre-commit hooks. Hook test fixtures that run git init <tmp> and inherit them re-initialize that git dir, guess it's bare (the path doesn't end in .git), and write core.bare = true to the main checkout's shared .git/config. That breaks the main checkout and blocks new worktree sessions. The fixture commits (base, drop the companion) also land on the worktree's branch.

It happened on 2026-11-15 and again on 2026-11-16. The reflogs of several ai-toolkit worktrees on main's hooks show the fixture commits. The source is tests/test_apm_external_skills.py WorkTreeTests (#240), which the apm-external-skills hook runs wherever bare python3 is a real Python. tests/test_hook_scripts.py FeatureBranchPushTest has the same pattern (CI only today).

Fix

  • Drop GIT_* variables in every fixture suite that runs git, as test_renovate_prs.py already does.
  • Add a regression test, run by a pre-commit hook and in CI. It runs the git-fixture suites with a linked worktree's hook environment against a throwaway repo and fails if that repo's config, refs or index change.

Found while working on #246 / #247.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions