Skip to content

Commit 4ca2bbb

Browse files
committed
Merge remote-tracking branch 'upstream/master' into portable
2 parents 9fca61f + 802aeb4 commit 4ca2bbb

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed

LibGit2Sharp.Shared/Commands/Stage.cs

+2
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,8 @@ public static void Unstage(IRepository repository, IEnumerable<string> paths, Ex
199199
{
200200
repository.Index.Replace(repository.Head.Tip, paths, explicitPathsOptions);
201201
}
202+
203+
repository.Index.Write();
202204
}
203205

204206
/// <summary>

LibGit2Sharp.Tests.Shared/StageFixture.cs

+18
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,24 @@ public void CanStage(string relativePath, FileStatus currentStatus, bool doesCur
3333
}
3434
}
3535

36+
[Theory]
37+
[InlineData("deleted_unstaged_file.txt", FileStatus.DeletedFromIndex)]
38+
[InlineData("modified_unstaged_file.txt", FileStatus.ModifiedInIndex)]
39+
[InlineData("new_untracked_file.txt", FileStatus.NewInIndex)]
40+
public void StagingWritesIndex(string relativePath, FileStatus expectedStatus)
41+
{
42+
string path = SandboxStandardTestRepo();
43+
using (var repo = new Repository(path))
44+
{
45+
Commands.Stage(repo, relativePath);
46+
}
47+
48+
using (var repo = new Repository(path))
49+
{
50+
Assert.Equal(expectedStatus, repo.RetrieveStatus(relativePath));
51+
}
52+
}
53+
3654
[Fact]
3755
public void CanStageTheUpdationOfAStagedFile()
3856
{

LibGit2Sharp.Tests.Shared/UnstageFixture.cs

+19
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,25 @@ public void CanUnstage(
8484
}
8585
}
8686

87+
88+
[Theory]
89+
[InlineData("modified_staged_file.txt", FileStatus.ModifiedInWorkdir)]
90+
[InlineData("new_tracked_file.txt", FileStatus.NewInWorkdir)]
91+
[InlineData("deleted_staged_file.txt", FileStatus.DeletedFromWorkdir)]
92+
public void UnstagingWritesIndex(string relativePath, FileStatus expectedStatus)
93+
{
94+
string path = SandboxStandardTestRepo();
95+
using (var repo = new Repository(path))
96+
{
97+
Commands.Unstage(repo, relativePath);
98+
}
99+
100+
using (var repo = new Repository(path))
101+
{
102+
Assert.Equal(expectedStatus, repo.RetrieveStatus(relativePath));
103+
}
104+
}
105+
87106
[Theory]
88107
[InlineData("new_untracked_file.txt", FileStatus.NewInWorkdir)]
89108
[InlineData("where-am-I.txt", FileStatus.Nonexistent)]

0 commit comments

Comments
 (0)