/// <summary> /// Create an iterator to walk the merge base of two commits. /// </summary> /// <param name="aIdx"> /// Index of the first commit in <seealso cref="SourceObjects"/>. /// </param> /// <param name="bIdx"> /// Index of the second commit in <seealso cref="SourceObjects"/>. /// </param> /// <returns> the new iterator </returns> /// <exception cref="IncorrectObjectTypeException"> /// one of the input objects is not a commit. /// </exception> /// <exception cref="IOException"> /// objects are missing or multiple merge bases were found. /// </exception> protected AbstractTreeIterator MergeBase(int aIdx, int bIdx) { if (_sourceCommits[aIdx] == null) { throw new IncorrectObjectTypeException(_sourceObjects[aIdx], Constants.TYPE_COMMIT); } if (_sourceCommits[bIdx] == null) { throw new IncorrectObjectTypeException(_sourceObjects[bIdx], Constants.TYPE_COMMIT); } _walk.reset(); _walk.setRevFilter(RevFilter.MERGE_BASE); _walk.markStart(_sourceCommits[aIdx]); _walk.markStart(_sourceCommits[bIdx]); RevCommit base1 = _walk.next(); if (base1 == null) { return(new EmptyTreeIterator()); } RevCommit base2 = _walk.next(); if (base2 != null) { throw new IOException("Multiple merge bases for:" + "\n " + _sourceCommits[aIdx].Name + "\n " + _sourceCommits[bIdx].Name + "found:" + "\n " + base1.Name + "\n " + base2.Name); } return(OpenTree(base1.Tree)); }