private static @Nullable GitBranchTrackInfo convertBranchConfig(@Nullable BranchConfig branchConfig,
                                                                  @NotNull Collection<? extends GitLocalBranch> localBranches,
                                                                  @NotNull Collection<? extends GitRemoteBranch> remoteBranches) {
    if (branchConfig == null) {
      return null;
    }
    final String branchName = branchConfig.getName();
    String remoteName = branchConfig.getRemote();
    String mergeName = branchConfig.getMerge();
    String rebaseName = branchConfig.getRebase();

    if (StringUtil.isEmptyOrSpaces(mergeName) && StringUtil.isEmptyOrSpaces(rebaseName)) {
      LOG.debug("No branch." + branchName + ".merge/rebase item in the .git/config");
      return null;
    }
    if (StringUtil.isEmptyOrSpaces(remoteName)) {
      LOG.debug("No branch." + branchName + ".remote item in the .git/config");
      return null;
    }

    boolean merge = mergeName != null;
    final String remoteBranchName = StringUtil.unquoteString(merge ? mergeName : rebaseName);

    GitLocalBranch localBranch = findLocalBranch(branchName, localBranches);
    GitRemoteBranch remoteBranch = findRemoteBranch(remoteBranchName, remoteName, remoteBranches);
    if (localBranch == null || remoteBranch == null) {
      // obsolete record in .git/config: local or remote branch doesn't exist, but the tracking information wasn't removed
      LOG.debug("localBranch: " + localBranch + ", remoteBranch: " + remoteBranch);
      return null;
    }
    return new GitBranchTrackInfo(localBranch, remoteBranch, merge);
  }
private static @Nullable GitBranchTrackInfo convertBranchConfig(@Nullable BranchConfig branchConfig,
                                                                  @NotNull Collection<? extends GitLocalBranch> localBranches,
                                                                  @NotNull Collection<? extends GitRemoteBranch> remoteBranches)