summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit
diff options
context:
space:
mode:
authorRobin Rosenberg <robin.rosenberg@dewire.com>2012-11-27 08:51:31 +0100
committerRobin Rosenberg <robin.rosenberg@dewire.com>2012-12-27 17:29:13 +0100
commit92893d1f92b12922a41accd53da19b074090f15e (patch)
tree0d2e7f3e85c314d06f7922e2f1557d13f8230ca1 /org.eclipse.jgit
parentc310fa0c802f40a774edb58641de3ac5bfad0e2c (diff)
downloadjgit-92893d1f92b12922a41accd53da19b074090f15e.tar.gz
jgit-92893d1f92b12922a41accd53da19b074090f15e.zip
Do not perform character translation on copies in patches
Translation is unnecessary and risks damaging the file. Also ensure that we close the file if an I/O error occurs. Change-Id: Ieae6eb941fdeaa61f2611f4cd14dd39117aa12f9
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/api/ApplyCommand.java11
1 files changed, 8 insertions, 3 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 2bda76c323..2147a2e5c4 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/ApplyCommand.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/ApplyCommand.java
@@ -43,6 +43,7 @@
package org.eclipse.jgit.api;
import java.io.File;
+import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
@@ -147,10 +148,14 @@ public class ApplyCommand extends GitCommand<ApplyResult> {
case COPY:
f = getFile(fh.getOldPath(), false);
byte[] bs = IO.readFully(f);
- FileWriter fw = new FileWriter(getFile(fh.getNewPath(),
+ FileOutputStream fos = new FileOutputStream(getFile(
+ fh.getNewPath(),
true));
- fw.write(new String(bs));
- fw.close();
+ try {
+ fos.write(bs);
+ } finally {
+ fos.close();
+ }
}
r.addUpdatedFile(f);
}