]> source.dussan.org Git - jgit.git/commitdiff
Refactor DefaultRemoteReader for easier code reuse 08/28308/2
authorYuxuan 'fishy' Wang <fishywang@google.com>
Tue, 10 Jun 2014 22:44:15 +0000 (15:44 -0700)
committerYuxuan 'fishy' Wang <fishywang@google.com>
Tue, 10 Jun 2014 23:21:42 +0000 (16:21 -0700)
Change-Id: I7f326b4fc96198de7b424e15d8329bde7d7b39cf
Signed-off-by: Yuxuan 'fishy' Wang <fishywang@google.com>
org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/RepoCommand.java

index b967c968d4f6ede4ca388ea7adf4d51433801030..c999975539212e1e8f1d913dcab365fabf571c8a 100644 (file)
@@ -182,6 +182,15 @@ public class RepoCommand extends GitCommand<RevCommit> {
                                        .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<RevCommit> {
                                result = reader.open(oid).getBytes(Integer.MAX_VALUE);
                        } finally {
                                reader.release();
-                               FileUtils.delete(dir, FileUtils.RECURSIVE);
                        }
                        return result;
                }