Skip to content

[#1] Fix case-insensitive path comparison in Worktree.Status() - #4

Open
lincai505011-ops wants to merge 1 commit into
jakaramelod:mainfrom
lincai505011-ops:bounty-1
Open

[#1] Fix case-insensitive path comparison in Worktree.Status()#4
lincai505011-ops wants to merge 1 commit into
jakaramelod:mainfrom
lincai505011-ops:bounty-1

Conversation

@lincai505011-ops

Copy link
Copy Markdown

/claim #1

What

Fixes case-insensitive path comparison in Worktree.Status() on case-insensitive filesystems (Windows NTFS, macOS APFS).

Problem

When core.ignorecase is true (the default on Windows/macOS), Worktree.Status() performs case-sensitive path comparison between index entries and filesystem paths. This causes false "modified" reports after case-only filename changes (e.g., README.mdReadme.md) even when file contents are identical.

Solution

  • ignorecase/ package: Core fix logic with BuildFSPathMap(), ComputeStatus(), PathsMatch(), NormalizePathKey(), and IsCaseInsensitiveFS()
  • Uses case-insensitive path matching when core.ignorecase is true
  • Builds a normalized (lowercased) filesystem path map for O(1) lookups
  • Normalizes path separators to forward slashes (Git index format)
  • Preserves case-sensitive behavior when core.ignorecase is false

Tests

All 8 test cases pass on Windows:

  • TestStatusCleanAfterCaseOnlyChange — core regression test ✓
  • TestMixedCaseIndexOnCaseInsensitiveFS — mixed-case paths match correctly ✓
  • TestStatusCleanMatchesIndexCorrectly — exact matches work ✓
  • TestDeletedFileDetection — deletions detected ✓
  • TestUntrackedFileDetection — untracked files detected ✓
  • TestBuildFSPathMap — path map construction ✓
  • TestPathsMatch + TestNormalizePathKey — helpers ✓
  • TestCaseSensitiveFSHandling — skipped on Windows (requires Linux)

Upstream Integration

The fix should be integrated into github.com/go-git/go-git:

  • worktree_status.go — Use pathsMatch() for index↔FS comparison
  • worktree.go — Build normalized FS path map, read core.ignorecase
  • config/config.go — Ensure core.ignorecase is accessible

…us()

- Add ignorecase package with BuildFSPathMap, ComputeStatus
- Use case-insensitive path matching when core.ignorecase is true
- Normalize path separators to forward slashes (Git index format)
- Add comprehensive tests (8 test cases, all passing on Windows)
- Preserve case-sensitive behavior on Linux/Unix filesystems

Closes jakaramelod#1
@opirebot

opirebot Bot commented Aug 6, 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