diff options
author | Matthias Sohn <matthias.sohn@sap.com> | 2020-05-06 09:36:52 +0200 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2020-05-06 10:16:35 +0200 |
commit | 231c44d553d9868795eafd9c8d87a2d3f7de50bd (patch) | |
tree | ab54d40a3eb1b4bd7f4c6f2c490b12ba0c5957cf | |
parent | b6d70a66ae6382e40290a78b2946b9ffa8c6d98f (diff) | |
download | jgit-231c44d553d9868795eafd9c8d87a2d3f7de50bd.tar.gz jgit-231c44d553d9868795eafd9c8d87a2d3f7de50bd.zip |
ApplyCommand: use Files#copy to copy file
This should be faster.
Change-Id: I404ec5e66731b3cf7a8e621cf1ff8748d109ea69
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/api/ApplyCommand.java | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/ApplyCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/ApplyCommand.java index e11e683f94..0d4b3da6a3 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/ApplyCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/ApplyCommand.java @@ -17,6 +17,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStreamWriter; import java.io.Writer; +import java.nio.file.Files; import java.nio.file.StandardCopyOption; import java.text.MessageFormat; import java.util.ArrayList; @@ -34,7 +35,6 @@ import org.eclipse.jgit.patch.FileHeader; import org.eclipse.jgit.patch.HunkHeader; import org.eclipse.jgit.patch.Patch; import org.eclipse.jgit.util.FileUtils; -import org.eclipse.jgit.util.IO; /** * Apply a patch to files and/or to the index. @@ -125,14 +125,9 @@ public class ApplyCommand extends GitCommand<ApplyResult> { break; case COPY: f = getFile(fh.getOldPath(), false); - byte[] bs = IO.readFully(f); - File target = getFile(fh.getNewPath(), true); - FileOutputStream fos = new FileOutputStream(target); - try { - fos.write(bs); - } finally { - fos.close(); - } + File target = getFile(fh.getNewPath(), false); + FileUtils.mkdirs(target.getParentFile(), true); + Files.copy(f.toPath(), target.toPath()); apply(target, fh); } r.addUpdatedFile(f); |