private static @NotNull Collection<Change> getDiffChanges(@NotNull Project project,
                                                            @NotNull GitRepository repository,
                                                            @NotNull VirtualFile file,
                                                            @NotNull String tagName) throws VcsException {
    FilePath filePath = VcsUtil.getFilePath(file);
    String refToCompare = GitTag.REFS_TAGS_PREFIX + tagName;
    GitRevisionNumber revisionNumber = new GitRevisionNumber(refToCompare);

    Collection<Change> changes =
      GitChangeUtils.getDiffWithWorkingDir(project, repository.getRoot(), refToCompare, Collections.singletonList(filePath), false);

    // if git returned no changes, we need to check that file exists in compareWith branch to avoid this error in diff dialog
    // a.e. when you perform compareWith for unversioned file
    if (changes.isEmpty() && GitHistoryUtils.getCurrentRevision(project, filePath, refToCompare) == null) {
      throw new VcsException(GitBundle.message("git.compare.with.tag.file.not.found.in.tag",
                                               file.isDirectory() ? 2 : 1, file.getPresentableUrl(), tagName));
    }

    ContentRevision revision = GitContentRevision.createRevision(filePath, revisionNumber, project);
    return changes.isEmpty() && !filePath.isDirectory() ? createChangesWithCurrentContentForFile(filePath, revision) : changes;
  }
private static @NotNull Collection<Change> getDiffChanges(@NotNull Project project,
                                                            @NotNull GitRepository repository,
                                                            @NotNull VirtualFile file,
                                                            @NotNull String tagName)