archive: Drop unnecessary empty comments and 'final' qualifiers on locals

Early JGit code used comments to inform the Eclipse formatter about
where to break lines and used final in the hope of making code faster.
The ArchiveCommand command implementation imitated that style.

Nowadays the project relies less on the Eclipse formatter and relies
more on Java having sane performance with local variables that are not
explicitly marked 'final'.  Removing the unnecessary empty comments and
'final' qualifiers makes this code more readable and more consistent
with recent JGit code.

Change-Id: I7a181432eda7e18bd32cf110d89c0efbe490c4f1
Signed-off-by: Jonathan Nieder <jrn@google.com>
This commit is contained in:
Jonathan Nieder 2015-05-27 16:25:49 -07:00
parent 1287cdaf33
commit a5778b6f41
2 changed files with 80 additions and 80 deletions

View File

@ -92,22 +92,22 @@ public void setUp() throws Exception {
@Ignore("Some versions of java.util.zip refuse to write an empty ZIP") @Ignore("Some versions of java.util.zip refuse to write an empty ZIP")
@Test @Test
public void testEmptyArchive() throws Exception { public void testEmptyArchive() throws Exception {
final byte[] result = CLIGitCommand.rawExecute( // byte[] result = CLIGitCommand.rawExecute(
"git archive --format=zip " + emptyTree, db); "git archive --format=zip " + emptyTree, db);
assertArrayEquals(new String[0], listZipEntries(result)); assertArrayEquals(new String[0], listZipEntries(result));
} }
@Test @Test
public void testEmptyTar() throws Exception { public void testEmptyTar() throws Exception {
final byte[] result = CLIGitCommand.rawExecute( // byte[] result = CLIGitCommand.rawExecute(
"git archive --format=tar " + emptyTree, db); "git archive --format=tar " + emptyTree, db);
assertArrayEquals(new String[0], listTarEntries(result)); assertArrayEquals(new String[0], listTarEntries(result));
} }
@Test @Test
public void testUnrecognizedFormat() throws Exception { public void testUnrecognizedFormat() throws Exception {
final String[] expect = new String[] { "fatal: Unknown archive format 'nonsense'" }; String[] expect = new String[] { "fatal: Unknown archive format 'nonsense'" };
final String[] actual = execute("git archive --format=nonsense " + emptyTree); String[] actual = execute("git archive --format=nonsense " + emptyTree);
assertArrayEquals(expect, actual); assertArrayEquals(expect, actual);
} }
@ -120,9 +120,9 @@ public void testArchiveWithFiles() throws Exception {
git.add().addFilepattern("c").call(); git.add().addFilepattern("c").call();
git.commit().setMessage("populate toplevel").call(); git.commit().setMessage("populate toplevel").call();
final byte[] result = CLIGitCommand.rawExecute( // byte[] result = CLIGitCommand.rawExecute(
"git archive --format=zip HEAD", db); "git archive --format=zip HEAD", db);
assertArrayEquals(new String[] { "a", "c" }, // assertArrayEquals(new String[] { "a", "c" },
listZipEntries(result)); listZipEntries(result));
} }
@ -135,9 +135,9 @@ private void commitGreeting() throws Exception {
@Test @Test
public void testDefaultFormatIsTar() throws Exception { public void testDefaultFormatIsTar() throws Exception {
commitGreeting(); commitGreeting();
final byte[] result = CLIGitCommand.rawExecute( // byte[] result = CLIGitCommand.rawExecute(
"git archive HEAD", db); "git archive HEAD", db);
assertArrayEquals(new String[] { "greeting" }, // assertArrayEquals(new String[] { "greeting" },
listTarEntries(result)); listTarEntries(result));
} }
@ -147,8 +147,8 @@ private static String shellQuote(String s) {
@Test @Test
public void testFormatOverridesFilename() throws Exception { public void testFormatOverridesFilename() throws Exception {
final File archive = new File(db.getWorkTree(), "format-overrides-name.tar"); File archive = new File(db.getWorkTree(), "format-overrides-name.tar");
final String path = archive.getAbsolutePath(); String path = archive.getAbsolutePath();
commitGreeting(); commitGreeting();
assertArrayEquals(new String[] { "" }, assertArrayEquals(new String[] { "" },
@ -162,8 +162,8 @@ public void testFormatOverridesFilename() throws Exception {
@Test @Test
public void testUnrecognizedExtensionMeansTar() throws Exception { public void testUnrecognizedExtensionMeansTar() throws Exception {
final File archive = new File(db.getWorkTree(), "example.txt"); File archive = new File(db.getWorkTree(), "example.txt");
final String path = archive.getAbsolutePath(); String path = archive.getAbsolutePath();
commitGreeting(); commitGreeting();
assertArrayEquals(new String[] { "" }, assertArrayEquals(new String[] { "" },
@ -176,8 +176,8 @@ public void testUnrecognizedExtensionMeansTar() throws Exception {
@Test @Test
public void testNoExtensionMeansTar() throws Exception { public void testNoExtensionMeansTar() throws Exception {
final File archive = new File(db.getWorkTree(), "example"); File archive = new File(db.getWorkTree(), "example");
final String path = archive.getAbsolutePath(); String path = archive.getAbsolutePath();
commitGreeting(); commitGreeting();
assertArrayEquals(new String[] { "" }, assertArrayEquals(new String[] { "" },
@ -189,8 +189,8 @@ public void testNoExtensionMeansTar() throws Exception {
@Test @Test
public void testExtensionMatchIsAnchored() throws Exception { public void testExtensionMatchIsAnchored() throws Exception {
final File archive = new File(db.getWorkTree(), "two-extensions.zip.bak"); File archive = new File(db.getWorkTree(), "two-extensions.zip.bak");
final String path = archive.getAbsolutePath(); String path = archive.getAbsolutePath();
commitGreeting(); commitGreeting();
assertArrayEquals(new String[] { "" }, assertArrayEquals(new String[] { "" },
@ -202,8 +202,8 @@ public void testExtensionMatchIsAnchored() throws Exception {
@Test @Test
public void testZipExtension() throws Exception { public void testZipExtension() throws Exception {
final File archiveWithDot = new File(db.getWorkTree(), "greeting.zip"); File archiveWithDot = new File(db.getWorkTree(), "greeting.zip");
final File archiveNoDot = new File(db.getWorkTree(), "greetingzip"); File archiveNoDot = new File(db.getWorkTree(), "greetingzip");
commitGreeting(); commitGreeting();
execute("git archive " + execute("git archive " +
@ -218,8 +218,8 @@ public void testZipExtension() throws Exception {
@Test @Test
public void testTarExtension() throws Exception { public void testTarExtension() throws Exception {
final File archive = new File(db.getWorkTree(), "tarball.tar"); File archive = new File(db.getWorkTree(), "tarball.tar");
final String path = archive.getAbsolutePath(); String path = archive.getAbsolutePath();
commitGreeting(); commitGreeting();
assertArrayEquals(new String[] { "" }, assertArrayEquals(new String[] { "" },
@ -234,8 +234,8 @@ public void testTgzExtensions() throws Exception {
commitGreeting(); commitGreeting();
for (String ext : Arrays.asList("tar.gz", "tgz")) { for (String ext : Arrays.asList("tar.gz", "tgz")) {
final File archiveWithDot = new File(db.getWorkTree(), "tarball." + ext); File archiveWithDot = new File(db.getWorkTree(), "tarball." + ext);
final File archiveNoDot = new File(db.getWorkTree(), "tarball" + ext); File archiveNoDot = new File(db.getWorkTree(), "tarball" + ext);
execute("git archive " + execute("git archive " +
shellQuote("--output=" + archiveWithDot.getAbsolutePath()) + " " + shellQuote("--output=" + archiveWithDot.getAbsolutePath()) + " " +
@ -253,8 +253,8 @@ public void testTbz2Extension() throws Exception {
commitGreeting(); commitGreeting();
for (String ext : Arrays.asList("tar.bz2", "tbz", "tbz2")) { for (String ext : Arrays.asList("tar.bz2", "tbz", "tbz2")) {
final File archiveWithDot = new File(db.getWorkTree(), "tarball." + ext); File archiveWithDot = new File(db.getWorkTree(), "tarball." + ext);
final File archiveNoDot = new File(db.getWorkTree(), "tarball" + ext); File archiveNoDot = new File(db.getWorkTree(), "tarball" + ext);
execute("git archive " + execute("git archive " +
shellQuote("--output=" + archiveWithDot.getAbsolutePath()) + " " + shellQuote("--output=" + archiveWithDot.getAbsolutePath()) + " " +
@ -272,8 +272,8 @@ public void testTxzExtension() throws Exception {
commitGreeting(); commitGreeting();
for (String ext : Arrays.asList("tar.xz", "txz")) { for (String ext : Arrays.asList("tar.xz", "txz")) {
final File archiveWithDot = new File(db.getWorkTree(), "tarball." + ext); File archiveWithDot = new File(db.getWorkTree(), "tarball." + ext);
final File archiveNoDot = new File(db.getWorkTree(), "tarball" + ext); File archiveNoDot = new File(db.getWorkTree(), "tarball" + ext);
execute("git archive " + execute("git archive " +
shellQuote("--output=" + archiveWithDot.getAbsolutePath()) + " " + shellQuote("--output=" + archiveWithDot.getAbsolutePath()) + " " +
@ -302,7 +302,7 @@ public void testArchiveWithSubdir() throws Exception {
git.add().addFilepattern("b").call(); git.add().addFilepattern("b").call();
git.commit().setMessage("add subdir").call(); git.commit().setMessage("add subdir").call();
final byte[] result = CLIGitCommand.rawExecute( // byte[] result = CLIGitCommand.rawExecute(
"git archive --format=zip master", db); "git archive --format=zip master", db);
String[] expect = { "a", "b.c", "b0c", "b/", "b/a", "b/b", "c" }; String[] expect = { "a", "b.c", "b0c", "b/", "b/a", "b/b", "c" };
String[] actual = listZipEntries(result); String[] actual = listZipEntries(result);
@ -328,7 +328,7 @@ public void testTarWithSubdir() throws Exception {
git.add().addFilepattern("b").call(); git.add().addFilepattern("b").call();
git.commit().setMessage("add subdir").call(); git.commit().setMessage("add subdir").call();
final byte[] result = CLIGitCommand.rawExecute( // byte[] result = CLIGitCommand.rawExecute(
"git archive --format=tar master", db); "git archive --format=tar master", db);
String[] expect = { "a", "b.c", "b0c", "b/", "b/a", "b/b", "c" }; String[] expect = { "a", "b.c", "b0c", "b/", "b/a", "b/b", "c" };
String[] actual = listTarEntries(result); String[] actual = listTarEntries(result);
@ -390,7 +390,7 @@ public void testPrefixDoesNotNormalizeDoubleSlash() throws Exception {
@Test @Test
public void testPrefixDoesNotNormalizeDoubleSlashInTar() throws Exception { public void testPrefixDoesNotNormalizeDoubleSlashInTar() throws Exception {
commitFoo(); commitFoo();
final byte[] result = CLIGitCommand.rawExecute( // byte[] result = CLIGitCommand.rawExecute(
"git archive --prefix=x// --format=tar master", db); "git archive --prefix=x// --format=tar master", db);
String[] expect = { "x//foo" }; String[] expect = { "x//foo" };
assertArrayEquals(expect, listTarEntries(result)); assertArrayEquals(expect, listTarEntries(result));
@ -421,7 +421,7 @@ public void testPrefixWithoutTrailingSlash() throws Exception {
@Test @Test
public void testTarPrefixWithoutTrailingSlash() throws Exception { public void testTarPrefixWithoutTrailingSlash() throws Exception {
commitBazAndFooSlashBar(); commitBazAndFooSlashBar();
final byte[] result = CLIGitCommand.rawExecute( // byte[] result = CLIGitCommand.rawExecute(
"git archive --prefix=my- --format=tar master", db); "git archive --prefix=my- --format=tar master", db);
String[] expect = { "my-baz", "my-foo/", "my-foo/bar" }; String[] expect = { "my-baz", "my-foo/", "my-foo/bar" };
String[] actual = listTarEntries(result); String[] actual = listTarEntries(result);
@ -441,7 +441,7 @@ public void testArchiveIncludesSubmoduleDirectory() throws Exception {
git.submoduleAdd().setURI("./.").setPath("b").call().close(); git.submoduleAdd().setURI("./.").setPath("b").call().close();
git.commit().setMessage("add submodule").call(); git.commit().setMessage("add submodule").call();
final byte[] result = CLIGitCommand.rawExecute( // byte[] result = CLIGitCommand.rawExecute(
"git archive --format=zip master", db); "git archive --format=zip master", db);
String[] expect = { ".gitmodules", "a", "b/", "c" }; String[] expect = { ".gitmodules", "a", "b/", "c" };
String[] actual = listZipEntries(result); String[] actual = listZipEntries(result);
@ -461,7 +461,7 @@ public void testTarIncludesSubmoduleDirectory() throws Exception {
git.submoduleAdd().setURI("./.").setPath("b").call().close(); git.submoduleAdd().setURI("./.").setPath("b").call().close();
git.commit().setMessage("add submodule").call(); git.commit().setMessage("add submodule").call();
final byte[] result = CLIGitCommand.rawExecute( // byte[] result = CLIGitCommand.rawExecute(
"git archive --format=tar master", db); "git archive --format=tar master", db);
String[] expect = { ".gitmodules", "a", "b/", "c" }; String[] expect = { ".gitmodules", "a", "b/", "c" };
String[] actual = listTarEntries(result); String[] actual = listTarEntries(result);
@ -491,7 +491,7 @@ public void testArchivePreservesMode() throws Exception {
git.commit().setMessage("three files with different modes").call(); git.commit().setMessage("three files with different modes").call();
final byte[] zipData = CLIGitCommand.rawExecute( // byte[] zipData = CLIGitCommand.rawExecute(
"git archive --format=zip master", db); "git archive --format=zip master", db);
writeRaw("zip-with-modes.zip", zipData); writeRaw("zip-with-modes.zip", zipData);
assertContainsEntryWithMode("zip-with-modes.zip", "-rw-", "plain"); assertContainsEntryWithMode("zip-with-modes.zip", "-rw-", "plain");
@ -520,7 +520,7 @@ public void testTarPreservesMode() throws Exception {
git.commit().setMessage("three files with different modes").call(); git.commit().setMessage("three files with different modes").call();
final byte[] archive = CLIGitCommand.rawExecute( // byte[] archive = CLIGitCommand.rawExecute(
"git archive --format=tar master", db); "git archive --format=tar master", db);
writeRaw("with-modes.tar", archive); writeRaw("with-modes.tar", archive);
assertTarContainsEntry("with-modes.tar", "-rw-r--r--", "plain"); assertTarContainsEntry("with-modes.tar", "-rw-r--r--", "plain");
@ -532,7 +532,7 @@ public void testTarPreservesMode() throws Exception {
@Test @Test
public void testArchiveWithLongFilename() throws Exception { public void testArchiveWithLongFilename() throws Exception {
String filename = ""; String filename = "";
final List<String> l = new ArrayList<String>(); List<String> l = new ArrayList<String>();
for (int i = 0; i < 20; i++) { for (int i = 0; i < 20; i++) {
filename = filename + "1234567890/"; filename = filename + "1234567890/";
l.add(filename); l.add(filename);
@ -543,7 +543,7 @@ public void testArchiveWithLongFilename() throws Exception {
git.add().addFilepattern("1234567890").call(); git.add().addFilepattern("1234567890").call();
git.commit().setMessage("file with long name").call(); git.commit().setMessage("file with long name").call();
final byte[] result = CLIGitCommand.rawExecute( // byte[] result = CLIGitCommand.rawExecute(
"git archive --format=zip HEAD", db); "git archive --format=zip HEAD", db);
assertArrayEquals(l.toArray(new String[l.size()]), assertArrayEquals(l.toArray(new String[l.size()]),
listZipEntries(result)); listZipEntries(result));
@ -552,7 +552,7 @@ public void testArchiveWithLongFilename() throws Exception {
@Test @Test
public void testTarWithLongFilename() throws Exception { public void testTarWithLongFilename() throws Exception {
String filename = ""; String filename = "";
final List<String> l = new ArrayList<String>(); List<String> l = new ArrayList<String>();
for (int i = 0; i < 20; i++) { for (int i = 0; i < 20; i++) {
filename = filename + "1234567890/"; filename = filename + "1234567890/";
l.add(filename); l.add(filename);
@ -563,7 +563,7 @@ public void testTarWithLongFilename() throws Exception {
git.add().addFilepattern("1234567890").call(); git.add().addFilepattern("1234567890").call();
git.commit().setMessage("file with long name").call(); git.commit().setMessage("file with long name").call();
final byte[] result = CLIGitCommand.rawExecute( // byte[] result = CLIGitCommand.rawExecute(
"git archive --format=tar HEAD", db); "git archive --format=tar HEAD", db);
assertArrayEquals(l.toArray(new String[l.size()]), assertArrayEquals(l.toArray(new String[l.size()]),
listTarEntries(result)); listTarEntries(result));
@ -571,34 +571,34 @@ public void testTarWithLongFilename() throws Exception {
@Test @Test
public void testArchivePreservesContent() throws Exception { public void testArchivePreservesContent() throws Exception {
final String payload = "“The quick brown fox jumps over the lazy dog!”"; String payload = "“The quick brown fox jumps over the lazy dog!”";
writeTrashFile("xyzzy", payload); writeTrashFile("xyzzy", payload);
git.add().addFilepattern("xyzzy").call(); git.add().addFilepattern("xyzzy").call();
git.commit().setMessage("add file with content").call(); git.commit().setMessage("add file with content").call();
final byte[] result = CLIGitCommand.rawExecute( // byte[] result = CLIGitCommand.rawExecute(
"git archive --format=zip HEAD", db); "git archive --format=zip HEAD", db);
assertArrayEquals(new String[] { payload }, // assertArrayEquals(new String[] { payload },
zipEntryContent(result, "xyzzy")); zipEntryContent(result, "xyzzy"));
} }
@Test @Test
public void testTarPreservesContent() throws Exception { public void testTarPreservesContent() throws Exception {
final String payload = "“The quick brown fox jumps over the lazy dog!”"; String payload = "“The quick brown fox jumps over the lazy dog!”";
writeTrashFile("xyzzy", payload); writeTrashFile("xyzzy", payload);
git.add().addFilepattern("xyzzy").call(); git.add().addFilepattern("xyzzy").call();
git.commit().setMessage("add file with content").call(); git.commit().setMessage("add file with content").call();
final byte[] result = CLIGitCommand.rawExecute( // byte[] result = CLIGitCommand.rawExecute(
"git archive --format=tar HEAD", db); "git archive --format=tar HEAD", db);
assertArrayEquals(new String[] { payload }, // assertArrayEquals(new String[] { payload },
tarEntryContent(result, "xyzzy")); tarEntryContent(result, "xyzzy"));
} }
private Process spawnAssumingCommandPresent(String... cmdline) { private Process spawnAssumingCommandPresent(String... cmdline) {
final File cwd = db.getWorkTree(); File cwd = db.getWorkTree();
final ProcessBuilder procBuilder = new ProcessBuilder(cmdline) // ProcessBuilder procBuilder = new ProcessBuilder(cmdline)
.directory(cwd) // .directory(cwd)
.redirectErrorStream(true); .redirectErrorStream(true);
Process proc = null; Process proc = null;
try { try {
@ -612,15 +612,15 @@ private Process spawnAssumingCommandPresent(String... cmdline) {
} }
private BufferedReader readFromProcess(Process proc) throws Exception { private BufferedReader readFromProcess(Process proc) throws Exception {
return new BufferedReader( // return new BufferedReader(
new InputStreamReader(proc.getInputStream(), "UTF-8")); new InputStreamReader(proc.getInputStream(), "UTF-8"));
} }
private void grepForEntry(String name, String mode, String... cmdline) // private void grepForEntry(String name, String mode, String... cmdline)
throws Exception { throws Exception {
final Process proc = spawnAssumingCommandPresent(cmdline); Process proc = spawnAssumingCommandPresent(cmdline);
proc.getOutputStream().close(); proc.getOutputStream().close();
final BufferedReader reader = readFromProcess(proc); BufferedReader reader = readFromProcess(proc);
try { try {
String line; String line;
while ((line = reader.readLine()) != null) while ((line = reader.readLine()) != null)
@ -672,20 +672,20 @@ private void assertIsXz(File file) throws Exception {
assertMagic(new byte[] { (byte) 0xfd, '7', 'z', 'X', 'Z', 0 }, file); assertMagic(new byte[] { (byte) 0xfd, '7', 'z', 'X', 'Z', 0 }, file);
} }
private void assertContainsEntryWithMode(String zipFilename, String mode, String name) // private void assertContainsEntryWithMode(String zipFilename, String mode, String name)
throws Exception { throws Exception {
grepForEntry(name, mode, "zipinfo", zipFilename); grepForEntry(name, mode, "zipinfo", zipFilename);
} }
private void assertTarContainsEntry(String tarfile, String mode, String name) // private void assertTarContainsEntry(String tarfile, String mode, String name)
throws Exception { throws Exception {
grepForEntry(name, mode, "tar", "tvf", tarfile); grepForEntry(name, mode, "tar", "tvf", tarfile);
} }
private void writeRaw(String filename, byte[] data) // private void writeRaw(String filename, byte[] data)
throws IOException { throws IOException {
final File path = new File(db.getWorkTree(), filename); File path = new File(db.getWorkTree(), filename);
final OutputStream out = new FileOutputStream(path); OutputStream out = new FileOutputStream(path);
try { try {
out.write(data); out.write(data);
} finally { } finally {
@ -694,8 +694,8 @@ private void writeRaw(String filename, byte[] data) //
} }
private static String[] listZipEntries(byte[] zipData) throws IOException { private static String[] listZipEntries(byte[] zipData) throws IOException {
final List<String> l = new ArrayList<String>(); List<String> l = new ArrayList<String>();
final ZipInputStream in = new ZipInputStream( // ZipInputStream in = new ZipInputStream(
new ByteArrayInputStream(zipData)); new ByteArrayInputStream(zipData));
ZipEntry e; ZipEntry e;
@ -706,9 +706,9 @@ private static String[] listZipEntries(byte[] zipData) throws IOException {
} }
private static Future<Object> writeAsync(final OutputStream stream, final byte[] data) { private static Future<Object> writeAsync(final OutputStream stream, final byte[] data) {
final ExecutorService executor = Executors.newSingleThreadExecutor(); ExecutorService executor = Executors.newSingleThreadExecutor();
return executor.submit(new Callable<Object>() { // return executor.submit(new Callable<Object>() {
public Object call() throws IOException { public Object call() throws IOException {
try { try {
stream.write(data); stream.write(data);
@ -721,13 +721,13 @@ public Object call() throws IOException {
} }
private String[] listTarEntries(byte[] tarData) throws Exception { private String[] listTarEntries(byte[] tarData) throws Exception {
final List<String> l = new ArrayList<String>(); List<String> l = new ArrayList<String>();
final Process proc = spawnAssumingCommandPresent("tar", "tf", "-"); Process proc = spawnAssumingCommandPresent("tar", "tf", "-");
final BufferedReader reader = readFromProcess(proc); BufferedReader reader = readFromProcess(proc);
final OutputStream out = proc.getOutputStream(); OutputStream out = proc.getOutputStream();
// Dump tarball to tar stdin in background // Dump tarball to tar stdin in background
final Future<?> writing = writeAsync(out, tarData); Future<?> writing = writeAsync(out, tarData);
try { try {
String line; String line;
@ -742,9 +742,9 @@ private String[] listTarEntries(byte[] tarData) throws Exception {
} }
} }
private static String[] zipEntryContent(byte[] zipData, String path) // private static String[] zipEntryContent(byte[] zipData, String path)
throws IOException { throws IOException {
final ZipInputStream in = new ZipInputStream( // ZipInputStream in = new ZipInputStream(
new ByteArrayInputStream(zipData)); new ByteArrayInputStream(zipData));
ZipEntry e; ZipEntry e;
while ((e = in.getNextEntry()) != null) { while ((e = in.getNextEntry()) != null) {
@ -752,8 +752,8 @@ private static String[] zipEntryContent(byte[] zipData, String path) //
continue; continue;
// found! // found!
final List<String> l = new ArrayList<String>(); List<String> l = new ArrayList<String>();
final BufferedReader reader = new BufferedReader( // BufferedReader reader = new BufferedReader(
new InputStreamReader(in, "UTF-8")); new InputStreamReader(in, "UTF-8"));
String line; String line;
while ((line = reader.readLine()) != null) while ((line = reader.readLine()) != null)
@ -765,13 +765,13 @@ private static String[] zipEntryContent(byte[] zipData, String path) //
return null; return null;
} }
private String[] tarEntryContent(byte[] tarData, String path) // private String[] tarEntryContent(byte[] tarData, String path)
throws Exception { throws Exception {
final List<String> l = new ArrayList<String>(); List<String> l = new ArrayList<String>();
final Process proc = spawnAssumingCommandPresent("tar", "Oxf", "-", path); Process proc = spawnAssumingCommandPresent("tar", "Oxf", "-", path);
final BufferedReader reader = readFromProcess(proc); BufferedReader reader = readFromProcess(proc);
final OutputStream out = proc.getOutputStream(); OutputStream out = proc.getOutputStream();
final Future<?> writing = writeAsync(out, tarData); Future<?> writing = writeAsync(out, tarData);
try { try {
String line; String line;

View File

@ -367,10 +367,10 @@ private <T extends Closeable> OutputStream writeArchive(Format<T> fmt) {
try { try {
try (TreeWalk walk = new TreeWalk(repo); try (TreeWalk walk = new TreeWalk(repo);
RevWalk rw = new RevWalk(walk.getObjectReader())) { RevWalk rw = new RevWalk(walk.getObjectReader())) {
final String pfx = prefix == null ? "" : prefix; //$NON-NLS-1$ String pfx = prefix == null ? "" : prefix; //$NON-NLS-1$
final T outa = fmt.createArchiveOutputStream(out, formatOptions); T outa = fmt.createArchiveOutputStream(out, formatOptions);
final MutableObjectId idBuf = new MutableObjectId(); MutableObjectId idBuf = new MutableObjectId();
final ObjectReader reader = walk.getObjectReader(); ObjectReader reader = walk.getObjectReader();
walk.reset(rw.parseTree(tree)); walk.reset(rw.parseTree(tree));
if (!paths.isEmpty()) if (!paths.isEmpty())
@ -414,7 +414,7 @@ private <T extends Closeable> OutputStream writeArchive(Format<T> fmt) {
public OutputStream call() throws GitAPIException { public OutputStream call() throws GitAPIException {
checkCallable(); checkCallable();
final Format<?> fmt; Format<?> fmt;
if (format == null) if (format == null)
fmt = formatBySuffix(suffix); fmt = formatBySuffix(suffix);
else else