aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/hooks/GitHook.java6
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsStreamKey.java4
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GcLog.java4
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/LazyObjectIdSetFile.java4
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/BlockReader.java8
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/BlockWriter.java12
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/ReftableOutputStream.java4
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/ReftableReader.java6
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/lib/BlobBasedConfig.java5
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/lib/Config.java5
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/lib/Constants.java6
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/lib/RebaseTodoFile.java6
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/lib/TextProgressMonitor.java4
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevCommit.java4
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevTag.java6
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/storage/file/FileBasedConfig.java6
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/AmazonS3.java4
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/HMACSHA1NonceGenerator.java4
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/HttpAuthMethod.java10
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/ProgressSpinner.java4
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/PushCertificateIdent.java6
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/PushCertificateStore.java6
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/RefAdvertiser.java4
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/Transport.java3
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/util/Base64.java9
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/util/FS_Win32_Cygwin.java4
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/util/HttpSupport.java4
27 files changed, 79 insertions, 69 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/hooks/GitHook.java b/org.eclipse.jgit/src/org/eclipse/jgit/hooks/GitHook.java
index ad43e2ca83..8a61d1b0b1 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/hooks/GitHook.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/hooks/GitHook.java
@@ -42,7 +42,7 @@
*/
package org.eclipse.jgit.hooks;
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -158,7 +158,7 @@ abstract class GitHook<T> implements Callable<T> {
PrintStream hookErrRedirect = null;
try {
hookErrRedirect = new PrintStream(errorByteArray, false,
- UTF_8.name());
+ CHARSET.name());
} catch (UnsupportedEncodingException e) {
// UTF-8 is guaranteed to be available
}
@@ -167,7 +167,7 @@ abstract class GitHook<T> implements Callable<T> {
hookErrRedirect, getStdinArgs());
if (result.isExecutedWithError()) {
throw new AbortedByHookException(
- new String(errorByteArray.toByteArray(), UTF_8),
+ new String(errorByteArray.toByteArray(), CHARSET),
getHookName(), result.getExitCode());
}
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsStreamKey.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsStreamKey.java
index 8793d83126..c11f696708 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsStreamKey.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsStreamKey.java
@@ -43,7 +43,7 @@
package org.eclipse.jgit.internal.storage.dfs;
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
import java.util.Arrays;
@@ -67,7 +67,7 @@ public abstract class DfsStreamKey {
*/
public static DfsStreamKey of(DfsRepositoryDescription repo, String name,
@Nullable PackExt ext) {
- return new ByteArrayDfsStreamKey(repo, name.getBytes(UTF_8), ext);
+ return new ByteArrayDfsStreamKey(repo, name.getBytes(CHARSET), ext);
}
final int hash;
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GcLog.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GcLog.java
index bca7076aca..c159a94705 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GcLog.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GcLog.java
@@ -43,7 +43,7 @@
package org.eclipse.jgit.internal.storage.file;
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
import java.io.BufferedReader;
import java.io.File;
@@ -187,6 +187,6 @@ class GcLog {
if (content.length() > 0) {
nonEmpty = true;
}
- lock.write(content.getBytes(UTF_8));
+ lock.write(content.getBytes(CHARSET));
}
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/LazyObjectIdSetFile.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/LazyObjectIdSetFile.java
index 3d0e9c7189..c82d52e79c 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/LazyObjectIdSetFile.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/LazyObjectIdSetFile.java
@@ -43,7 +43,7 @@
package org.eclipse.jgit.internal.storage.file;
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
import java.io.BufferedReader;
import java.io.File;
@@ -86,7 +86,7 @@ public class LazyObjectIdSetFile implements ObjectIdSet {
private ObjectIdOwnerMap<Entry> load() {
ObjectIdOwnerMap<Entry> r = new ObjectIdOwnerMap<>();
try (FileInputStream fin = new FileInputStream(src);
- Reader rin = new InputStreamReader(fin, UTF_8);
+ Reader rin = new InputStreamReader(fin, CHARSET);
BufferedReader br = new BufferedReader(rin)) {
MutableObjectId id = new MutableObjectId();
for (String line; (line = br.readLine()) != null;) {
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/BlockReader.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/BlockReader.java
index ce2ba4a2e1..942d72fe23 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/BlockReader.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/BlockReader.java
@@ -43,7 +43,7 @@
package org.eclipse.jgit.internal.storage.reftable;
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
import static org.eclipse.jgit.internal.storage.reftable.BlockWriter.compare;
import static org.eclipse.jgit.internal.storage.reftable.ReftableConstants.FILE_BLOCK_TYPE;
import static org.eclipse.jgit.internal.storage.reftable.ReftableConstants.FILE_HEADER_LEN;
@@ -138,7 +138,7 @@ class BlockReader {
if (blockType == LOG_BLOCK_TYPE) {
len -= 9;
}
- return RawParseUtils.decode(UTF_8, nameBuf, 0, len);
+ return RawParseUtils.decode(CHARSET, nameBuf, 0, len);
}
boolean match(byte[] match, boolean matchIsPrefix) {
@@ -171,7 +171,7 @@ class BlockReader {
}
Ref readRef() throws IOException {
- String name = RawParseUtils.decode(UTF_8, nameBuf, 0, nameLen);
+ String name = RawParseUtils.decode(CHARSET, nameBuf, 0, nameLen);
switch (valueType & VALUE_TYPE_MASK) {
case VALUE_NONE: // delete
return newRef(name);
@@ -266,7 +266,7 @@ class BlockReader {
private String readValueString() {
int len = readVarint32();
int end = ptr + len;
- String s = RawParseUtils.decode(UTF_8, buf, ptr, end);
+ String s = RawParseUtils.decode(CHARSET, buf, ptr, end);
ptr = end;
return s;
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/BlockWriter.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/BlockWriter.java
index b3173e838c..3d8fbf4996 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/BlockWriter.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/BlockWriter.java
@@ -43,7 +43,7 @@
package org.eclipse.jgit.internal.storage.reftable;
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
import static org.eclipse.jgit.internal.storage.reftable.ReftableConstants.FILE_HEADER_LEN;
import static org.eclipse.jgit.internal.storage.reftable.ReftableConstants.INDEX_BLOCK_TYPE;
import static org.eclipse.jgit.internal.storage.reftable.ReftableConstants.LOG_BLOCK_TYPE;
@@ -440,7 +440,7 @@ class BlockWriter {
}
private static byte[] nameUtf8(Ref ref) {
- return ref.getName().getBytes(UTF_8);
+ return ref.getName().getBytes(CHARSET);
}
}
@@ -559,13 +559,13 @@ class BlockWriter {
this.newId = newId;
this.timeSecs = who.getWhen().getTime() / 1000L;
this.tz = (short) who.getTimeZoneOffset();
- this.name = who.getName().getBytes(UTF_8);
- this.email = who.getEmailAddress().getBytes(UTF_8);
- this.msg = message.getBytes(UTF_8);
+ this.name = who.getName().getBytes(CHARSET);
+ this.email = who.getEmailAddress().getBytes(CHARSET);
+ this.msg = message.getBytes(CHARSET);
}
static byte[] key(String ref, long index) {
- byte[] name = ref.getBytes(UTF_8);
+ byte[] name = ref.getBytes(CHARSET);
byte[] key = Arrays.copyOf(name, name.length + 1 + 8);
NB.encodeInt64(key, key.length - 8, reverseUpdateIndex(index));
return key;
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/ReftableOutputStream.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/ReftableOutputStream.java
index 1fc43c9fac..44bbb16219 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/ReftableOutputStream.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/ReftableOutputStream.java
@@ -43,7 +43,7 @@
package org.eclipse.jgit.internal.storage.reftable;
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
import static org.eclipse.jgit.internal.storage.reftable.ReftableConstants.FILE_HEADER_LEN;
import static org.eclipse.jgit.internal.storage.reftable.ReftableConstants.INDEX_BLOCK_TYPE;
import static org.eclipse.jgit.internal.storage.reftable.ReftableConstants.LOG_BLOCK_TYPE;
@@ -160,7 +160,7 @@ class ReftableOutputStream extends OutputStream {
}
void writeVarintString(String s) {
- writeVarintString(s.getBytes(UTF_8));
+ writeVarintString(s.getBytes(CHARSET));
}
void writeVarintString(byte[] msg) {
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/ReftableReader.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/ReftableReader.java
index 74877192f6..5356952b5d 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/ReftableReader.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/ReftableReader.java
@@ -43,7 +43,7 @@
package org.eclipse.jgit.internal.storage.reftable;
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
import static org.eclipse.jgit.internal.storage.reftable.BlockReader.decodeBlockLen;
import static org.eclipse.jgit.internal.storage.reftable.ReftableConstants.FILE_BLOCK_TYPE;
import static org.eclipse.jgit.internal.storage.reftable.ReftableConstants.FILE_FOOTER_LEN;
@@ -182,7 +182,7 @@ public class ReftableReader extends Reftable {
public RefCursor seekRef(String refName) throws IOException {
initRefIndex();
- byte[] key = refName.getBytes(UTF_8);
+ byte[] key = refName.getBytes(CHARSET);
boolean prefix = key[key.length - 1] == '/';
RefCursorImpl i = new RefCursorImpl(refEnd, key, prefix);
@@ -223,7 +223,7 @@ public class ReftableReader extends Reftable {
initLogIndex();
if (logPosition > 0) {
byte[] key = LogEntry.key(refName, updateIndex);
- byte[] match = refName.getBytes(UTF_8);
+ byte[] match = refName.getBytes(CHARSET);
LogCursorImpl i = new LogCursorImpl(logEnd, match);
i.block = seek(LOG_BLOCK_TYPE, key, logIndex, logPosition, logEnd);
return i;
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/BlobBasedConfig.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/BlobBasedConfig.java
index 3ff92dc739..f44aeceb52 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/BlobBasedConfig.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/BlobBasedConfig.java
@@ -45,6 +45,8 @@
package org.eclipse.jgit.lib;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
+
import java.io.FileNotFoundException;
import java.io.IOException;
import java.text.MessageFormat;
@@ -81,8 +83,7 @@ public class BlobBasedConfig extends Config {
super(base);
final String decoded;
if (isUtf8(blob)) {
- decoded = RawParseUtils.decode(RawParseUtils.UTF8_CHARSET,
- blob, 3, blob.length);
+ decoded = RawParseUtils.decode(CHARSET, blob, 3, blob.length);
} else {
decoded = RawParseUtils.decode(blob);
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Config.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Config.java
index 4d558c9fc2..285a56c87a 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Config.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Config.java
@@ -51,6 +51,8 @@
package org.eclipse.jgit.lib;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
+
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Collections;
@@ -1166,8 +1168,7 @@ public class Config {
String decoded;
if (isUtf8(bytes)) {
- decoded = RawParseUtils.decode(RawParseUtils.UTF8_CHARSET, bytes, 3,
- bytes.length);
+ decoded = RawParseUtils.decode(CHARSET, bytes, 3, bytes.length);
} else {
decoded = RawParseUtils.decode(bytes);
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Constants.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Constants.java
index 29189a9d74..5c7cee6ca5 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Constants.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Constants.java
@@ -228,10 +228,10 @@ public final class Constants {
public static final byte[] PACK_SIGNATURE = { 'P', 'A', 'C', 'K' };
/** Native character encoding for commit messages, file names... */
- public static final Charset CHARSET = UTF_8;
+ public static final Charset CHARSET;
/** Native character encoding for commit messages, file names... */
- public static final String CHARACTER_ENCODING = CHARSET.name();
+ public static final String CHARACTER_ENCODING;
/** Default main branch name */
public static final String MASTER = "master";
@@ -654,6 +654,8 @@ public final class Constants {
static {
if (OBJECT_ID_LENGTH != newMessageDigest().getDigestLength())
throw new LinkageError(JGitText.get().incorrectOBJECT_ID_LENGTH);
+ CHARSET = UTF_8;
+ CHARACTER_ENCODING = CHARSET.name();
}
/** name of the file containing the commit msg for a merge commit */
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/RebaseTodoFile.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/RebaseTodoFile.java
index 06b4b227c8..38716055b5 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/RebaseTodoFile.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/RebaseTodoFile.java
@@ -43,7 +43,7 @@
package org.eclipse.jgit.lib;
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
import java.io.BufferedOutputStream;
import java.io.File;
@@ -183,7 +183,7 @@ public class RebaseTodoFile {
switch (tokenCount) {
case 0:
String actionToken = new String(buf, tokenBegin,
- nextSpace - tokenBegin - 1, UTF_8);
+ nextSpace - tokenBegin - 1, CHARSET);
tokenBegin = nextSpace;
action = RebaseTodoLine.Action.parse(actionToken);
if (action == null)
@@ -192,7 +192,7 @@ public class RebaseTodoFile {
case 1:
nextSpace = RawParseUtils.next(buf, tokenBegin, ' ');
String commitToken = new String(buf, tokenBegin,
- nextSpace - tokenBegin - 1, UTF_8);
+ nextSpace - tokenBegin - 1, CHARSET);
tokenBegin = nextSpace;
commit = AbbreviatedObjectId.fromString(commitToken);
break;
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/TextProgressMonitor.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/TextProgressMonitor.java
index 936ce3dcc8..2f759e53ca 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/TextProgressMonitor.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/TextProgressMonitor.java
@@ -44,7 +44,7 @@
package org.eclipse.jgit.lib;
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
import java.io.IOException;
import java.io.OutputStreamWriter;
@@ -63,7 +63,7 @@ public class TextProgressMonitor extends BatchingProgressMonitor {
* Initialize a new progress monitor.
*/
public TextProgressMonitor() {
- this(new PrintWriter(new OutputStreamWriter(System.err, UTF_8)));
+ this(new PrintWriter(new OutputStreamWriter(System.err, CHARSET)));
}
/**
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevCommit.java b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevCommit.java
index 9db146706f..5c8371f918 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevCommit.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevCommit.java
@@ -44,7 +44,7 @@
package org.eclipse.jgit.revwalk;
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
import java.io.IOException;
import java.nio.charset.Charset;
@@ -539,7 +539,7 @@ public class RevCommit extends RevObject {
try {
return getEncoding();
} catch (IllegalCharsetNameException | UnsupportedCharsetException e) {
- return UTF_8;
+ return CHARSET;
}
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevTag.java b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevTag.java
index d74837e860..cbeda71a87 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevTag.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevTag.java
@@ -45,7 +45,7 @@
package org.eclipse.jgit.revwalk;
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
import java.io.IOException;
import java.nio.charset.Charset;
@@ -169,7 +169,7 @@ public class RevTag extends RevObject {
int p = pos.value += 4; // "tag "
final int nameEnd = RawParseUtils.nextLF(rawTag, p) - 1;
- tagName = RawParseUtils.decode(UTF_8, rawTag, p, nameEnd);
+ tagName = RawParseUtils.decode(CHARSET, rawTag, p, nameEnd);
if (walk.isRetainBody())
buffer = rawTag;
@@ -257,7 +257,7 @@ public class RevTag extends RevObject {
try {
return RawParseUtils.parseEncoding(buffer);
} catch (IllegalCharsetNameException | UnsupportedCharsetException e) {
- return UTF_8;
+ return CHARSET;
}
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/FileBasedConfig.java b/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/FileBasedConfig.java
index 9927daf3d5..93ffb944c8 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/FileBasedConfig.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/FileBasedConfig.java
@@ -49,6 +49,8 @@
package org.eclipse.jgit.storage.file;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
+
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
@@ -154,7 +156,7 @@ public class FileBasedConfig extends StoredConfig {
} else {
final String decoded;
if (isUtf8(in)) {
- decoded = RawParseUtils.decode(RawParseUtils.UTF8_CHARSET,
+ decoded = RawParseUtils.decode(CHARSET,
in, 3, in.length);
utf8Bom = true;
} else {
@@ -198,7 +200,7 @@ public class FileBasedConfig extends StoredConfig {
bos.write(0xEF);
bos.write(0xBB);
bos.write(0xBF);
- bos.write(text.getBytes(RawParseUtils.UTF8_CHARSET.name()));
+ bos.write(text.getBytes(CHARSET));
out = bos.toByteArray();
} else {
out = Constants.encode(text);
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/AmazonS3.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/AmazonS3.java
index d7c5b9d7f9..71e3d16c47 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/AmazonS3.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/AmazonS3.java
@@ -43,7 +43,7 @@
package org.eclipse.jgit.transport;
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
import java.io.ByteArrayOutputStream;
import java.io.File;
@@ -638,7 +638,7 @@ public class AmazonS3 {
try {
final Mac m = Mac.getInstance(HMAC);
m.init(privateKey);
- sec = Base64.encodeBytes(m.doFinal(s.toString().getBytes(UTF_8)));
+ sec = Base64.encodeBytes(m.doFinal(s.toString().getBytes(CHARSET)));
} catch (NoSuchAlgorithmException e) {
throw new IOException(MessageFormat.format(JGitText.get().noHMACsupport, HMAC, e.getMessage()));
} catch (InvalidKeyException e) {
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/HMACSHA1NonceGenerator.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/HMACSHA1NonceGenerator.java
index 6c26b7026a..1415334c63 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/HMACSHA1NonceGenerator.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/HMACSHA1NonceGenerator.java
@@ -43,7 +43,7 @@
package org.eclipse.jgit.transport;
import static java.nio.charset.StandardCharsets.ISO_8859_1;
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
import java.io.File;
import java.security.InvalidKeyException;
@@ -102,7 +102,7 @@ public class HMACSHA1NonceGenerator implements NonceGenerator {
}
String input = path + ":" + String.valueOf(timestamp); //$NON-NLS-1$
- byte[] rawHmac = mac.doFinal(input.getBytes(UTF_8));
+ byte[] rawHmac = mac.doFinal(input.getBytes(CHARSET));
return Long.toString(timestamp) + "-" + toHex(rawHmac); //$NON-NLS-1$
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/HttpAuthMethod.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/HttpAuthMethod.java
index c40d9635de..de7a7dc1c7 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/HttpAuthMethod.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/HttpAuthMethod.java
@@ -43,7 +43,7 @@
package org.eclipse.jgit.transport;
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
import static org.eclipse.jgit.util.HttpSupport.HDR_AUTHORIZATION;
import static org.eclipse.jgit.util.HttpSupport.HDR_WWW_AUTHENTICATE;
@@ -315,7 +315,7 @@ abstract class HttpAuthMethod {
@Override
void configureRequest(final HttpConnection conn) throws IOException {
String ident = user + ":" + pass; //$NON-NLS-1$
- String enc = Base64.encodeBytes(ident.getBytes(UTF_8));
+ String enc = Base64.encodeBytes(ident.getBytes(CHARSET));
conn.setRequestProperty(HDR_AUTHORIZATION, type.getSchemeName()
+ " " + enc); //$NON-NLS-1$
}
@@ -430,15 +430,15 @@ abstract class HttpAuthMethod {
private static String H(String data) {
MessageDigest md = newMD5();
- md.update(data.getBytes(UTF_8));
+ md.update(data.getBytes(CHARSET));
return LHEX(md.digest());
}
private static String KD(String secret, String data) {
MessageDigest md = newMD5();
- md.update(secret.getBytes(UTF_8));
+ md.update(secret.getBytes(CHARSET));
md.update((byte) ':');
- md.update(data.getBytes(UTF_8));
+ md.update(data.getBytes(CHARSET));
return LHEX(md.digest());
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/ProgressSpinner.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/ProgressSpinner.java
index 41af8078c8..2364434b0f 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/ProgressSpinner.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/ProgressSpinner.java
@@ -43,7 +43,7 @@
package org.eclipse.jgit.transport;
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
import java.io.IOException;
import java.io.OutputStream;
@@ -141,7 +141,7 @@ public class ProgressSpinner {
private void write(String s) {
if (write) {
try {
- out.write(s.getBytes(UTF_8));
+ out.write(s.getBytes(CHARSET));
out.flush();
} catch (IOException e) {
write = false;
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/PushCertificateIdent.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/PushCertificateIdent.java
index f9fddbe889..178c80d22e 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/PushCertificateIdent.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/PushCertificateIdent.java
@@ -43,7 +43,7 @@
package org.eclipse.jgit.transport;
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
import static org.eclipse.jgit.util.RawParseUtils.lastIndexOfTrim;
import java.text.SimpleDateFormat;
@@ -95,7 +95,7 @@ public class PushCertificateIdent {
*/
public static PushCertificateIdent parse(String str) {
MutableInteger p = new MutableInteger();
- byte[] raw = str.getBytes(UTF_8);
+ byte[] raw = str.getBytes(CHARSET);
int tzBegin = raw.length - 1;
tzBegin = lastIndexOfTrim(raw, ' ', tzBegin);
if (tzBegin < 0 || raw[tzBegin] != ' ') {
@@ -129,7 +129,7 @@ public class PushCertificateIdent {
idEnd = raw.length;
}
}
- String id = new String(raw, 0, idEnd, UTF_8);
+ String id = new String(raw, 0, idEnd, CHARSET);
return new PushCertificateIdent(str, id, when * 1000L, tz);
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/PushCertificateStore.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/PushCertificateStore.java
index ab58a3317a..36d660234d 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/PushCertificateStore.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/PushCertificateStore.java
@@ -43,7 +43,7 @@
package org.eclipse.jgit.transport;
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
import static org.eclipse.jgit.lib.Constants.OBJ_BLOB;
import static org.eclipse.jgit.lib.Constants.OBJ_COMMIT;
import static org.eclipse.jgit.lib.FileMode.TYPE_FILE;
@@ -292,7 +292,7 @@ public class PushCertificateStore implements AutoCloseable {
ObjectLoader loader =
tw.getObjectReader().open(tw.getObjectId(0), OBJ_BLOB);
try (InputStream in = loader.openStream();
- Reader r = new BufferedReader(new InputStreamReader(in, UTF_8))) {
+ Reader r = new BufferedReader(new InputStreamReader(in, CHARSET))) {
return PushCertificateParser.fromReader(r);
}
}
@@ -473,7 +473,7 @@ public class PushCertificateStore implements AutoCloseable {
DirCacheEditor editor = dc.editor();
String certText = pc.cert.toText() + pc.cert.getSignature();
- final ObjectId certId = inserter.insert(OBJ_BLOB, certText.getBytes(UTF_8));
+ final ObjectId certId = inserter.insert(OBJ_BLOB, certText.getBytes(CHARSET));
boolean any = false;
for (ReceiveCommand cmd : pc.cert.getCommands()) {
if (byRef != null && !commandsEqual(cmd, byRef.get(cmd.getRefName()))) {
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/RefAdvertiser.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/RefAdvertiser.java
index 5eb1661738..6ad39e3ddd 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/RefAdvertiser.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/RefAdvertiser.java
@@ -43,7 +43,7 @@
package org.eclipse.jgit.transport;
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
import static org.eclipse.jgit.lib.Constants.OBJECT_ID_STRING_LENGTH;
import static org.eclipse.jgit.transport.GitProtocolConstants.OPTION_SYMREF;
@@ -74,7 +74,7 @@ import org.eclipse.jgit.util.RefMap;
public abstract class RefAdvertiser {
/** Advertiser which frames lines in a {@link PacketLineOut} format. */
public static class PacketLineOutRefAdvertiser extends RefAdvertiser {
- private final CharsetEncoder utf8 = UTF_8.newEncoder();
+ private final CharsetEncoder utf8 = CHARSET.newEncoder();
private final PacketLineOut pckOut;
private byte[] binArr = new byte[256];
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/Transport.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/Transport.java
index 8db796a83f..ce321b014a 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/Transport.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/Transport.java
@@ -46,6 +46,7 @@
package org.eclipse.jgit.transport;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
import static org.eclipse.jgit.lib.RefDatabase.ALL;
import java.io.BufferedReader;
@@ -147,7 +148,7 @@ public abstract class Transport implements AutoCloseable {
BufferedReader br;
try {
InputStream urlIn = url.openStream();
- br = new BufferedReader(new InputStreamReader(urlIn, "UTF-8")); //$NON-NLS-1$
+ br = new BufferedReader(new InputStreamReader(urlIn, CHARSET));
} catch (IOException err) {
// If we cannot read from the service list, go to the next.
//
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/Base64.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/Base64.java
index 0c27ced76b..442f0793fb 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/util/Base64.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/Base64.java
@@ -6,9 +6,8 @@
package org.eclipse.jgit.util;
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
-import java.nio.charset.StandardCharsets;
import java.text.MessageFormat;
import java.util.Arrays;
@@ -55,7 +54,7 @@ public class Base64 {
+ "abcdefghijklmnopqrstuvwxyz" // //$NON-NLS-1$
+ "0123456789" // //$NON-NLS-1$
+ "+/" // //$NON-NLS-1$
- ).getBytes(UTF_8);
+ ).getBytes(CHARSET);
DEC = new byte[128];
Arrays.fill(DEC, INVALID_DEC);
@@ -178,7 +177,7 @@ public class Base64 {
e += 4;
}
- return new String(outBuff, 0, e, StandardCharsets.UTF_8);
+ return new String(outBuff, 0, e, CHARSET);
}
/**
@@ -294,7 +293,7 @@ public class Base64 {
* @return the decoded data
*/
public static byte[] decode(String s) {
- byte[] bytes = s.getBytes(UTF_8);
+ byte[] bytes = s.getBytes(CHARSET);
return decode(bytes, 0, bytes.length);
}
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_Win32_Cygwin.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_Win32_Cygwin.java
index 64cdcc300d..0b0a5057ce 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_Win32_Cygwin.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_Win32_Cygwin.java
@@ -43,6 +43,8 @@
package org.eclipse.jgit.util;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
+
import java.io.File;
import java.io.PrintStream;
import java.nio.file.Files;
@@ -124,7 +126,7 @@ public class FS_Win32_Cygwin extends FS_Win32 {
try {
w = readPipe(dir, //
new String[] { cygpath, "--windows", "--absolute", pn }, // //$NON-NLS-1$ //$NON-NLS-2$
- "UTF-8"); //$NON-NLS-1$
+ CHARSET.name());
} catch (CommandFailedException e) {
LOG.warn(e.getMessage());
return null;
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/HttpSupport.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/HttpSupport.java
index a5a858f85e..d070ed39d0 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/util/HttpSupport.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/HttpSupport.java
@@ -44,6 +44,8 @@
package org.eclipse.jgit.util;
+import static org.eclipse.jgit.lib.Constants.CHARACTER_ENCODING;
+
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.ConnectException;
@@ -179,7 +181,7 @@ public class HttpSupport {
if (key == null || key.length() == 0)
return;
try {
- urlstr.append(URLEncoder.encode(key, "UTF-8")); //$NON-NLS-1$
+ urlstr.append(URLEncoder.encode(key, CHARACTER_ENCODING));
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(JGitText.get().couldNotURLEncodeToUTF8, e);
}