From afa2154e45a9bcb3cad886ca9a5c52c1dc786f0a Mon Sep 17 00:00:00 2001 From: Yuxuan 'fishy' Wang Date: Tue, 10 Jun 2014 15:44:15 -0700 Subject: [PATCH] Refactor DefaultRemoteReader for easier code reuse Change-Id: I7f326b4fc96198de7b424e15d8329bde7d7b39cf Signed-off-by: Yuxuan 'fishy' Wang --- .../src/org/eclipse/jgit/gitrepo/RepoCommand.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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; } -- 2.39.5