8000 Introduce repo.Index.IsFullyMerged · rlazev/libgit2sharp@2546c05 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2546c05

Browse files
committed
Introduce repo.Index.IsFullyMerged
1 parent 1fdbc89 commit 2546c05

File tree

5 files changed

+35
-0
lines changed

5 files changed

+35
-0
lines changed

LibGit2Sharp.Tests/LibGit2Sharp.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
</ItemGroup>
5959
<ItemGroup>
6060
<Compile Include="CheckoutFixture.cs" />
61+
<Compile Include="MergeFixture.cs" />
6162
<Compile Include="CleanFixture.cs" />
6263
<Compile Include="CurrentOperationFixture.cs" />
6364
<Compile Include="MetaFixture.cs" />

LibGit2Sharp.Tests/MergeFixture.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using LibGit2Sharp.Tests.TestHelpers;
2+
using Xunit;
3+
4+
namespace LibGit2Sharp.Tests
5+
{
6+
public class MergeFixture : BaseFixture
7+
{
8+
[Fact]
9+
public void ANewRepoIsFullyMerged()
10+
{
11+
SelfCleaningDirectory scd = BuildSelfCleaningDirectory();
12+
using (var repo = Repository.Init(scd.DirectoryPath))
13+
{
14+
Assert.Equal(true, repo.Index.IsFullyMerged);
15+
}
16+
}
17+
}
18+
}

LibGit2Sharp/Core/NativeMethods.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,9 @@ internal static extern IndexEntrySafeHandle git_index_get_bypath(
414414
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath path,
415415
int stage);
416416

417+
[DllImport(libgit2)]
418+
internal static extern int git_index_has_conflicts(IndexSafeHandle index);
419+
417420
[DllImport(libgit2)]
418421
internal static extern int git_index_open(
419422
out IndexSafeHandle index,

LibGit2Sharp/Core/Proxy.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,11 @@ public static IndexEntrySafeHandle git_index_get_bypath(IndexSafeHandle index, F
685685
return handle.IsZero ? null : handle;
686686
}
687687

688+
public static bool git_index_has_conflicts(IndexSafeHandle index)
689+
{
690+
return NativeMethods.git_index_has_conflicts(index) != 0;
691+
}
692+
688693
public static IndexSafeHandle git_index_open(FilePath indexpath)
689694
{
690695
using (ThreadAffinity())

LibGit2Sharp/Index.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,14 @@ public virtual int Count
5858
get { return Proxy.git_index_entrycount(handle); }
5959
}
6060

61+
/// <summary>
62+
/// Determines if the index is free from conflicts.
63+
/// </summary>
64+
public virtual bool IsFullyMerged
65+
{
66+
get { return !Proxy.git_index_has_conflicts(handle); }
67+
}
68+
6169
/// <summary>
6270
/// Gets the <see cref = "IndexEntry" /> with the specified relative path.
6371
/// </summary>

0 commit comments

Comments
 (0)
0