Skip to content

fix: case-insensitive path comparison in Worktree.Status() - #7

Open
digivasserver-ai wants to merge 1 commit into
jakaramelod:mainfrom
digivasserver-ai:fix/case-insensitive-status
Open

fix: case-insensitive path comparison in Worktree.Status()#7
digivasserver-ai wants to merge 1 commit into
jakaramelod:mainfrom
digivasserver-ai:fix/case-insensitive-status

Conversation

@digivasserver-ai

Copy link
Copy Markdown

Summary

Implements a complete Worktree.Status() that respects core.ignorecase and eliminates false-positive modifications on case-insensitive filesystems (APFS/NTFS).

The bug

On case-insensitive filesystems, an index path like README.md could not be matched against the on-disk name Readme.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 when core.ignorecase is enabled (via a lowercased lookup map for O(1) matching).
  • pathsMatch()/case-folding is disabled when core.ignorecase is false, so case-sensitive filesystems (ext4) still treat README.md and Readme.md as distinct files — no regression.
  • Real content changes are still detected via SHA-256 content-hash comparison against the index, along with untracked and deleted file detection.

Verification

  • go vet ./... clean
  • go test ./... — 9 tests pass:
    • case-insensitive FS + case-only rename → IsClean() == true
    • case-sensitive FS + case-only rename → dirty (README.md deleted, Readme.md untracked)
    • case-sensitive FS + exact names → clean
    • modified / untracked / deleted detection
    • .git directory skipped
    • pathsMatch honours core.ignorecase
  • go run . demo verifies all four scenarios end-to-end.

/claim #1

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
@opirebot

opirebot Bot commented Aug 8, 2026

Copy link
Copy Markdown

😅 Ups... the issue does not have any reward yet!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant