8000 Enhance ObjectDatabase.CanMergeWithoutConflict() test coverage · thatfrankdev/libgit2sharp@a026f5d · GitHub
[go: up one dir, main page]

Skip to content

Commit a026f5d

Browse files
committed
Enhance ObjectDatabase.CanMergeWithoutConflict() test coverage
1 parent e1228da commit a026f5d

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

LibGit2Sharp.Tests/ObjectDatabaseFixture.cs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,46 @@ public void TestMergeIntoSelfHasNoConflicts()
668668
}
669669
}
670670

671+
[Fact]
672+
public void TestMergeIntoOtherUnbornBranchHasNoConflicts()
673+
{
674+
string path = SandboxMergeTestRepo();
675+
using (var repo = new Repository(path))
676+
{
677+
repo.Refs.UpdateTarget("HEAD", "refs/heads/unborn");
678+
679+
Touch(repo.Info.WorkingDirectory, "README", "Yeah!\n");
680+
repo.Index.Clear();
681+
repo.Stage("README");
682+
683+
repo.Commit("A new world, free of the burden of the history", Constants.Signature, Constants.Signature);
684+
685+
var master = repo.Branches["master"].Tip;
686+
var branch = repo.Branches["unborn"].Tip;
687+
688+
Assert.True(repo.ObjectDatabase.CanMergeWithoutConflict(master, branch));
689+
}
690+
}
691+
692+
[Fact]
693+
public void TestMergeIntoOtherUnbornBranchHasConflicts()
694+
{
695+
string path = SandboxMergeTestRepo();
696+
using (var repo = new Repository(path))
697+
{
698+
repo.Refs.UpdateTarget("HEAD", "refs/heads/unborn");
699+
700+
repo.Index.Replace(repo.Lookup<Commit>("conflicts"));
701+
702+
repo.Commit("A conflicting world, free of the burden of the history", Constants.Signature, Constants.Signature);
703+
704+
var master = repo.Branches["master"].Tip;
705+
var branch = repo.Branches["unborn"].Tip;
706+
707+
Assert.False(repo.ObjectDatabase.CanMergeWithoutConflict(master, branch));
708+
}
709+
}
710+
671711
[Fact]
672712
public void TestMergeIntoOtherBranchHasNoConflicts()
673713
{

0 commit comments

Comments
 (0)
0