Skip to content

Perform case-sensitive path comparisons on Linux#1232

Merged
kivikakk merged 1 commit intomicrosoft:features/linuxprototypefrom
github:platform-case-sensitivity
Jun 19, 2019
Merged

Perform case-sensitive path comparisons on Linux#1232
kivikakk merged 1 commit intomicrosoft:features/linuxprototypefrom
github:platform-case-sensitivity

Conversation

@kivikakk
Copy link
Contributor

@kivikakk kivikakk commented Jun 3, 2019

On Windows and Mac, path comparisons are case-insensitive, as the filesystems are case-insensitive -- .git and .GIT are the same path name, and you can't have two different files or directories with names that only differ in case.

On Linux, filesystems (usually) are case-sensitive -- it is possible to have .git, .GIT and .Git entries in the one directory, all referring to different things. Accordingly, we need to do all path comparisons in a case-sensitive fashion.

This change should be a no-op for Windows and Mac, inasmuch as no different values will result after the change. This change does mean GVFSPlatform.Instance is being relied on in more places, and it's difficult to audit if a given piece of code could be called without GVFSPlatform.Instance already being initialised. (This bit me when working on #1084, where I tried to use GVFSPlatform.Instance in GVFS.FunctionalTests.LockHolder, which silently died with NRE because it wasn't initialised.)

Nonetheless, unit and (Windows) functional tests pass, so it might be fine.

Fixes github#29.
/cc @chrisd8088

@kivikakk kivikakk self-assigned this Jun 3, 2019
@kivikakk kivikakk changed the title introduce path case-sensitivity platform property Perform case-sensitive path comparisons on Linux Jun 4, 2019
@kivikakk kivikakk marked this pull request as ready for review June 4, 2019 06:54
@kivikakk
Copy link
Contributor Author

kivikakk commented Jun 4, 2019

/azp run GitHub VFSForGit Mac Functional Tests

@azure-pipelines
Copy link

No pipelines are associated with this pull request.

@kivikakk
Copy link
Contributor Author

kivikakk commented Jun 4, 2019

I thought I'd give it a try! Looks like maybe I don't have permissions?

@derrickstolee
Copy link
Contributor

I thought I'd give it a try! Looks like maybe I don't have permissions?

It looks like the mac build worked for you. Sorry that you don't have access to the build results themselves. It's unfortunate that we always get those "No pipelines are associated..." messages.

Copy link
Contributor

@derrickstolee derrickstolee left a comment

Choose a reason for hiding this comment

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

This seems straight-forward. I just have one question about how we can skip tests more eloquently using annotations, but I don't know if it is possible. Thanks!

