summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit
diff options
context:
space:
mode:
authorXinTong Wang <xintong@ca.ibm.com>2015-12-08 15:03:26 -0500
committerMatthias Sohn <matthias.sohn@sap.com>2016-03-03 01:43:02 +0100
commit770d36c8bafba2ad20686c161246a3a239cdf1d9 (patch)
tree321c15c91a7e17b61a05af454545e0ac44e4b4c3 /org.eclipse.jgit
parentbe8c525fa0664d429e23cbf070420cb84a4a1607 (diff)
downloadjgit-770d36c8bafba2ad20686c161246a3a239cdf1d9.tar.gz
jgit-770d36c8bafba2ad20686c161246a3a239cdf1d9.zip
Fix apply patch which did not work with non-ascii characters
Bug: 483943 Change-Id: If28f64053d20ab1bee54245f223e952dc2fe392c Signed-off-by: XinTong Wang <xintong@ca.ibm.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/api/ApplyCommand.java10
1 files changed, 6 insertions, 4 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 676ae03009..bde450f99d 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/ApplyCommand.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/ApplyCommand.java
@@ -201,10 +201,12 @@ public class ApplyCommand extends GitCommand<ApplyResult> {
oldLines.add(rt.getString(i));
List<String> newLines = new ArrayList<String>(oldLines);
for (HunkHeader hh : fh.getHunks()) {
- StringBuilder hunk = new StringBuilder();
- for (int j = hh.getStartOffset(); j < hh.getEndOffset(); j++)
- hunk.append((char) hh.getBuffer()[j]);
- RawText hrt = new RawText(hunk.toString().getBytes());
+
+ byte[] b = new byte[hh.getEndOffset() - hh.getStartOffset()];
+ System.arraycopy(hh.getBuffer(), hh.getStartOffset(), b, 0,
+ b.length);
+ RawText hrt = new RawText(b);
+
List<String> hunkLines = new ArrayList<String>(hrt.size());
for (int i = 0; i < hrt.size(); i++)
hunkLines.add(hrt.getString(i));