@Override
  public void actionPerformed(final AnActionEvent event) {
    final Project project = event.getProject();
    assert project != null;

    final VirtualFile file = getAffectedFile(event);

    GitRepositoryManager manager = GitUtil.getRepositoryManager(project);
    GitRepository repository = manager.getRepositoryForFile(file);
    assert repository != null;

    GitBranch currentBranch = repository.getCurrentBranch();
    final String head;
    if (currentBranch == null) {
      String currentRevision = repository.getCurrentRevision();
      LOG.assertTrue(
          currentRevision != null,
          "Current revision is null for "
              + repository
              + ". Compare with branch shouldn't be available for fresh repository");
      head = DvcsUtil.getShortHash(currentRevision);
    } else {
      head = currentBranch.getName();
    }
    final List<String> branchNames = getBranchNamesExceptCurrent(repository);

    // prepare and invoke popup
    final JBList list = new JBList(branchNames);

    JBPopupFactory.getInstance()
        .createListPopupBuilder(list)
        .setTitle("Select branch to compare")
        .setItemChoosenCallback(new OnBranchChooseRunnable(project, file, head, list))
        .setAutoselectOnMouseMove(true)
        .createPopup()
        .showInBestPositionFor(event.getDataContext());
  }
 /**
  * @return the short revision number. The revision number likely unambiguously identify local
  *     revision, however in rare cases there could be conflicts.
  */
 @NotNull
 public String getShortRev() {
   return DvcsUtil.getShortHash(myRevisionHash);
 }