Skip to content

Commit 5e60873

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

File tree

2 files changed

+12
-27
lines changed

2 files changed

+12
-27
lines changed

LibGit2Sharp/IRepository.cs

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

229229
/// <summary>
230230
/// Analyze the possibilities of updating HEAD with the given commit(s).
231+
/// <para>
232+
/// It expects objects convertible to annotated commits, so <see cref="LibGit2Sharp.Reference"/> and
233+
/// <see cref="LibGit2Sharp.Commit"/> also work as inputs.
234+
/// </para>
231235
/// </summary>
232236
/// <param name="commits">Commits to merge into HEAD</param>
233237
/// <returns>Which update methods are possible and which preference the user has specified</returns>
234-
MergeAnalysisResult AnalyzeMerge(params Commit[] commits);
235-
236-
237-
/// <summary>
238-
/// Analyze the possibilities of updating HEAD with the given reference(s)
239-
/// </summary>
240-
/// <param name="references">References to merge into HEAD</param>
241-
/// <returns>Which update methods are possible and which preference the user has specified</returns>
242-
MergeAnalysisResult AnalyzeMerge(params Reference[] references);
238+
MergeAnalysisResult AnalyzeMerge(params IAnnotatedCommit[] commits);
243239

244240
/// <summary>
245241
/// Access to Rebase functionality.

LibGit2Sharp/Repository.cs

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

14241424
/// <summary>
14251425
/// Analyze the possibilities of updating HEAD with the given commit(s).
1426+
/// <para>
1427+
/// It expects objects convertible to annotated commits, so <see cref="LibGit2Sharp.Reference"/> and
1428+
/// <see cref="LibGit2Sharp.Commit"/> also work as inputs.
1429+
/// </para>
14261430
/// </summary>
14271431
/// <param name="commits">Commits to merge into HEAD</param>
14281432
/// <returns>Which update methods are possible and which preference the user has specified</returns>
1429-
public MergeAnalysisResult AnalyzeMerge(params Commit[] commits)
1430-
{
1431-
using (var handles = new DisposableArray<AnnotatedCommitHandle>(commits.Select(commit =>
1432-
Proxy.git_annotated_commit_lookup(Handle, commit.Id.Oid)).ToArray()))
1433-
{
1434-
return AnalyzeMerge(handles);
1435-
}
1436-
}
1437-
1438-
/// <summary>
1439-
/// Analyze the possibilities of updating HEAD with the given reference(s)
1440-
/// </summary>
1441-
/// <param name="references">References to merge into HEAD</param>
1442-
/// <returns>Which update methods are possible and which preference the user has specified</returns>
1443-
public MergeAnalysisResult AnalyzeMerge(params Reference[] references)
1433+
public MergeAnalysisResult AnalyzeMerge(params IAnnotatedCommit[] commits)
14441434
{
1445-
using (var refHandles = new DisposableArray<ReferenceHandle>(references.Select(r => refs.RetrieveReferencePtr(r.CanonicalName))))
1446-
using (var handles = new DisposableArray<AnnotatedCommitHandle>(refHandles.Array.Select(rh => Proxy.git_annotated_commit_from_ref(Handle, rh))))
1435+
using (var annotated = new DisposableArray<AnnotatedCommit>(commits.Select(c => c.GetAnnotatedCommit())))
14471436
{
1448-
return AnalyzeMerge(handles);
1437+
return AnalyzeMerge(annotated.Array.Select(c => c.Handle).ToArray());
14491438
}
14501439
}
14511440

0 commit comments

Comments
 (0)