diff options
author | Shawn O. Pearce <spearce@spearce.org> | 2010-06-30 18:56:20 -0700 |
---|---|---|
committer | Shawn O. Pearce <spearce@spearce.org> | 2010-06-30 18:56:20 -0700 |
commit | d04b7972d891a51b4b4c09128431961fece52e75 (patch) | |
tree | cb72972cbe303a7f45c35c3ab546d8d824affe4e | |
parent | a0fd06e5c2696cc6bed396fd513ec8e4465e399c (diff) | |
download | jgit-d04b7972d891a51b4b4c09128431961fece52e75.tar.gz jgit-d04b7972d891a51b4b4c09128431961fece52e75.zip |
Use copyTo during checkout of files to working tree
This way we can stream a large file through memory, rather than
loading the entire thing into a single contiguous byte array.
Change-Id: I3ada2856af2bf518f072edec242667a486fb0df1
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/lib/GitIndex.java | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/GitIndex.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/GitIndex.java index 0495d38a11..1df25ca708 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/GitIndex.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/GitIndex.java @@ -874,16 +874,15 @@ public class GitIndex { */ public void checkoutEntry(File wd, Entry e) throws IOException { ObjectLoader ol = db.open(e.sha1, Constants.OBJ_BLOB); - byte[] bytes = ol.getBytes(); File file = new File(wd, e.getName()); file.delete(); file.getParentFile().mkdirs(); - FileChannel channel = new FileOutputStream(file).getChannel(); - ByteBuffer buffer = ByteBuffer.wrap(bytes); - int j = channel.write(buffer); - if (j != bytes.length) - throw new IOException(MessageFormat.format(JGitText.get().couldNotWriteFile, file)); - channel.close(); + FileOutputStream dst = new FileOutputStream(file); + try { + ol.copyTo(dst); + } finally { + dst.close(); + } if (config_filemode() && File_hasExecute()) { if (FileMode.EXECUTABLE_FILE.equals(e.mode)) { if (!File_canExecute(file)) |