Repository navigation
fix: respect .git/info/exclude in a linked git worktree and a submodule - #1462
Merged
Merged
Conversation
…dule In a worktree created with `git worktree add`, `.git` is a file with the path of the worktree's git directory, whose `commondir` file has the path of the git directory it shares with the main worktree. git reads `info/exclude` from there, but dprint only looked in `<root>/.git`, so it formatted files that git ignores. A `.git` file is now followed the way git does it. This also picks up the `info/exclude` of a submodule, which has a `.git` file without a `commondir`. Closes #1459
# Conflicts: # crates/dprint/src/utils/gitignore.rs
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 #1459
In a worktree created with
git worktree add,.gitis a file with the path of the worktree's git directory (<main>/.git/worktrees/<name>), and that directory'scommondirfile has the path of the git directory it shares with the main worktree. git readsinfo/excludefrom that shared directory, but dprint only looked in<root>/.git/info/exclude, so it formatted files that git ignores.Changes
.gitis a file, itsgitdir: <path>and the git directory'scommondirare now followed the same way git does it (relative and absolute paths, only trailing\r/\ntrimmed, nothing read from a file over 1 MB) andinfo/excludeis read from there..gitfile, but its git directory has nocommondir, so it now gets theinfo/excludeof its own git directory (<super>/.git/modules/<name>), which matches git..gitfile that doesn't lead anywhere still makes the directory a repository root with no exclude file, as before..gitfile changes. The.gitandcommondirfiles aren't read again on each lookup unless the.gitfile changed or the repository has noinfo/exclude.The cost for a normal run is one extra stat of
.gitper repository root found during a traversal.Testing
gitdir, absolutecommondir, Windows line endings), submodules,.gitfiles that don't lead to an exclude file, and change detection in a linked worktree.excluded-dir/probe.mdis listed by 0.64.3 and isn't listed with this change, in both the linked and main worktrees.