Skip to content

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

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

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

Conversation

@RawNuke

@RawNuke RawNuke commented Aug 7, 2026

Copy link
Copy Markdown

/claim #1

What

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

Problem

When core.ignorecase is true (default on macOS/Windows), Worktree.Status() performed case-sensitive path comparison between index entries and filesystem paths. Files with casing-only changes (README.md vs Readme.md) were incorrectly reported as modified or untracked.

Solution

Extends the existing pathsMatch() and isIgnoreCase() helpers with:

  • Worktree.Status() method: walks the filesystem and compares entries against the index using case-insensitive matching when core.ignorecase is true
  • findInIndex(): case-aware index entry lookup
  • Status.IsClean(): returns true when no entries are modified, deleted, or untracked

The fix respects core.ignorecase from repository config. On case-sensitive filesystems, files differing only by case are treated as distinct entries.

Tests

All 7 tests pass:

  • TestStatusCleanOnCaseInsensitiveFS: files with casing differences report clean
  • TestStatusCleanOnCaseSensitiveFS: exact matches report clean
  • TestCaseSensitiveFSSeparatesDifferentCases: different-case files distinguished on case-sensitive FS
  • TestPathMatchCaseInsensitive: pathsMatch() with ignorecase
  • TestPathMatchCaseSensitive: pathsMatch() without ignorecase
  • TestFindInIndexCaseInsensitive: findInIndex() case-insensitive lookup
  • TestFindInIndexCaseSensitive: findInIndex() case-sensitive lookup

When core.ignorecase is true (macOS/Windows), use case-insensitive path
matching via findInIndex() to compare filesystem entries against index
entries. Files with casing-only differences (README.md vs Readme.md) are
correctly matched as unmodified.

Additions:
- Worktree struct with Status() method that walks the filesystem
- findInIndex() for case-aware index lookup
- pathsMatch() preserved from prior fix, used in Status()
- IsClean() on Status type
- 7 passing tests covering case-insensitive and case-sensitive scenarios

The fix respects core.ignorecase from repository config and does not
introduce regressions on case-sensitive filesystems.

Signed-off-by: RawNuke <67506722+RawNuke@users.noreply.github.com>
@opirebot

opirebot Bot commented Aug 7, 2026

Copy link
Copy Markdown

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

@RawNuke

RawNuke commented Aug 7, 2026

Copy link
Copy Markdown
Author

The work is complete. Thank you for the chance to help.
If you liked my support, please donate:

  • EVM (ETH, USDC, USDT, Base): 0x9C7d9BfC606D3D5B5fB22C199495cF7207C5Cd16
  • Bitcoin: bc1qswtgp6a0dp4qpsstf0jsrnzgquq80nzy2g5nmm
  • Solana: EW4SCPWMiATUC53Apkaxw9EDKLRQtm8oTGAzk4XhDcP9
  • Tron: TBEJYtPeK1owFA6P67dKtBntSU6u29PwsH

A donation is optional and always appreciated.

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