Skip to content

worktree: Apply outer repository excludes within nested repositories - #61492

Merged
kubkon merged 2 commits into
mainfrom
eric/tra-162-repo-exclude-nested-repos
Jul 23, 2026
Merged

worktree: Apply outer repository excludes within nested repositories#61492
kubkon merged 2 commits into
mainfrom
eric/tra-162-repo-exclude-nested-repos

Conversation

@eholk

@eholk eholk commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

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.

eholk added 2 commits July 22, 2026 18:44
The outer repository's .git/info/exclude rules are dropped when an
entry's ignore stack is rebuilt from scratch for a path inside a nested
repository, because ignore_stack_for_abs_path only consults the exclude
file of the nearest ancestor containing .git.
When rebuilding an entry's ignore stack from scratch, only the
info/exclude file of the nearest ancestor containing .git was
consulted. For paths inside a nested repository, that nearest ancestor
is the nested repository itself, so the outer repository's exclude
rules were silently dropped and previously-ignored entries became
unignored whenever they were loaded or changed on disk.

Collect the info/exclude rules of every containing repository instead,
outermost first, mirroring how ancestor .gitignore files are stacked.
@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Jul 23, 2026
@zed-community-bot zed-community-bot Bot added the staff Pull requests authored by a current member of Zed staff label Jul 23, 2026
@kubkon
kubkon added this pull request to the merge queue Jul 23, 2026
Merged via the queue into main with commit 3cee61d Jul 23, 2026
48 checks passed
@kubkon
kubkon deleted the eric/tra-162-repo-exclude-nested-repos branch July 23, 2026 07:27
@kubkon

kubkon commented Jul 23, 2026

Copy link
Copy Markdown
Member

/cherry-pick preview

zed-zippy Bot added a commit that referenced this pull request Jul 23, 2026
…61492) (cherry-pick to preview) (#61506)

Cherry-pick of #61492 to preview

----
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.

Co-authored-by: Eric Holk <eric@zed.dev>
jolutz pushed a commit to jolutz/zed that referenced this pull request Aug 8, 2026
…ed-industries#61492) (cherry-pick to preview) (zed-industries#61506)

Cherry-pick of zed-industries#61492 to preview

----
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 zed-industries#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.

Co-authored-by: Eric Holk <eric@zed.dev>
jolutz pushed a commit to jolutz/zed that referenced this pull request Aug 8, 2026
…ed-industries#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 zed-industries#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.
playdohface pushed a commit to playdohface/zed that referenced this pull request Aug 29, 2026
…ed-industries#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 zed-industries#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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement staff Pull requests authored by a current member of Zed staff

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants