Skip to content

Reload index on RetrieveStatus() #451

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 2 commits into from
Closed

Conversation

dahlbyk
Copy link
Member

@dahlbyk dahlbyk commented Jun 12, 2013

This fixes the repro provided in #322; however, I don't feel great about how I solved the problem.

Furthermore, this diff fails at Assert.True(readStatus.IsDirty):

@@ -263,6 +263,15 @@ public void CanCopeWithExternalChangesToTheIndex()
                 Assert.Equal(0, repoRead.Index.Count);

                 repoWrite.Index.Stage("*");
+
+                writeStatus = repoWrite.Index.RetrieveStatus();
+                Assert.True(writeStatus.IsDirty);
+                Assert.Equal(2, repoWrite.Index.Count);
+
+                readStatus = repoRead.Index.RetrieveStatus();
+                Assert.True(readStatus.IsDirty);
+                Assert.Equal(2, repoRead.Index.Count);
+
                 repoWrite.Commit("message", DummySignature);

                 writeStatus = repoWrite.Index.RetrieveStatus();

@dahlbyk
Copy link
Member Author

dahlbyk commented Jun 15, 2013

And that's why we always run all tests..oops. 89b6e9b is probably worth cherry-picking, but the hack in 0e95c58 breaks enough that's it's probably not worth refining.

@dahlbyk dahlbyk closed this Jun 15, 2013
@nulltoken
Copy link
Member

89b6e9b is probably worth cherry-picking

How about this:

diff --git a/LibGit2Sharp.Tests/TestHelpers/BaseFixture.cs b/LibGit2Sharp.Tests/TestHelpers/BaseFixture.cs
index ee15666..eb9c290 100644
--- a/LibGit2Sharp.Tests/TestHelpers/BaseFixture.cs
+++ b/LibGit2Sharp.Tests/TestHelpers/BaseFixture.cs
@@ -1,5 +1,6 @@
 using System;
 using System.Collections.Generic;
+using System.Diagnostics;
 using System.Globalization;
 using System.IO;
 using System.Linq;
@@ -213,17 +214,12 @@ private static RepositoryOptions BuildFakeRepositoryOptions(SelfCleaningDirector

         protected string Touch(string parent, string file, string content = null)
         {
-            var lastIndex = file.LastIndexOf('/');
-            if (lastIndex > 0)
-            {
-                var parents = file.Substring(0, lastIndex);
-                Directory.CreateDirectory(Path.Combine(parent, parents));
-            }
+            string filePath = Path.Combine(parent, file);
+            string dir = Path.GetDirectoryName(filePath);
+            Debug.Assert(dir != null);

-            if (!Directory.Exists(parent))
-                Directory.CreateDirectory(parent);
+            Directory.CreateDirectory(dir);

-            var filePath = Path.Combine(parent, file);
             File.AppendAllText(filePath, content ?? string.Empty, Encoding.ASCII);

             return file;

@dahlbyk
Copy link
Member Author

dahlbyk commented Jun 16, 2013

How about this:

👍

@nulltoken
Copy link
Member

@dahlbyk Merged!

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.

2 participants