Skip to content

Commit 2b03d65

Browse files
ethomsonEdward Thomson
authored and
Edward Thomson
committed
stage tests: stage ignored files properly
Staging should ignore files that are ignored, unless the file already exists in the repository. Additional tests to validate this.
1 parent ba6b4b4 commit 2b03d65

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

LibGit2Sharp.Tests/StageFixture.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,5 +334,21 @@ public void CanStageIgnoredPaths(string path)
334334
Assert.Equal(FileStatus.NewInIndex, repo.RetrieveStatus(path));
335335
}
336336
}
337+
338+
[Theory]
339+
[InlineData("new_untracked_file.txt", FileStatus.Ignored)]
340+
[InlineData("modified_unstaged_file.txt", FileStatus.ModifiedInIndex)]
341+
public void IgnoredFilesAreOnlyStagedIfTheyreInTheRepo(string filename, FileStatus expected)
342+
{
343+
var path = SandboxStandardTestRepoGitDir();
344+
using (var repo = new Repository(path))
345+
{
346+
File.WriteAllText(Path.Combine(repo.Info.WorkingDirectory, ".gitignore"),
347+
String.Format("{0}\n", filename));
348+
349+
repo.Stage(filename);
350+
Assert.Equal(expected, repo.RetrieveStatus(filename));
351+
}
352+
}
337353
}
338354
}

0 commit comments

Comments
 (0)