]> source.dussan.org Git - jgit.git/commit
ArchiveCommand: Allow to pass options to underlying stream 87/41887/3
authorDavid Ostrovsky <david@ostrovsky.org>
Sun, 15 Feb 2015 19:31:29 +0000 (20:31 +0100)
committerDavid Ostrovsky <david@ostrovsky.org>
Fri, 20 Feb 2015 00:40:06 +0000 (01:40 +0100)
commitc0c4c6f09ac1d601a5d9fe9855e36e4b96b10335
treeca02a75898d38203c510efef4037553e597691b4
parent6c1f7393882baf8464859136a70199ea96fcae0f
ArchiveCommand: Allow to pass options to underlying stream

Current ArchiveCommand design doesn't allow to pass in options to
underlying stream implementations. To overcome this, client has to
implement custom format implementation (it cannot be derived from
the existing one, because the classes are marked as final), and set
the options using ThreadLocal, before the method

  ArchiveOutputStream createArchiveOutputStream(OutputStream s)

is get called.

This change extends the ArchiveCommand.Format by allowing to pass
option map during creation of ArchiveOutputStream.

ArchiveCommand is extended correspondingly. That way client can
easily pass options to the underlying streams:

  Map<String, Object> level = ImmutableMap.<String, Object> of(
      "level", new Integer(9));
  new ArchiveCommand(repo)
      .setFormat("zip")
      .setFormatOptions(level)
      .setTree(tree)
      .setPaths(paths)
      .setPrefix(prefix)
      .setOutputStream(sidebandOut)
      .call();

Change-Id: I1d92a1e5249117487da39d19c7593e4b812ad97a
Signed-off-by: David Ostrovsky <david@ostrovsky.org>
org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/BaseFormat.java [new file with mode: 0644]
org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/TarFormat.java
org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/Tbz2Format.java
org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/TgzFormat.java
org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/TxzFormat.java
org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/ZipFormat.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ArchiveCommandTest.java
org.eclipse.jgit/src/org/eclipse/jgit/api/ArchiveCommand.java
org.eclipse.jgit/src/org/eclipse/jgit/util/StringUtils.java