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 b967c968d..c99997553 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; }