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:
authorEdward Thomson <ethomson@microsoft.com>2014-06-19 22:07:19 +0400
committerEdward Thomson <ethomson@microsoft.com>2014-06-24 00:01:44 +0400
commitfcb3711c64f535b57fb4e73c21d977e4fc13121f (patch)
tree6f3dad48d2f7ab589f5624a44a22b2e0a5eced52 /LibGit2Sharp.Tests
parent19cd6304bb8d935b5545ce4157c4519ce1b27b07 (diff)
repo.Reset() renamed items correctly
Diffstat (limited to 'LibGit2Sharp.Tests')
-rw-r--r--LibGit2Sharp.Tests/ResetIndexFixture.cs54
1 files changed, 54 insertions, 0 deletions
diff --git a/LibGit2Sharp.Tests/ResetIndexFixture.cs b/LibGit2Sharp.Tests/ResetIndexFixture.cs
index 23e6a1cc..0e774cd7 100644
--- a/LibGit2Sharp.Tests/ResetIndexFixture.cs
+++ b/LibGit2Sharp.Tests/ResetIndexFixture.cs
@@ -151,5 +151,59 @@ namespace LibGit2Sharp.Tests
repo.Reset(repo.Lookup<Commit>("5b5b025"), new[] { "new.txt", "non-existent-path-28.txt" }, new ExplicitPathsOptions()));
}
}
+
+ [Fact]
+ public void CanResetTheIndexWhenARenameExists()
+ {
+ using (var repo = new Repository(CloneStandardTestRepo()))
+ {
+ repo.Index.Move("branch_file.txt", "renamed_branch_file.txt");
+ repo.Reset(repo.Lookup<Commit>("32eab9c"));
+
+ RepositoryStatus status = repo.Index.RetrieveStatus();
+ Assert.Equal(0, status.Where(IsStaged).Count());
+ }
+ }
+
+ [Fact]
+ public void CanResetSourceOfARenameInIndex()
+ {
+ using (var repo = new Repository(CloneStandardTestRepo()))
+ {
+ repo.Index.Move("branch_file.txt", "renamed_branch_file.txt");
+
+ RepositoryStatus oldStatus = repo.Index.RetrieveStatus();
+ Assert.Equal(1, oldStatus.RenamedInIndex.Count());
+ Assert.Equal(FileStatus.Nonexistent, oldStatus["branch_file.txt"].State);
+ Assert.Equal(FileStatus.RenamedInIndex, oldStatus["renamed_branch_file.txt"].State);
+
+ repo.Reset(repo.Lookup<Commit>("32eab9c"), new string[] { "branch_file.txt" });
+
+ RepositoryStatus newStatus = repo.Index.RetrieveStatus();
+ Assert.Equal(0, newStatus.RenamedInIndex.Count());
+ Assert.Equal(FileStatus.Missing, newStatus["branch_file.txt"].State);
+ Assert.Equal(FileStatus.Added, newStatus["renamed_branch_file.txt"].State);
+ }
+ }
+
+ [Fact]
+ public void CanResetTargetOfARenameInIndex()
+ {
+ using (var repo = new Repository(CloneStandardTestRepo()))
+ {
+ repo.Index.Move("branch_file.txt", "renamed_branch_file.txt");
+
+ RepositoryStatus oldStatus = repo.Index.RetrieveStatus();
+ Assert.Equal(1, oldStatus.RenamedInIndex.Count());
+ Assert.Equal(FileStatus.RenamedInIndex, oldStatus["renamed_branch_file.txt"].State);
+
+ repo.Reset(repo.Lookup<Commit>("32eab9c"), new string[] { "renamed_branch_file.txt" });
+
+ RepositoryStatus newStatus = repo.Index.RetrieveStatus();
+ Assert.Equal(0, newStatus.RenamedInIndex.Count());
+ Assert.Equal(FileStatus.Untracked, newStatus["renamed_branch_file.txt"].State);
+ Assert.Equal(FileStatus.Removed, newStatus["branch_file.txt"].State);
+ }
+ }
}
}