fix: case-insensitive path comparison in Worktree.Status() - #7
Open
digivasserver-ai wants to merge 1 commit into
Open
fix: case-insensitive path comparison in Worktree.Status()#7digivasserver-ai wants to merge 1 commit into
digivasserver-ai wants to merge 1 commit into
Conversation
Implement a complete Worktree.Status() that respects core.ignorecase: - On case-insensitive filesystems (APFS/NTFS, core.ignorecase=true), index paths are matched against on-disk names with case folding, so a case-only rename (README.md -> Readme.md) is reported as clean instead of modified/untracked/deleted. - Case-folded index lookups use a lowercased map for O(1) matching. - On case-sensitive filesystems (ext4, core.ignorecase=false), paths differing only in case remain distinct, matching git's behaviour. - Status still detects real modifications (content hash comparison), untracked files, and deleted files. - Adds a runnable demo in main.go and a test suite covering the case-insensitive fix, the case-sensitive regression guard, and the modified/untracked/deleted cases. Closes jakaramelod#1
|
😅 Ups... the issue does not have any reward yet! |
4 tasks
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.
Summary
Implements a complete
Worktree.Status()that respectscore.ignorecaseand eliminates false-positive modifications on case-insensitive filesystems (APFS/NTFS).The bug
On case-insensitive filesystems, an index path like
README.mdcould not be matched against the on-disk nameReadme.md. After a case-only rename,Worktree.Status()reported the file as modified/untracked/deleted even though git CLI reports a clean tree.The fix
Worktree.Status()now matches index paths against on-disk paths using case folding whencore.ignorecaseis enabled (via a lowercased lookup map for O(1) matching).pathsMatch()/case-folding is disabled whencore.ignorecaseis false, so case-sensitive filesystems (ext4) still treatREADME.mdandReadme.mdas distinct files — no regression.Verification
go vet ./...cleango test ./...— 9 tests pass:IsClean() == true.gitdirectory skippedpathsMatchhonourscore.ignorecasego run .demo verifies all four scenarios end-to-end./claim #1