# worktree: Apply outer repository excludes within nested repositories \(\#61492\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/3cee61d75f582e345faa43e2291e371534f223dd)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 3cee61d75f582e345faa43e2291e371534f223dd

Requested commit: 3cee61d75f582e345faa43e2291e371534f223dd

Commit: 3cee61d75f582e345faa43e2291e371534f223dd

Tree: ad2a1c05cdbd19992cafa554997cc5d8b3c02ec0

Author: Eric Holk

Committer: GitHub

## Message

```
worktree: Apply outer repository excludes within nested repositories (#61492)

Closes TRA-162

When an entry's ignore stack is rebuilt from scratch (opening a file,
file system events, a search that includes ignored files),
`ignore_stack_for_abs_path` only consulted the `.git/info/exclude` rules
of the nearest ancestor containing `.git`. For a path inside a nested
repository, that nearest ancestor is the nested repository itself, so
the outer repository's exclude rules were silently dropped: entries that
were correctly ignored after the initial scan would flip to unignored
the moment they were loaded or changed on disk, and from then on project
search would surface them.

This is the same class of bug that #60772 fixed for ancestor
`.gitignore` files — this change extends the fix to `info/exclude` by
collecting the exclude rules of every containing repository (outermost
first, mirroring how ancestor gitignores are stacked) instead of just
the innermost one.

Added a regression test that models the affected layout: a bare clone
and a linked worktree of it kept inside the repository, hidden via
anchored patterns in the outer repository's `.git/info/exclude`.

Release Notes:

- Fixed project search returning results from inside nested repositories
that are excluded by the containing repository's `.git/info/exclude`
file.
```

## Parents

- [6e1e050738edae5d145d160ebdf65e1dc25ba3ee](https://git.cafe/gitcafe/zed/commit/6e1e050738edae5d145d160ebdf65e1dc25ba3ee?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/3cee61d75f582e345faa43e2291e371534f223dd?format=markdown)
