From: Yuxuan 'fishy' Wang Date: Tue, 10 Jun 2014 22:44:15 +0000 (-0700) Subject: Refactor DefaultRemoteReader for easier code reuse X-Git-Tag: v3.5.0.201409071800-rc1~101^2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=afa2154e45a9bcb3cad886ca9a5c52c1dc786f0a;p=jgit.git Refactor DefaultRemoteReader for easier code reuse Change-Id: I7f326b4fc96198de7b424e15d8329bde7d7b39cf Signed-off-by: Yuxuan 'fishy' Wang --- diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/RepoCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/RepoCommand.java index b967c968d4..c999975539 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/RepoCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/RepoCommand.java @@ -182,6 +182,15 @@ public class RepoCommand extends GitCommand { .setURI(uri) .call() .getRepository(); + try { + return readFileFromRepo(repo, ref, path); + } finally { + FileUtils.delete(dir, FileUtils.RECURSIVE); + } + } + + protected byte[] readFileFromRepo(Repository repo, + String ref, String path) throws GitAPIException, IOException { ObjectReader reader = repo.newObjectReader(); byte[] result; try { @@ -189,7 +198,6 @@ public class RepoCommand extends GitCommand { result = reader.open(oid).getBytes(Integer.MAX_VALUE); } finally { reader.release(); - FileUtils.delete(dir, FileUtils.RECURSIVE); } return result; }