private @NotNull GitUpdateResult handleMergeFailure(MergeLineListener mergeLineListener,
                                                      GitMessageWithFilesDetector untrackedFilesWouldBeOverwrittenByMergeDetector,
                                                      GitCommandResult commandResult) {
    final MergeError error = mergeLineListener.getMergeError();
    LOG.info("merge error: " + error);
    if (error == MergeError.CONFLICT) {
      LOG.info("Conflict detected");
      final boolean allMerged =
        new MyConflictResolver(myProject, myRoot).merge();
      return allMerged ? GitUpdateResult.SUCCESS_WITH_RESOLVED_CONFLICTS : GitUpdateResult.INCOMPLETE;
    }
    else if (error == MergeError.LOCAL_CHANGES) {
      LOG.info("Local changes would be overwritten by merge");
      final List<FilePath> paths = getFilesOverwrittenByMerge(mergeLineListener.getOutput());
      final Collection<Change> changes = getLocalChangesFilteredByFiles(paths);
      UIUtil.invokeAndWaitIfNeeded(() -> {
        LoadingCommittedChangeListPanel panel = new LoadingCommittedChangeListPanel(myProject);
        panel.setChanges(changes, null);
        panel.setDescription(GitBundle.message("warning.your.local.changes.would.be.overwritten.by.merge"));

        ChangeListViewerDialog.showDialog(myProject, null, panel);
      });
      return GitUpdateResult.ERROR;
    }
    else if (untrackedFilesWouldBeOverwrittenByMergeDetector.wasMessageDetected()) {
      LOG.info("handleMergeFailure: untracked files would be overwritten by merge");
      GitUntrackedFilesHelper.notifyUntrackedFilesOverwrittenBy(myProject, myRoot,
                                                                untrackedFilesWouldBeOverwrittenByMergeDetector.getRelativeFilePaths(),
                                                                GitBundle.message("merge.operation.name"), null);
      return GitUpdateResult.ERROR;
    }
    else {
      LOG.info("Unknown error: " + commandResult.getErrorOutputAsJoinedString());
      VcsNotifier.getInstance(myProject)
        .notifyError(MERGE_ERROR, GitBundle.message("notification.title.error.merging"), commandResult.getErrorOutputAsHtmlString());
      return GitUpdateResult.ERROR;
    }
  }
private @NotNull GitUpdateResult handleMergeFailure(MergeLineListener mergeLineListener,
                                                      GitMessageWithFilesDetector untrackedFilesWouldBeOverwrittenByMergeDetector,
                                                      GitCommandResult commandResult)