Skip to content

Commit 02940ce

Browse files
committed
stage tests: ensure we can stage conflicts
A file should be ignored when it does not exist in the repository, but conflicts should absolutely qualify as "existing in the repository". Ensure that we can stage ignored files correctly.
1 parent 2b03d65 commit 02940ce

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

LibGit2Sharp.Tests/StageFixture.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,5 +350,27 @@ public void IgnoredFilesAreOnlyStagedIfTheyreInTheRepo(string filename, FileStat
350350
Assert.Equal(expected, repo.RetrieveStatus(filename));
351351
}
352352
}
353+
354+
[Theory]
355+
[InlineData("ancestor-and-ours.txt", FileStatus.Unaltered)]
356+
[InlineData("ancestor-and-theirs.txt", FileStatus.NewInIndex)]
357+
[InlineData("ancestor-only.txt", FileStatus.Nonexistent)]
358+
[InlineData("conflicts-one.txt", FileStatus.ModifiedInIndex)]
359+
[InlineData("conflicts-two.txt", FileStatus.ModifiedInIndex)]
360+
[InlineData("ours-only.txt", FileStatus.Unaltered)]
361+
[InlineData("ours-and-theirs.txt", FileStatus.ModifiedInIndex)]
362+
[InlineData("theirs-only.txt", FileStatus.NewInIndex)]
363+
public void CanStageConflictedIgnoredFiles(string filename, FileStatus expected)
364+
{
365+
var path = SandboxMergedTestRepo();
366+
using (var repo = new Repository(path))
367+
{
368+
File.WriteAllText(Path.Combine(repo.Info.WorkingDirectory, ".gitignore"),
369+
String.Format("{0}\n", filename));
370+
371+
repo.Stage(filename);
372+
Assert.Equal(expected, repo.RetrieveStatus(filename));
373+
}
374+
}
353375
}
354376
}

0 commit comments

Comments
 (0)