}
private <T extends Closeable> OutputStream writeArchive(Format<T> fmt) {
- final String pfx = prefix == null ? "" : prefix; //$NON-NLS-1$
- try (final TreeWalk walk = new TreeWalk(repo)) {
- final T outa = fmt.createArchiveOutputStream(out, formatOptions);
- try (final RevWalk rw = new RevWalk(walk.getObjectReader())) {
+ try {
+ try (TreeWalk walk = new TreeWalk(repo);
+ RevWalk rw = new RevWalk(walk.getObjectReader())) {
+ final String pfx = prefix == null ? "" : prefix; //$NON-NLS-1$
+ final T outa = fmt.createArchiveOutputStream(out, formatOptions);
final MutableObjectId idBuf = new MutableObjectId();
final ObjectReader reader = walk.getObjectReader();
walk.setFilter(PathFilterGroup.createFromStrings(paths));
while (walk.next()) {
- final String name = pfx + walk.getPathString();
+ String name = pfx + walk.getPathString();
FileMode mode = walk.getFileMode(0);
if (walk.isSubtree())
fmt.putEntry(outa, name, mode, reader.open(idBuf));
}
outa.close();
+ return out;
} finally {
out.close();
}
- return out;
} catch (IOException e) {
// TODO(jrn): Throw finer-grained errors.
throw new JGitInternalException(