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:18:50 +0400
committerEdward Thomson <ethomson@microsoft.com>2014-06-24 00:01:46 +0400
commit2378a56fadea4b9cdd57e0abead4c5fd061567bc (patch)
tree91d3b40fb201a966a1fa29d04e1a4da06c73b132 /LibGit2Sharp.Tests
parentfcb3711c64f535b57fb4e73c21d977e4fc13121f (diff)
repo.Unstage() renamed items correctly
Diffstat (limited to 'LibGit2Sharp.Tests')
-rw-r--r--LibGit2Sharp.Tests/UnstageFixture.cs55
1 files changed, 55 insertions, 0 deletions
diff --git a/LibGit2Sharp.Tests/UnstageFixture.cs b/LibGit2Sharp.Tests/UnstageFixture.cs
index fea1aea3..47562a6f 100644
--- a/LibGit2Sharp.Tests/UnstageFixture.cs
+++ b/LibGit2Sharp.Tests/UnstageFixture.cs
@@ -233,5 +233,60 @@ namespace LibGit2Sharp.Tests
Assert.Throws<ArgumentException>(() => repo.Index.Unstage(new string[] { null }));
}
}
+
+ [Fact]
+ public void CanUnstageSourceOfARename()
+ {
+ 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.Index.Unstage(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 CanUnstageTargetOfARename()
+ {
+ 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.Index.Unstage(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);
+ }
+ }
+
+ [Fact]
+ public void CanUnstageBothSidesOfARename()
+ {
+ using (var repo = new Repository(CloneStandardTestRepo()))
+ {
+ repo.Index.Move("branch_file.txt", "renamed_branch_file.txt");
+ repo.Index.Unstage(new string[] { "branch_file.txt", "renamed_branch_file.txt" });
+
+ RepositoryStatus status = repo.Index.RetrieveStatus();
+ Assert.Equal(FileStatus.Missing, status["branch_file.txt"].State);
+ Assert.Equal(FileStatus.Untracked, status["renamed_branch_file.txt"].State);
+ }
+ }
}
}