/// <summary> /// Perform a three-way merge of two commits, looking up their /// commit ancestor. The returned index will contain the results /// of the merge and can be examined for conflicts. /// </summary> /// <param name="ours">The first tree</param> /// <param name="theirs">The second tree</param> /// <param name="options">The <see cref="MergeTreeOptions"/> controlling the merge</param> /// <returns>The <see cref="TransientIndex"/> containing the merged trees and any conflicts, or null if the merge stopped early due to conflicts. /// The index must be disposed by the caller.</returns> public virtual TransientIndex MergeCommitsIntoIndex(Commit ours, Commit theirs, MergeTreeOptions options) { Ensure.ArgumentNotNull(ours, "ours"); Ensure.ArgumentNotNull(theirs, "theirs"); options = options ?? new MergeTreeOptions(); bool earlyStop; var indexHandle = MergeCommits(ours, theirs, options, out earlyStop); if (earlyStop) { if (indexHandle != null) { indexHandle.Dispose(); } return(null); } var result = new TransientIndex(indexHandle, repo); return(result); }
/// <summary> /// Performs a cherry-pick of <paramref name="cherryPickCommit"/> onto <paramref name="cherryPickOnto"/> commit. /// </summary> /// <param name="cherryPickCommit">The commit to cherry-pick.</param> /// <param name="cherryPickOnto">The commit to cherry-pick onto.</param> /// <param name="mainline">Which commit to consider the parent for the diff when cherry-picking a merge commit.</param> /// <param name="options">The options for the merging in the cherry-pick operation.</param> /// <returns>The <see cref="TransientIndex"/> containing the cherry-pick result tree and any conflicts, or null if the merge stopped early due to conflicts. /// The index must be disposed by the caller. </returns> public virtual TransientIndex CherryPickCommitIntoIndex(Commit cherryPickCommit, Commit cherryPickOnto, int mainline, MergeTreeOptions options) { Ensure.ArgumentNotNull(cherryPickCommit, "cherryPickCommit"); Ensure.ArgumentNotNull(cherryPickOnto, "cherryPickOnto"); options = options ?? new MergeTreeOptions(); bool earlyStop; var indexHandle = CherryPickCommit(cherryPickCommit, cherryPickOnto, mainline, options, out earlyStop); if (earlyStop) { if (indexHandle != null) { indexHandle.Dispose(); } return(null); } var result = new TransientIndex(indexHandle, repo); return(result); }