Conversation
3 tasks
belav
pushed a commit
that referenced
this pull request
May 17, 2026
# Issue csharpier was not formatting any files, in a worktree under a .gitignored folder path ## Description `IgnoreFile.FindIgnorePaths` walks up from the target directory collecting `.gitignore` files and stops when it encounters a `.git` directory. In a git worktree, `.git` is a *file* containing a `gitdir:` pointer rather than a directory, so the walk continued past the worktree root. When the worktree lives at a path the parent repo's `.gitignore` excludes (e.g. tools that create worktrees inside an ignored folder), every file in the worktree is matched by the parent ignore rule and `dotnet csharpier format .` reports `Formatted 0 files`. This change also stops the walk when `.git` exists as a file, matching git's own treatment of the worktree as a separate working tree. Added a regression test that mirrors the existing `Gitignore_Outside_Git_Is_Not_Used` but with `.git` as a file. ## Related Issue Follow-up to #1627 / #1649, which introduced the `.git` directory boundary but did not cover worktrees. ### Checklist - [x] My code follows the project's code style - always `var` - follow existing naming conventions - always `this.` - no pointless comments - [x] I will not force push after a code review of my PR has started - [x] I have added tests that cover my changes Co-authored-by: Jack Della <jack.della@revivefinancial.com.au> Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes #1627