Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2sharp.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Dahlby <dahlbyk@gmail.com>2013-10-04 13:13:34 +0400
committernulltoken <emeric.fermas@gmail.com>2013-10-05 22:29:19 +0400
commit8effe572bc3100210354b0d7822ef763f557a087 (patch)
tree57d0b058dfed1cc14adb33cf97c5d6639be1daa6 /LibGit2Sharp.Tests/IndexFixture.cs
parent467fbd0ae68783a6f8d9437e8bbdec2d6129928a (diff)
Make RetrieveStatus() reload on-disk index beforehand
Fix #322 and #522
Diffstat (limited to 'LibGit2Sharp.Tests/IndexFixture.cs')
-rw-r--r--LibGit2Sharp.Tests/IndexFixture.cs34
1 files changed, 34 insertions, 0 deletions
diff --git a/LibGit2Sharp.Tests/IndexFixture.cs b/LibGit2Sharp.Tests/IndexFixture.cs
index 5b6f6e4f..f6c1690a 100644
--- a/LibGit2Sharp.Tests/IndexFixture.cs
+++ b/LibGit2Sharp.Tests/IndexFixture.cs
@@ -244,5 +244,39 @@ namespace LibGit2Sharp.Tests
Assert.Throws<LockedFileException>(() => repo.Index.Stage("newfile"));
}
}
+
+ [Fact]
+ public void CanCopeWithExternalChangesToTheIndex()
+ {
+ SelfCleaningDirectory scd = BuildSelfCleaningDirectory();
+
+ Touch(scd.DirectoryPath, "a.txt", "a\n");
+ Touch(scd.DirectoryPath, "b.txt", "b\n");
+
+ string path = Repository.Init(scd.DirectoryPath);
+
+ using (var repoWrite = new Repository(path))
+ using (var repoRead = new Repository(path))
+ {
+ var writeStatus = repoWrite.Index.RetrieveStatus();
+ Assert.True(writeStatus.IsDirty);
+ Assert.Equal(0, repoWrite.Index.Count);
+
+ var readStatus = repoRead.Index.RetrieveStatus();
+ Assert.True(readStatus.IsDirty);
+ Assert.Equal(0, repoRead.Index.Count);
+
+ repoWrite.Index.Stage("*");
+ repoWrite.Commit("message", Constants.Signature, Constants.Signature);
+
+ writeStatus = repoWrite.Index.RetrieveStatus();
+ Assert.False(writeStatus.IsDirty);
+ Assert.Equal(2, repoWrite.Index.Count);
+
+ readStatus = repoRead.Index.RetrieveStatus();
+ Assert.False(readStatus.IsDirty);
+ Assert.Equal(2, repoRead.Index.Count);
+ }
+ }
}
}