Make sure treechanges and statuses are case-sensitive #365

Open
wants to merge 1 commit into
from

Conversation

Projects
None yet
3 participants
Contributor

yorah commented Mar 15, 2013

This behavior has been discussed in #344.

Contributor

yorah commented Mar 15, 2013

This is also related to #345.

/cc @nulltoken @arrbee

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.

Contributor

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.

@dahlbyk dahlbyk and 1 other commented on an outdated diff Mar 18, 2013

LibGit2Sharp.Tests/TestHelpers/OdbHelper.cs
@@ -0,0 +1,17 @@
+using System.IO;
+using System.Text;
+
+namespace LibGit2Sharp.Tests.TestHelpers
+{
+ public static class OdbHelper
+ {
+ public static Blob CreateBlob(Repository repo, string content)
@dahlbyk

dahlbyk Mar 18, 2013

Member

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

@yorah

yorah Mar 19, 2013

Contributor

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.

@dahlbyk

dahlbyk Mar 19, 2013

Member

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.
Member

nulltoken commented Mar 28, 2013

@yorah What's the status regarding this PR?

Contributor

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 referenced this pull request in libgit2/libgit2 Apr 23, 2013

Merged

Support more diff config options and use the config cache more #1499

5 of 5 tasks complete
Contributor

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
Contributor

yorah commented May 6, 2013

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

Member

nulltoken commented May 6, 2013

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

Awesome! dc208c9 has been merged. 👍

Member

nulltoken commented Mar 29, 2014

@yorah What should we do this one?

Member

nulltoken commented Jun 15, 2014

@yorah What should we do this one?

ping?

Member

nulltoken commented Jan 21, 2015

@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]
Member

nulltoken commented Jan 21, 2015

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 @harmeyo yorah Add test for Status case-sensitivity
4da1ab5
Contributor

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

Member

nulltoken commented Feb 2, 2015

@yorah Thanks for this.

@arrbee @ethomson Thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment