Skip to content

Commit a59b5cb

Browse files
committed
Accept IAnnotatedCommit in AnalyzeMerge
Instead of the multiple overloads, accept IAnnotatedCommit so the user can provide commits or references.
1 parent b2b3e38 commit a59b5cb

2 files changed

Lines changed: 12 additions & 27 deletions

File tree

LibGit2Sharp/IRepository.cs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -217,18 +217,14 @@ public interface IRepository : IDisposable
217217

218218
/// <summary>
219219
/// Analyze the possibilities of updating HEAD with the given commit(s).
220+
/// <para>
221+
/// It expects objects convertible to annotated commits, so <see cref="LibGit2Sharp.Reference"/> and
222+
/// <see cref="LibGit2Sharp.Commit"/> also work as inputs.
223+
/// </para>
220224
/// </summary>
221225
/// <param name="commits">Commits to merge into HEAD</param>
222226
/// <returns>Which update methods are possible and which preference the user has specified</returns>
223-
MergeAnalysisResult AnalyzeMerge(params Commit[] commits);
224-
225-
226-
/// <summary>
227-
/// Analyze the possibilities of updating HEAD with the given reference(s)
228-
/// </summary>
229-
/// <param name="references">References to merge into HEAD</param>
230-
/// <returns>Which update methods are possible and which preference the user has specified</returns>
231-
MergeAnalysisResult AnalyzeMerge(params Reference[] references);
227+
MergeAnalysisResult AnalyzeMerge(params IAnnotatedCommit[] commits);
232228

233229
/// <summary>
234230
/// Access to Rebase functionality.

LibGit2Sharp/Repository.cs

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1444,29 +1444,18 @@ private MergeAnalysisResult AnalyzeMerge(AnnotatedCommitHandle[] annotatedCommit
14441444

14451445
/// <summary>
14461446
/// Analyze the possibilities of updating HEAD with the given commit(s).
1447+
/// <para>
1448+
/// It expects objects convertible to annotated commits, so <see cref="LibGit2Sharp.Reference"/> and
1449+
/// <see cref="LibGit2Sharp.Commit"/> also work as inputs.
1450+
/// </para>
14471451
/// </summary>
14481452
/// <param name="commits">Commits to merge into HEAD</param>
14491453
/// <returns>Which update methods are possible and which preference the user has specified</returns>
1450-
public MergeAnalysisResult AnalyzeMerge(params Commit[] commits)
1451-
{
1452-
using (var handles = new DisposableArray<AnnotatedCommitHandle>(commits.Select(commit =>
1453-
Proxy.git_annotated_commit_lookup(Handle, commit.Id.Oid)).ToArray()))
1454-
{
1455-
return AnalyzeMerge(handles);
1456-
}
1457-
}
1458-
1459-
/// <summary>
1460-
/// Analyze the possibilities of updating HEAD with the given reference(s)
1461-
/// </summary>
1462-
/// <param name="references">References to merge into HEAD</param>
1463-
/// <returns>Which update methods are possible and which preference the user has specified</returns>
1464-
public MergeAnalysisResult AnalyzeMerge(params Reference[] references)
1454+
public MergeAnalysisResult AnalyzeMerge(params IAnnotatedCommit[] commits)
14651455
{
1466-
using (var refHandles = new DisposableArray<ReferenceHandle>(references.Select(r => refs.RetrieveReferencePtr(r.CanonicalName))))
1467-
using (var handles = new DisposableArray<AnnotatedCommitHandle>(refHandles.Array.Select(rh => Proxy.git_annotated_commit_from_ref(Handle, rh))))
1456+
using (var annotated = new DisposableArray<AnnotatedCommit>(commits.Select(c => c.GetAnnotatedCommit())))
14681457
{
1469-
return AnalyzeMerge(handles);
1458+
return AnalyzeMerge(annotated.Array.Select(c => c.Handle).ToArray());
14701459
}
14711460
}
14721461

0 commit comments

Comments
 (0)