Signed-off-by: Shawn O. Pearce <spearce@xxxxxxxxxxx> --- .../org/spearce/jgit/lib/ConcurrentRepackTest.java | 2 +- .../org/spearce/jgit/revwalk/RevWalkTestCase.java | 3 +-- .../src/org/spearce/jgit/lib/ObjectWriter.java | 2 +- .../jgit/revwalk/filter/PatternMatchRevFilter.java | 10 ++-------- .../org/spearce/jgit/util/RawSubStringPattern.java | 10 ++-------- 5 files changed, 7 insertions(+), 20 deletions(-) diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/ConcurrentRepackTest.java b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/ConcurrentRepackTest.java index fa6345e..bf155cf 100644 --- a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/ConcurrentRepackTest.java +++ b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/ConcurrentRepackTest.java @@ -244,7 +244,7 @@ private File fullPackFileName(final ObjectId name, final String suffix) { private RevObject writeBlob(final Repository repo, final String data) throws IOException { final RevWalk revWalk = new RevWalk(repo); - final byte[] bytes = data.getBytes(Constants.CHARACTER_ENCODING); + final byte[] bytes = Constants.encode(data); final ObjectWriter ow = new ObjectWriter(repo); final ObjectId id = ow.writeBlob(bytes); try { diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/RevWalkTestCase.java b/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/RevWalkTestCase.java index befc3d5..9d5a44c 100644 --- a/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/RevWalkTestCase.java +++ b/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/RevWalkTestCase.java @@ -82,8 +82,7 @@ protected void tick(final int secDelta) { } protected RevBlob blob(final String content) throws Exception { - return rw.lookupBlob(ow.writeBlob(content - .getBytes(Constants.CHARACTER_ENCODING))); + return rw.lookupBlob(ow.writeBlob(Constants.encode(content))); } protected DirCacheEntry file(final String path, final RevBlob blob) diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectWriter.java b/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectWriter.java index 546cc68..86b5b09 100644 --- a/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectWriter.java +++ b/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectWriter.java @@ -215,7 +215,7 @@ public ObjectId writeCommit(final Commit c) throws IOException { w.flush(); os.write('\n'); - if (!encoding.equals("UTF-8")) { + if (!encoding.equals(Constants.CHARACTER_ENCODING)) { os.write(hencoding); os.write(' '); os.write(Constants.encodeASCII(encoding)); diff --git a/org.spearce.jgit/src/org/spearce/jgit/revwalk/filter/PatternMatchRevFilter.java b/org.spearce.jgit/src/org/spearce/jgit/revwalk/filter/PatternMatchRevFilter.java index e0bccf7..f9e7e4a 100644 --- a/org.spearce.jgit/src/org/spearce/jgit/revwalk/filter/PatternMatchRevFilter.java +++ b/org.spearce.jgit/src/org/spearce/jgit/revwalk/filter/PatternMatchRevFilter.java @@ -38,12 +38,12 @@ package org.spearce.jgit.revwalk.filter; import java.io.IOException; -import java.io.UnsupportedEncodingException; import java.util.regex.Matcher; import java.util.regex.Pattern; import org.spearce.jgit.errors.IncorrectObjectTypeException; import org.spearce.jgit.errors.MissingObjectException; +import org.spearce.jgit.lib.Constants; import org.spearce.jgit.revwalk.RevCommit; import org.spearce.jgit.revwalk.RevWalk; import org.spearce.jgit.util.RawCharSequence; @@ -64,13 +64,7 @@ * character sequence {@link RawCharSequence}. */ protected static final String forceToRaw(final String patternText) { - final byte[] b; - try { - b = patternText.getBytes("UTF-8"); - } catch (UnsupportedEncodingException e) { - throw new IllegalStateException("JVM lacks UTF-8 support.", e); - } - + final byte[] b = Constants.encode(patternText); final StringBuilder needle = new StringBuilder(b.length); for (int i = 0; i < b.length; i++) needle.append((char) (b[i] & 0xff)); diff --git a/org.spearce.jgit/src/org/spearce/jgit/util/RawSubStringPattern.java b/org.spearce.jgit/src/org/spearce/jgit/util/RawSubStringPattern.java index 5ed071c..1628deb 100644 --- a/org.spearce.jgit/src/org/spearce/jgit/util/RawSubStringPattern.java +++ b/org.spearce.jgit/src/org/spearce/jgit/util/RawSubStringPattern.java @@ -37,7 +37,7 @@ package org.spearce.jgit.util; -import java.io.UnsupportedEncodingException; +import org.spearce.jgit.lib.Constants; /** * Searches text using only substring search. @@ -63,13 +63,7 @@ public RawSubStringPattern(final String patternText) { throw new IllegalArgumentException("Cannot match on empty string."); needleString = patternText; - final byte[] b; - try { - b = patternText.getBytes("UTF-8"); - } catch (UnsupportedEncodingException e) { - throw new IllegalStateException("JVM lacks UTF-8 support.", e); - } - + final byte[] b = Constants.encode(patternText); needle = new byte[b.length]; for (int i = 0; i < b.length; i++) needle[i] = lc(b[i]); -- 1.6.4.rc2.216.g769fa -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html