Fix merging changes into an empty repository
If an initial change for an empty repository is pushed and the submit type is MERGE_ALWAYS, on submit the change gets stuck in the 'Submitted, Merge Pending' state. Merging the change fails because the repository is empty and there is no commit with which the merge can be done. When trying to do the merge there is a NullPointerException because mergeTip is null. The same NullPointerException can happen with the MERGE_IF_NECESSARY submit type. Here the initial change can be successfully merged because this will be done as a fast forward. However if in this situation there would be other changes to be merged in the queue and a merge would be necessary for one of them the NullPointerException would occur. Change-Id: Id1526eb8759dbac028a5b2c2a76b1dbea7c330a6 Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
This commit is contained in:
		@@ -25,9 +25,16 @@ public class MergeIfNecessary extends SubmitStrategy {
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  @Override
 | 
			
		||||
  protected CodeReviewCommit _run(final CodeReviewCommit mergeTip,
 | 
			
		||||
      final List<CodeReviewCommit> toMerge) throws MergeException {
 | 
			
		||||
  protected CodeReviewCommit _run(CodeReviewCommit mergeTip,
 | 
			
		||||
      List<CodeReviewCommit> toMerge) throws MergeException {
 | 
			
		||||
    args.mergeUtil.reduceToMinimalMerge(args.mergeSorter, toMerge);
 | 
			
		||||
 | 
			
		||||
    if (mergeTip == null) {
 | 
			
		||||
      // The branch is unborn. Take a fast-forward resolution to
 | 
			
		||||
      // create the branch.
 | 
			
		||||
      mergeTip = toMerge.remove(0);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    CodeReviewCommit newMergeTip =
 | 
			
		||||
        args.mergeUtil.getFirstFastForward(mergeTip, args.rw, toMerge);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user