Skip to content

Fix TIA fingerprinting inside linked git worktrees - #1813

Open
ademola-emmanuel wants to merge 1 commit into
pestphp:5.xfrom
ademola-emmanuel:fix-tia-fingerprint-git-worktrees
Open

Fix TIA fingerprinting inside linked git worktrees#1813
ademola-emmanuel wants to merge 1 commit into
pestphp:5.xfrom
ademola-emmanuel:fix-tia-fingerprint-git-worktrees

Conversation

@ademola-emmanuel

Copy link
Copy Markdown

Fixes #1810.

The problem

Fingerprint::isTrackedByGit() answers "is this file gitignored?" with Symfony Finder's ignoreVCSIgnored(true). Finder locates the repository root by walking upward until it finds a .git directory. In a linked worktree .git is a pointer file, so the walk misses the worktree root, and what happens next depends on the directory layout:

  • If an ancestor directory contains a .git directory (worktrees kept inside the main repository under an ignored .worktrees/ directory, or a dotfiles repository in $HOME that ignores *), Finder adopts that ancestor as the repository root and applies its ignore rules to the worktree's files. Every structural file then reports as ignored, trackedHash() returns null for all of them, and --tia rebuilds the graph on every run with no error, just a permanent "fresh graph" message.
  • If no ancestor has one, the check happens to behave correctly, which is why the failure looks machine-dependent.

The fix

Ask git itself with git check-ignore -q, run from the project root, as the issue suggests. Git resolves the gitdir: pointer natively, so worktrees behave like regular clones. This also matches how TIA already answers the same question in ChangedFiles::filterIgnored().

Exit code 0 keeps a file out of the fingerprint (ignored), 1 keeps it in, and anything else (git missing, not a repository) keeps the file, matching the existing no-.git early return.

Verification

  • New test: a repository with a linked worktree under an ignored .worktrees/ directory. On current 5.x it fails (worktree fingerprints are null); with this change the worktree produces the same structural fingerprint as the clone, which is the property replay depends on.
  • The gitignored-untracked-lockfile exclusion documented on the method keeps working, also covered by a new test.
  • Full unit suite (1,608 tests), PHPStan, 100% type coverage, rector, and pint all pass.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: In a git worktree every TIA fingerprint input is null, so composer.lock / phpunit.xml changes never invalidate the graph

1 participant