Use `core.ignorecase` to determine case sensitivity by bk2204 · Pull Request #6212 · git-lfs/git-lfs · GitHub
Skip to content

Use core.ignorecase to determine case sensitivity - #6212

Merged
chrisd8088 merged 2 commits into
git-lfs:mainfrom
bk2204:ignorecase
Apr 9, 2026
Merged

chrisd8088 merged 2 commits into
git-lfs:mainfrom
bk2204:ignorecase

Conversation

@bk2204

@bk2204 bk2204 commented Mar 3, 2026

Copy link
Copy Markdown
Member

Right now, we always determine the case sensitivity of the repository based on the operating system default: case insensitive on Windows and macOS and case sensitive on other Unix systems. This works in most cases, but it is possible to have case sensitive file systems on macOS, case sensitive directories on Windows, and case insensitive file systems (e.g., JFS) on Linux, in which case we do not function correctly.

Add a function which uses the core.ignorecase setting in Git to properly detect whether our repository is case sensitive or not.

This PR contains independent, logical, bisectable commits each with their own commit message, and as such is best reviewed commit by commit.

@bk2204
bk2204 marked this pull request as ready for review March 3, 2026 20:22
@bk2204
bk2204 requested a review from a team as a code owner March 3, 2026 20:22
@chrisd8088 chrisd8088 added the git-config Related to our handling of Git configuration options label Mar 4, 2026
Comment thread tools/filetools.go Outdated

@chrisd8088 chrisd8088 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again for writing up this PR! I'm sorry it's taken me a while to reply properly.

Your work also prompted me to write up PR #6223, which I've been meaning to do for a while. That PR is still waiting for a review itself, but once that's done and it's merged, I think it will help simplify this PR.

I had a couple of other suggestions as well, and to test them out I drafted some additional commits on top of this PR (after first merging the branch from PR #6223) in my ignorecase branch. Please do take a look and see if those seem reasonable to you. I effectively just added a check for a nil parameter in the new caseFromConfig() function and then renamed some parameters to gitEnv.

Thanks again very much for this PR, which should really improve the experience of Git LFS users with non-default filesystem settings.

Comment thread fs/fs.go Outdated
Comment thread filepathfilter/filepathfilter.go Outdated
Comment thread filepathfilter/filepathfilter.go Outdated
Comment thread filepathfilter/filepathfilter.go Outdated
Comment thread filepathfilter/filepathfilter_test.go Outdated
@chrisd8088

Copy link
Copy Markdown
Member

@bk2204

bk2204 commented Apr 1, 2026

Copy link
Copy Markdown
Member Author

I'll try to get to rebasing this onto the main branch this week or early next week.

@bk2204

bk2204 commented Apr 8, 2026

Copy link
Copy Markdown
Member Author

Okay, I think I've got all of your suggestions here, but if I've missed one or more, please let me know and I'll try to get it addressed in a more timely manner than last time.

@chrisd8088 chrisd8088 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking really good, thank you!

I have only a couple of remaining small suggestions, just to avoid modifying the config and fs packages unnecessarily, and aligning one parameter name with the others.

Comment thread config/config.go Outdated
Comment thread fs/fs.go Outdated
Comment thread git/gitattr/files.go Outdated
Comment thread git/gitattr/files.go Outdated
@bk2204

bk2204 commented Apr 9, 2026

Copy link
Copy Markdown
Member Author

@chrisd8088 chrisd8088 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've picked up all those changes, I believe. My apologies for the oversight on the issues you'd mentioned.

No problem at all; thanks for accepting the changes! I'll merge the latest main, let CI finish, and then merge this PR.

Thanks again for this significant improvement to our file path matching!

bk2204 added 2 commits April 9, 2026 18:59
Right now, we always determine the case sensitivity of the repository
based on the operating system default: case insensitive on Windows and
macOS and case sensitive on other Unix systems.  This works in most
cases, but it is possible to have case sensitive file systems on macOS,
case sensitive directories on Windows, and case insensitive file systems
(e.g., JFS) on Linux, in which case we do not function correctly.

Add a function which looks up the `core.ignorecase` variable and if it
exists, use it to determine whether we should match case sensitively or
insensitively.  If it is not set, then assume it is false, since Git
only sets it if it needs to be true.
Right now, we always determine the case sensitivity of the repository
based on the operating system default: case insensitive on Windows and
macOS and case sensitive on other Unix systems.  This works in most
cases, but it is possible to have case sensitive file systems on macOS,
case sensitive directories on Windows, and case insensitive file systems
(e.g., JFS) on Linux, in which case we do not function correctly.

Use the new function which looks up the `core.ignorecase` variable to
determine whether we should match case sensitively or insensitively.
Pass the configuration object down to the file path filter so that it
can make use of the Git configuration.  Add a test for the proper
handling of this case based on `core.ignorecase`, which defaults to
false.

Add a fake environment that we can use throughout the testsuite that
contains no actual git configuration data.
@chrisd8088
chrisd8088 merged commit 831124f into git-lfs:main Apr 9, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

git-config Related to our handling of Git configuration options

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants