private @NotNull Set<VcsRef> readBranches(@NotNull GitRepository repository) {
    return computeWithSpan(myTracer, ReadingBranches.getName(), span -> {
      span.setAttribute("rootName", repository.getRoot().getName());
      VirtualFile root = repository.getRoot();
      repository.update();
      GitBranchesCollection branches = repository.getBranches();
      Collection<GitLocalBranch> localBranches = branches.getLocalBranches();
      Collection<GitRemoteBranch> remoteBranches = branches.getRemoteBranches();
      Set<VcsRef> refs = new HashSet<>(localBranches.size() + remoteBranches.size());
      for (GitLocalBranch localBranch : localBranches) {
        Hash hash = branches.getHash(localBranch);
        assert hash != null;
        refs.add(myVcsObjectsFactory.createRef(hash, localBranch.getName(), GitRefManager.LOCAL_BRANCH, root));
      }
      for (GitRemoteBranch remoteBranch : remoteBranches) {
        Hash hash = branches.getHash(remoteBranch);
        assert hash != null;
        refs.add(myVcsObjectsFactory.createRef(hash, remoteBranch.getNameForLocalOperations(), GitRefManager.REMOTE_BRANCH, root));
      }
      String currentRevision = repository.getCurrentRevision();
      if (currentRevision != null) { // null => fresh repository
        refs.add(myVcsObjectsFactory.createRef(HashImpl.build(currentRevision), GitUtil.HEAD, GitRefManager.HEAD, root));
      }
      return refs;
    });
  }
private @NotNull Set<VcsRef> readBranches(@NotNull GitRepository repository)