Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Make sure treechanges and statuses are case-sensitive #365

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

Closed
wants to merge 1 commit into from
Closed

Make sure treechanges and statuses are case-sensitive #365

wants to merge 1 commit into from

Conversation

yorah
Copy link
Contributor

@yorah yorah commented Mar 15, 2013

This behavior has been discussed in #344.

@yorah
Copy link
Contributor Author

yorah commented Mar 15, 2013

This is also related to #345.

/cc @nulltoken @arrbee

@dahlbyk
Copy link
Member

dahlbyk commented Mar 15, 2013

Tests look good to me. I'm confused why d9d866f is failing on CanEnumerateAllCommits()...nothing related should have changed.

@yorah
Copy link
Contributor Author

yorah commented Mar 18, 2013

Rebased on top of vNext.

I moved CreateBlob() in a new OdbHelper class, to avoid cross-references.
Please note that the tests do pass on Mono (ignorecase = true skips the offending tests). The failure happens only on Windows.

{
public static class OdbHelper
{
public static Blob CreateBlob(Repository repo, string content)
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we don't want to go down this path, but could this just be a test project extension method on ObjectDatabase?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Wouldn't it be confusing for people who read Unit Tests to understand how to use the library? They could mistake this extension method for a real method exposed by LibGit2Sharp.

Copy link
Member

Choose a reason for hiding this comment

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

Good point.

  • Leave as-is?
  • CreateTestBlob()?
  • Move the helper into the project proper, perhaps with an optional encoder? Could be handy for consumers, perhaps even in their own testing.

@nulltoken
Copy link
Member

@yorah What's the status regarding this PR?

@yorah
Copy link
Contributor Author

yorah commented Mar 28, 2013

The tests fail on Windows (works on Mono, but just because the test is skipped). I think for the same reason than #345 (or if not, something very closely related).

I believe that the fixes needed to make those tests pass will come from libgit2, and I've been willing to write some failing C tests to open an issue about. Hopefully I will have time to do that soon.

@yorah
Copy link
Contributor Author

yorah commented Apr 26, 2013

@arrbee's libgit2/libgit2#1499 partially fixes this PR (the diff tree to tree test is now passing, however the status retrieval is still inconsistent with git.git on Windows).

git.git behaviour (with a breakpoint in StatusFixture.RetrievingStatusMustAlwaysBeCaseSensitive()):

$ git status
# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#       deleted:    A.TXT
#       deleted:    a.txt
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#       a.TxT

Test output

  • a.txt is NonExistent
  • A.TXT is Removed | Untracked
  • a.TxT is NonExistent

@yorah
Copy link
Contributor Author

yorah commented May 6, 2013

I just rebased this PR, and split it in two commits so that the first one can get merged.

@nulltoken
Copy link
Member

I just rebased this PR, and split it in two commits so that the first one can get merged.

Awesome! dc208c9 has been merged. 👍

@nulltoken
Copy link
Member

@yorah What should we do this one?

@nulltoken
Copy link
Member

@yorah What should we do this one?

ping?

@nulltoken
Copy link
Member

@yorah Thanks for the rebase. However, could you please just take care of fixing the following errors?

"C:\projects\libgit2sharp\LibGit2Sharp.sln" (default target) (1) ->
"C:\projects\libgit2sharp\LibGit2Sharp.Tests\LibGit2Sharp.Tests.csproj" (default target) (3) ->
(CoreCompile target) -> 
  StatusFixture.cs(453,38): error CS0029: Cannot implicitly convert type 'string' to 'LibGit2Sharp.Repository' [C:\projects\libgit2sharp\LibGit2Sharp.Tests\LibGit2Sharp.Tests.csproj]
  StatusFixture.cs(465,71): error CS0103: The name 'DummySignature' does not exist in the current context [C:\projects\libgit2sharp\LibGit2Sharp.Tests\LibGit2Sharp.Tests.csproj]
  StatusFixture.cs(465,87): error CS0103: The name 'DummySignature' does not exist in the current context [C:\projects\libgit2sharp\LibGit2Sharp.Tests\LibGit2Sharp.Tests.csproj]
  StatusFixture.cs(476,30): error CS1928: 'LibGit2Sharp.Index' does not contain a definition for 'RetrieveStatus' and the best extension method overload 'LibGit2Sharp.RepositoryExtensions.RetrieveStatus(LibGit2Sharp.IRepository)' has some invalid arguments [C:\projects\libgit2sharp\LibGit2Sharp.Tests\LibGit2Sharp.Tests.csproj]
  StatusFixture.cs(476,30): error CS1929: Instance argument: cannot convert from 'LibGit2Sharp.Index' to 'LibGit2Sharp.IRepository' [C:\projects\libgit2sharp\LibGit2Sharp.Tests\LibGit2Sharp.Tests.csproj]

@nulltoken
Copy link
Member

Fix proposal

diff --git a/LibGit2Sharp.Tests/StatusFixture.cs b/LibGit2Sharp.Tests/StatusFixture.cs
index d818873..6bd172a 100644
--- a/LibGit2Sharp.Tests/StatusFixture.cs
+++ b/LibGit2Sharp.Tests/StatusFixture.cs
@@ -445,12 +445,12 @@ FileStatus expectedCamelCasedFileStatus
         [SkippableFact]
         public void RetrievingStatusMustAlwaysBeCaseSensitive()
         {
-            SelfCleaningDirectory scd = BuildSelfCleaningDirectory();
-
             InconclusiveIf(() => IsFileSystemCaseSensitive,
                 "Skipping 'ignorecase = true' test on case-sensitive file system.");

-            using (Repository repo = Repository.Init(scd.DirectoryPath))
+            string repoPath = InitNewRepository();
+
+            using (Repository repo = new Repository(repoPath))
             {
                 repo.Config.Set("core.ignorecase", true);

@@ -462,22 +462,23 @@ public void RetrievingStatusMustAlwaysBeCaseSensitive()

                 Tree treeOld = repo.ObjectDatabase.CreateTree(tdOld);

-                var commit = repo.ObjectDatabase.CreateCommit("blah", DummySignature, DummySignature, treeOld, new Commit[] { });
+                var commit = repo.ObjectDatabase.CreateCommit(
+                    Constants.Signature, Constants.Signature, "blah", treeOld, new Commit[] { }, true);

                 repo.Refs.Add("refs/heads/master", commit.Sha);

                 Assert.Equal(commit, repo.Head.Tip);
             }

-            using (var repo = new Repository(scd.DirectoryPath))
+            using (var repo = new Repository(repoPath))
             {
                 File.WriteAllText(Path.Combine(repo.Info.WorkingDirectory, "a.TxT"), "blah\n");

-                var status = repo.Index.RetrieveStatus();
+                var status = repo.RetrieveStatus();

-                Assert.Equal(FileStatus.Removed, status["a.txt"]);
-                Assert.Equal(FileStatus.Removed, status["A.TXT"]);
-                Assert.Equal(FileStatus.Untracked, status["a.TxT"]);
+                Assert.Equal(FileStatus.Removed, status["a.txt"].State);
+                Assert.Equal(FileStatus.Removed, status["A.TXT"].State);
+                Assert.Equal(FileStatus.Untracked, status["a.TxT"].State);
             }
         }

@yorah
Copy link
Contributor Author

yorah commented Feb 2, 2015

Still failing on Windows (and macosx).

Test output

a.txt is Removed
A.TXT is NonExistent => this is the unexpected behavior, it should be Removed I believe
a.TxT is Untracked

@nulltoken
Copy link
Member

@yorah Thanks for this.

@arrbee @ethomson Thoughts?

@bording bording closed this Apr 21, 2019
@yorah yorah deleted the topic/case-sensistivity-for-treechanges-and-statuses branch April 23, 2019 13:25
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