Browse Source

ArchiveCommand.Format: pass output stream as first argument to putEntry

This is more consistent with other APIs where the output side is the
first parameter to be analagous to the left-hand side of an
assignment.

Change-Id: Iec46bd50bc973a38b77d8367296adf5474ba515f
stable-3.1
Jonathan Nieder 11 years ago
parent
commit
d8177d6e19
  1. 9
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/archive/ArchiveCommand.java
  2. 5
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/archive/TarFormat.java
  3. 5
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/archive/ZipFormat.java

9
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/archive/ArchiveCommand.java

@ -106,7 +106,7 @@ public class ArchiveCommand extends GitCommand<OutputStream> {
* ArchiveOutputStream out = format.createArchiveOutputStream(System.out); * ArchiveOutputStream out = format.createArchiveOutputStream(System.out);
* try { * try {
* for (...) { * for (...) {
* format.putEntry(path, mode, repo.open(objectId), out); * format.putEntry(out, path, mode, repo.open(objectId));
* } * }
* } finally { * } finally {
* out.close(); * out.close();
@ -114,9 +114,8 @@ public class ArchiveCommand extends GitCommand<OutputStream> {
*/ */
public static interface Format { public static interface Format {
ArchiveOutputStream createArchiveOutputStream(OutputStream s); ArchiveOutputStream createArchiveOutputStream(OutputStream s);
void putEntry(String path, FileMode mode, // void putEntry(ArchiveOutputStream out, String path, FileMode mode,
ObjectLoader loader, ArchiveOutputStream out) // ObjectLoader loader) throws IOException;
throws IOException;
} }
/** /**
@ -204,7 +203,7 @@ public class ArchiveCommand extends GitCommand<OutputStream> {
continue; continue;
walk.getObjectId(idBuf, 0); walk.getObjectId(idBuf, 0);
fmt.putEntry(name, mode, reader.open(idBuf), outa); fmt.putEntry(outa, name, mode, reader.open(idBuf));
} }
} finally { } finally {
outa.close(); outa.close();

5
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/archive/TarFormat.java

@ -57,8 +57,9 @@ class TarFormat implements ArchiveCommand.Format {
return new TarArchiveOutputStream(s); return new TarArchiveOutputStream(s);
} }
public void putEntry(String path, FileMode mode, ObjectLoader loader, public void putEntry(ArchiveOutputStream out,
ArchiveOutputStream out) throws IOException { String path, FileMode mode, ObjectLoader loader)
throws IOException {
if (mode == FileMode.SYMLINK) { if (mode == FileMode.SYMLINK) {
final TarArchiveEntry entry = new TarArchiveEntry( final TarArchiveEntry entry = new TarArchiveEntry(
path, TarConstants.LF_SYMLINK); path, TarConstants.LF_SYMLINK);

5
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/archive/ZipFormat.java

@ -56,8 +56,9 @@ class ZipFormat implements ArchiveCommand.Format {
return new ZipArchiveOutputStream(s); return new ZipArchiveOutputStream(s);
} }
public void putEntry(String path, FileMode mode, ObjectLoader loader, public void putEntry(ArchiveOutputStream out,
ArchiveOutputStream out) throws IOException { String path, FileMode mode, ObjectLoader loader)
throws IOException {
final ZipArchiveEntry entry = new ZipArchiveEntry(path); final ZipArchiveEntry entry = new ZipArchiveEntry(path);
if (mode == FileMode.REGULAR_FILE) { if (mode == FileMode.REGULAR_FILE) {

Loading…
Cancel
Save