Skip to content

fix(xtask): perf attestation fails in git worktrees #170

@rocketman-code

Description

@rocketman-code

Current Behavior

The pre-commit, pre-push hooks and perf-validate command hardcode .git/perf-attestation.json and .git/hooks/ paths. In a git worktree, .git is a file (pointer to the real git dir), not a directory. This causes:

  1. cargo xtask perf-validate fails to write attestation: Not a directory (os error 20)
  2. Pre-push hook can't find the attestation and blocks the push
  3. cargo xtask install-hooks would fail in a worktree

Expected Behavior

Hooks and attestation should work correctly in both normal repos and git worktrees.

Technical Details

Relevant Code

xtask/src/hooks.rs:54,85,118 and xtask/src/perf_validate.rs:246

All use root.join(".git/...") which assumes .git is a directory.

Root Cause

In a git worktree, .git is a file containing gitdir: /path/to/real/.git/worktrees/<name>. The fix is to use git rev-parse --git-dir which returns the correct directory in both contexts.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium prioritybugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions