worktree: Anchor ignore rules at the repository they belong to (#62325)

Since #60772, a worktree's ignore rules are also applied to the
directories above its root. Because of this, an `info/exclude` pattern
naming one of those parent directories marks it as ignored, and with it
the whole worktree below.

Stop the walk at the repository containing the worktree root.

Also skip exclude rules for paths outside the work directory they are
anchored at, as `.gitignore` and global gitignore rules already do.

Release Notes:

- Fixed a worktree being reported as entirely ignored when its
repository's `info/exclude` named one of the worktree's parent
directories
83dc1967d0Henrique Ferreiro committed on 8/11/2026, 3:36:59 PM· committed by GitHubparent992c7d4
3 files changedLine totals unavailable