Browse Source

[findBugs] Use UTF-8 to read git-rebase-todo file

Change-Id: I7c6f71e13ef106678157eae1aa3f9d39712e577b
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
stable-4.8
Matthias Sohn 8 years ago
parent
commit
f1dd61f646
  1. 14
      org.eclipse.jgit/src/org/eclipse/jgit/lib/RebaseTodoFile.java

14
org.eclipse.jgit/src/org/eclipse/jgit/lib/RebaseTodoFile.java

@ -43,6 +43,8 @@
package org.eclipse.jgit.lib; package org.eclipse.jgit.lib;
import static java.nio.charset.StandardCharsets.UTF_8;
import java.io.BufferedOutputStream; import java.io.BufferedOutputStream;
import java.io.File; import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
@ -177,8 +179,8 @@ public class RebaseTodoFile {
while (tokenCount < 3 && nextSpace < lineEnd) { while (tokenCount < 3 && nextSpace < lineEnd) {
switch (tokenCount) { switch (tokenCount) {
case 0: case 0:
String actionToken = new String(buf, tokenBegin, nextSpace String actionToken = new String(buf, tokenBegin,
- tokenBegin - 1); nextSpace - tokenBegin - 1, UTF_8);
tokenBegin = nextSpace; tokenBegin = nextSpace;
action = RebaseTodoLine.Action.parse(actionToken); action = RebaseTodoLine.Action.parse(actionToken);
if (action == null) if (action == null)
@ -186,14 +188,14 @@ public class RebaseTodoFile {
break; break;
case 1: case 1:
nextSpace = RawParseUtils.next(buf, tokenBegin, ' '); nextSpace = RawParseUtils.next(buf, tokenBegin, ' ');
String commitToken = new String(buf, tokenBegin, nextSpace String commitToken = new String(buf, tokenBegin,
- tokenBegin - 1); nextSpace - tokenBegin - 1, UTF_8);
tokenBegin = nextSpace; tokenBegin = nextSpace;
commit = AbbreviatedObjectId.fromString(commitToken); commit = AbbreviatedObjectId.fromString(commitToken);
break; break;
case 2: case 2:
return new RebaseTodoLine(action, commit, RawParseUtils.decode( return new RebaseTodoLine(action, commit,
buf, tokenBegin, 1 + lineEnd)); RawParseUtils.decode(buf, tokenBegin, 1 + lineEnd));
} }
tokenCount++; tokenCount++;
} }

Loading…
Cancel
Save