public void buildPatch(
     @NotNull VcsRoot root,
     @Nullable String fromVersion,
     @NotNull String toVersion,
     @NotNull PatchBuilder builder,
     @NotNull CheckoutRules checkoutRules)
     throws IOException, VcsException {
   OperationContext context = createContext(root, "patch building");
   String fromRevision = fromVersion != null ? GitUtils.versionRevision(fromVersion) : null;
   String toRevision = GitUtils.versionRevision(toVersion);
   logBuildPatch(root, fromRevision, toRevision);
   GitPatchBuilderDispatcher gitPatchBuilder =
       new GitPatchBuilderDispatcher(
           myConfig, mySshKeyManager, context, builder, fromRevision, toRevision, checkoutRules);
   try {
     myCommitLoader.loadCommit(context, context.getGitRoot(), toRevision);
     gitPatchBuilder.buildPatch();
   } catch (Exception e) {
     throw context.wrapException(e);
   } finally {
     context.close();
   }
 }
 @NotNull
 public RepositoryStateData getCurrentState(@NotNull GitVcsRoot gitRoot) throws VcsException {
   String refInRoot = gitRoot.getRef();
   String fullRef = GitUtils.expandRef(refInRoot);
   Map<String, String> branchRevisions = new HashMap<String, String>();
   for (Ref ref : getRemoteRefs(gitRoot.getOriginalRoot()).values()) {
     if (!ref.getName().startsWith("ref")) continue;
     if (!gitRoot.isReportTags() && isTag(ref) && !fullRef.equals(ref.getName())) continue;
     branchRevisions.put(ref.getName(), getRevision(ref));
   }
   if (branchRevisions.get(fullRef) == null && !gitRoot.isIgnoreMissingDefaultBranch()) {
     throw new VcsException(
         "Cannot find revision of the default branch '"
             + refInRoot
             + "' of vcs root "
             + LogUtil.describe(gitRoot));
   }
   return RepositoryStateData.createVersionState(fullRef, branchRevisions);
 }