public static void writeBinaries(@Nullable Path basePath,
                                   @NotNull List<BinaryFilePatch> patches,
                                   @NotNull Writer writer) throws IOException {
    String lineSeparator = "\n"; //use it for git headers&binary content, otherwise git won't parse&apply it properly
    for (BinaryFilePatch filePatch : patches) {
      writeGitHeader(writer, basePath, filePatch, lineSeparator);
      byte[] afterContent = filePatch.getAfterContent();
      writer.write(getIndexHeader(filePatch.isNewFile() ? NOT_COMMITTED_HASH : getSha1ForContent(filePatch.getBeforeContent()),
                                  filePatch.isDeletedFile() ? NOT_COMMITTED_HASH : getSha1ForContent(afterContent)));
      writer.write(lineSeparator);
      writer.write(GIT_BINARY_HEADER);
      writer.write(lineSeparator);
      writer.write(String.format(LITERAL_HEADER, afterContent == null ? 0 : afterContent.length));
      writer.write(lineSeparator);
      try {
        BinaryEncoder.encode(new ByteArrayInputStream(afterContent != null ? afterContent : ArrayUtilRt.EMPTY_BYTE_ARRAY), writer);
      }
      catch (BinaryEncoder.BinaryPatchException e) {
        String afterFile = basePath == null ? filePatch.getAfterName() : basePath.resolve(filePatch.getAfterName()).toString();
        LOG.error("Can't write patch for binary file: " + afterFile, e);
      }
      writer.write(lineSeparator);
    }
  }
public static void writeBinaries(@Nullable Path basePath,
                                   @NotNull List<BinaryFilePatch> patches,
                                   @NotNull Writer writer)