diff options
author | Edward Thomson <ethomson@microsoft.com> | 2014-07-03 17:36:28 +0400 |
---|---|---|
committer | Edward Thomson <ethomson@microsoft.com> | 2014-08-23 20:19:38 +0400 |
commit | cf8c5fb8d4fdbda992e96f1f42f239d6255592bb (patch) | |
tree | e16601bd9b984ba38aa67de86ebd3ad1f0342d64 /LibGit2Sharp.Tests | |
parent | ad12cca3ba989659b0189df36b47e4e8121d2976 (diff) |
Index.Stage: do not stage ignored files
Stage() now respects ignore files by default, similar to git.git.
Users accustomed to the old behavior may use the new StageOptions
class (in particular the IncludeIgnored bool) to override this
behavior.
Diffstat (limited to 'LibGit2Sharp.Tests')
-rw-r--r-- | LibGit2Sharp.Tests/StageFixture.cs | 24 | ||||
-rw-r--r-- | LibGit2Sharp.Tests/UnstageFixture.cs | 2 |
2 files changed, 21 insertions, 5 deletions
diff --git a/LibGit2Sharp.Tests/StageFixture.cs b/LibGit2Sharp.Tests/StageFixture.cs index 5499f578..3355645f 100644 --- a/LibGit2Sharp.Tests/StageFixture.cs +++ b/LibGit2Sharp.Tests/StageFixture.cs @@ -67,7 +67,7 @@ namespace LibGit2Sharp.Tests Assert.Null(repo.Index[relativePath]); Assert.Equal(status, repo.Index.RetrieveStatus(relativePath)); - Assert.Throws<UnmatchedPathException>(() => repo.Index.Stage(relativePath, new ExplicitPathsOptions())); + Assert.Throws<UnmatchedPathException>(() => repo.Index.Stage(relativePath, new StageOptions { ExplicitPathsOptions = new ExplicitPathsOptions() })); } } @@ -82,7 +82,7 @@ namespace LibGit2Sharp.Tests Assert.Equal(status, repo.Index.RetrieveStatus(relativePath)); Assert.DoesNotThrow(() => repo.Index.Stage(relativePath)); - Assert.DoesNotThrow(() => repo.Index.Stage(relativePath, new ExplicitPathsOptions { ShouldFailOnUnmatchedPath = false })); + Assert.DoesNotThrow(() => repo.Index.Stage(relativePath, new StageOptions { ExplicitPathsOptions = new ExplicitPathsOptions { ShouldFailOnUnmatchedPath = false } })); Assert.Equal(status, repo.Index.RetrieveStatus(relativePath)); } @@ -99,7 +99,7 @@ namespace LibGit2Sharp.Tests Assert.Equal(status, repo.Index.RetrieveStatus(relativePath)); repo.Index.Stage(relativePath); - repo.Index.Stage(relativePath, new ExplicitPathsOptions { ShouldFailOnUnmatchedPath = false }); + repo.Index.Stage(relativePath, new StageOptions { ExplicitPathsOptions = new ExplicitPathsOptions { ShouldFailOnUnmatchedPath = false } }); } } @@ -302,6 +302,22 @@ namespace LibGit2Sharp.Tests [Theory] [InlineData("ignored_file.txt")] [InlineData("ignored_folder/file.txt")] + public void CanIgnoreIgnoredPaths(string path) + { + using (var repo = new Repository(CloneStandardTestRepo())) + { + Touch(repo.Info.WorkingDirectory, ".gitignore", "ignored_file.txt\nignored_folder/\n"); + Touch(repo.Info.WorkingDirectory, path, "This file is ignored."); + + Assert.Equal(FileStatus.Ignored, repo.Index.RetrieveStatus(path)); + repo.Index.Stage("*"); + Assert.Equal(FileStatus.Ignored, repo.Index.RetrieveStatus(path)); + } + } + + [Theory] + [InlineData("ignored_file.txt")] + [InlineData("ignored_folder/file.txt")] public void CanStageIgnoredPaths(string path) { using (var repo = new Repository(CloneStandardTestRepo())) @@ -310,7 +326,7 @@ namespace LibGit2Sharp.Tests Touch(repo.Info.WorkingDirectory, path, "This file is ignored."); Assert.Equal(FileStatus.Ignored, repo.Index.RetrieveStatus(path)); - repo.Index.Stage(path); + repo.Index.Stage(path, new StageOptions { IncludeIgnored = true }); Assert.Equal(FileStatus.Added, repo.Index.RetrieveStatus(path)); } } diff --git a/LibGit2Sharp.Tests/UnstageFixture.cs b/LibGit2Sharp.Tests/UnstageFixture.cs index 47562a6f..d5878442 100644 --- a/LibGit2Sharp.Tests/UnstageFixture.cs +++ b/LibGit2Sharp.Tests/UnstageFixture.cs @@ -50,7 +50,7 @@ namespace LibGit2Sharp.Tests Assert.Equal(FileStatus.Ignored, repo.Index.RetrieveStatus(relativePath)); - repo.Index.Stage(relativePath); + repo.Index.Stage(relativePath, new StageOptions { IncludeIgnored = true }); Assert.Equal(FileStatus.Added, repo.Index.RetrieveStatus(relativePath)); repo.Index.Unstage(relativePath); |