[TestCase]
public void ParsesCaseChangesAsAdds()
{
if (GVFSPlatform.Instance.Constants.CaseSensitiveFileSystem)
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if there is a way to do this with test categories using the [] annotations.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Time to find out!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

be79df2 uses this approach -- thanks!

@@ -260,7 +260,7 @@ public void WriteAllEntriesAndFlush(IEnumerable<IPlaceholderData> updatedPlaceho

private IEnumerable<string> GenerateDataLines(IEnumerable<IPlaceholderData> updatedPlaceholders)
Copy link
Member

Choose a reason for hiding this comment

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

FYI - On master the placeholders are now being stored in a SQLite database (see #1140). When updating the Linux feature branch to pick up that change you'll need to make the table creation call aware of whether the platform is case sensitive (currently the table is created with a case-insensitive path/key).

@wilbaker
Copy link
Member

wilbaker commented Jun 4, 2019

FYI - If you need to support repos that have files whose names only differ by case, you'll also need to update GitIndexProjection.SortedFolderEntries.

It uses LazyUTF8String.CaseInsensitiveCompare and it will need to use a new CaseSensitiveCompare if you need to support repos that allow names that only differ by case.

Please note that this is an extremely hot path, and has been tuned to eliminate as many instructions as possible (it's hit for every entry when parsing the index) and so we'll have to be careful with how this code is updated.

Related, there is a project GVFS.PerfProfiling that can be used to measure the perf of VFS4G's index loading/parsing code which I've found to be helpful when making changes in this area. Unfortunately it looks like it hasn't been converted to .NET core yet, and so right now it can only be run on Windows.

@derrickstolee
Copy link
Contributor

FYI - If you need to support repos that have files whose names only differ by case, you'll also need to update GitIndexProjection.SortedFolderEntries.

It uses LazyUTF8String.CaseInsensitiveCompare and it will need to use a new CaseSensitiveCompare if you need to support repos that allow names that only differ by case.

Sounds like we will need a new set of functional tests that only run on Linux that check case-sensitive comparisons by explicitly adding files or folders that differ only by case, otherwise, we will never know if we've checked all the things we need to make this switch.

@kivikakk
Copy link
Contributor Author

For now we've decided to not support in-tree files whose name only differ by case -- this PR will be scoped only to the operations VFS for Git performs on the filesystem for its own functioning (like locating the .git directory, or matching .keep and .idx files, etc.) -- the repository content will remain case-insensitive.

@kivikakk kivikakk force-pushed the platform-case-sensitivity branch from 105c1f5 to 33369e0 Compare June 12, 2019 03:38
This only applies to on-disk operations like locating the ".git"
directory or ".idx" files, etc. -- the repository contents remain
case-insensitive.
@kivikakk kivikakk force-pushed the platform-case-sensitivity branch from 33369e0 to c2a89da Compare June 12, 2019 04:03
@kivikakk
Copy link
Contributor Author

I think this should be good to go -- @derrickstolee @wilbaker fyi in case you'd like to re-review. I've lessened the scope of the change so nothing that impacts tracked content should be changed now.

@chrisd8088
Copy link
Contributor

Purely as a note for future work (not for this PR, unless someone feels it's important), I have a suspicion there are a few places in the functional test suite where we may want to have a similar OS-specific path comparator instead of StringComparison.OrdinalIgnoreCase().

@kivikakk
Copy link
Contributor Author

The paths referred to in those instances are in-tree paths (tracked content), and so are not in the scope of the change proposed in this PR. We'll only change those if we proceed to make VFSForGit support case-sensitivity in the repository contents. Right now we're just behaving appropriately with respect to the backing store.

chrisd8088 added a commit to chrisd8088/scalar that referenced this pull request Sep 17, 2020
TODO -- since we have no failing tests without this work, add some.

Use filesystem-specific case matching when comparing path
throughout Scalar and the functional test suite.

From microsoft/VFSForGit#1232, microsoft/VFSForGit#1412, and
microsoft/VFSForGit#1503.

From microsoft/VFSForGit@e6eb054,
microsoft/VFSForGit@66e3e21,
microsoft/VFSForGit@6067f04,
and microsoft/VFSForGit@7100179.

Co-authored-by: Ashe Connor <ashe@kivikakk.ee>
chrisd8088 added a commit to chrisd8088/scalar that referenced this pull request Sep 18, 2020
TODO -- since we have no failing tests without this work, add some.

Use filesystem-specific case matching when comparing path
throughout Scalar and the functional test suite.

From microsoft/VFSForGit#1232, microsoft/VFSForGit#1412, and
microsoft/VFSForGit#1503.

From microsoft/VFSForGit@e6eb054,
microsoft/VFSForGit@66e3e21,
microsoft/VFSForGit@6067f04,
and microsoft/VFSForGit@7100179.

Co-authored-by: Ashe Connor <ashe@kivikakk.ee>
chrisd8088 added a commit to chrisd8088/scalar that referenced this pull request Sep 18, 2020
TODO -- since we have no failing tests without this work, add some.

Use filesystem-specific case matching when comparing path
throughout Scalar and the functional test suite.

From microsoft/VFSForGit#1232, microsoft/VFSForGit#1412, and
microsoft/VFSForGit#1503.

From microsoft/VFSForGit@e6eb054,
microsoft/VFSForGit@66e3e21,
microsoft/VFSForGit@6067f04,
and microsoft/VFSForGit@7100179.

Co-authored-by: Ashe Connor <ashe@kivikakk.ee>
chrisd8088 added a commit to chrisd8088/scalar that referenced this pull request Sep 18, 2020
TODO -- since we have no failing tests without this work, add some.

Use filesystem-specific case matching when comparing path
throughout Scalar and the functional test suite.

From microsoft/VFSForGit#1232, microsoft/VFSForGit#1412, and
microsoft/VFSForGit#1503.

From microsoft/VFSForGit@e6eb054,
microsoft/VFSForGit@66e3e21,
microsoft/VFSForGit@6067f04,
and microsoft/VFSForGit@7100179.

Co-authored-by: Ashe Connor <ashe@kivikakk.ee>
chrisd8088 added a commit to chrisd8088/scalar that referenced this pull request Sep 23, 2020
TODO -- since we have no failing tests without this work, add some.

Use filesystem-specific case matching when comparing path
throughout Scalar and the functional test suite.

From microsoft/VFSForGit#1232, microsoft/VFSForGit#1412, and
microsoft/VFSForGit#1503.

From microsoft/VFSForGit@e6eb054,
microsoft/VFSForGit@66e3e21,
microsoft/VFSForGit@6067f04,
and microsoft/VFSForGit@7100179.

Co-authored-by: Ashe Connor <ashe@kivikakk.ee>
chrisd8088 added a commit to chrisd8088/scalar that referenced this pull request Sep 24, 2020
Use filesystem-specific case matching when comparing path
throughout Scalar and the functional test suite.

From microsoft/VFSForGit#1232, microsoft/VFSForGit#1412, and
microsoft/VFSForGit#1503.

From microsoft/VFSForGit@e6eb054,
microsoft/VFSForGit@66e3e21,
microsoft/VFSForGit@6067f04,
and microsoft/VFSForGit@7100179.

Co-authored-by: Ashe Connor <ashe@kivikakk.ee>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants