Skip to content

When core.ignorecase, check Status for files case-insensitively #724

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

nevinera
Copy link
Contributor

@nevinera nevinera commented May 26, 2024

Fixes #586 by making Status#changed? case-insensitive when core.ignoreCase is set. Also solve the matching unreported issues for Status#added, Status#deleted, and Status#untracked.

I did run into a bit of an issue trying to write thorough tests for these, because it turns out that git itself doesn't support setting core.ignoreCase to a value that doesn't match the behavior of the file-system; that option is provided so you can tell git how the file-system is going to act, not so you can control git's behavior! In the tests here, I do break that guideline, but because I don't actually rename any files, git doesn't have trouble - just don't try to make it test the case that was actually reported, because that will not work.

@nevinera nevinera force-pushed the nev--status-changes-should-obey-case-sensitivity branch from f66c543 to fd6bc67 Compare May 27, 2024 03:27
@nevinera nevinera marked this pull request as ready for review May 27, 2024 03:34
@nevinera nevinera changed the title When core.ignorecase, check for changed-files case-insensitively When core.ignorecase, check Status for files case-insensitively May 27, 2024
@jcouball jcouball self-requested a review June 1, 2024 00:41
Copy link
Member

@jcouball jcouball left a comment

Choose a reason for hiding this comment

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

Thanks again, Eric.

It seems awfully inefficient to downcase all keys in the collection every time you call one of these predicate methods. But with the tests we can optimize later.

Looks good 👍🏼

@jcouball jcouball merged commit 2bacccc into ruby-git:master Jun 1, 2024
7 checks passed
@nevinera
Copy link
Contributor Author

nevinera commented Jun 1, 2024

Thanks again, Eric.

It seems awfully inefficient to downcase all keys in the collection every time you call one of these predicate methods. But with the tests we can optimize later.

Looks good 👍🏼

I actually initially had it memoized, and had started down the path of memoizing all the other methods, but it was making the PR quite large. The existing predicates actually are far worse already, as they generate the corresponding collection dynamically in each call by iterating the @files, then check membership.

I decided that meant that the working set of items must typically be small enough not to worry about it, but I'd be happy to roll up a PR memoizing all the things, if that's of interest?

@nevinera
Copy link
Contributor Author

nevinera commented Jun 1, 2024

@jcouball - here are the performance improvements, when you have a minute: #729

@jcouball
Copy link
Member

jcouball commented Jun 1, 2024

I am interested but can live without it for now. Let's see if anyone complains.

@nevinera nevinera deleted the nev--status-changes-should-obey-case-sensitivity branch June 3, 2024 12:50
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.

Status#changed? is case-sensitive despite git config
2 participants