Consistently use Constants.CHARSET rather than StandardCharsets.UTF_8
Change-Id: I6714fc3666e1bced22abba94ceb700477349586e Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
This commit is contained in:
parent
62bc48df60
commit
f07b60239c
|
@ -42,6 +42,8 @@
|
|||
*/
|
||||
package org.eclipse.jgit.archive;
|
||||
|
||||
import static org.eclipse.jgit.lib.Constants.CHARACTER_ENCODING;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.text.MessageFormat;
|
||||
|
@ -82,7 +84,8 @@ public ArchiveOutputStream createArchiveOutputStream(OutputStream s)
|
|||
@Override
|
||||
public ArchiveOutputStream createArchiveOutputStream(OutputStream s,
|
||||
Map<String, Object> o) throws IOException {
|
||||
TarArchiveOutputStream out = new TarArchiveOutputStream(s, "UTF-8"); //$NON-NLS-1$
|
||||
TarArchiveOutputStream out = new TarArchiveOutputStream(s,
|
||||
CHARACTER_ENCODING);
|
||||
out.setLongFileMode(TarArchiveOutputStream.LONGFILE_POSIX);
|
||||
out.setBigNumberMode(TarArchiveOutputStream.BIGNUMBER_POSIX);
|
||||
return applyFormatOptions(out, o);
|
||||
|
@ -97,7 +100,7 @@ public void putEntry(ArchiveOutputStream out,
|
|||
final TarArchiveEntry entry = new TarArchiveEntry(
|
||||
path, TarConstants.LF_SYMLINK);
|
||||
entry.setLinkName(new String(
|
||||
loader.getCachedBytes(100), "UTF-8")); //$NON-NLS-1$
|
||||
loader.getCachedBytes(100), CHARACTER_ENCODING));
|
||||
out.putArchiveEntry(entry);
|
||||
out.closeArchiveEntry();
|
||||
return;
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
|
||||
package org.eclipse.jgit.http.test;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static org.eclipse.jgit.util.HttpSupport.HDR_CONTENT_ENCODING;
|
||||
import static org.eclipse.jgit.util.HttpSupport.HDR_CONTENT_LENGTH;
|
||||
import static org.eclipse.jgit.util.HttpSupport.HDR_CONTENT_TYPE;
|
||||
|
@ -1084,7 +1084,7 @@ public void testInitialClone_BrokenServer() throws Exception {
|
|||
public void testInvalidWant() throws Exception {
|
||||
@SuppressWarnings("resource")
|
||||
ObjectId id = new ObjectInserter.Formatter().idFor(Constants.OBJ_BLOB,
|
||||
"testInvalidWant".getBytes(UTF_8));
|
||||
"testInvalidWant".getBytes(CHARSET));
|
||||
|
||||
Repository dst = createBareRepository();
|
||||
try (Transport t = Transport.open(dst, remoteURI);
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
|
||||
package org.eclipse.jgit.junit;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
|
@ -246,7 +246,7 @@ public static void write(final File f, final String body)
|
|||
throws IOException {
|
||||
FileUtils.mkdirs(f.getParentFile(), true);
|
||||
try (Writer w = new OutputStreamWriter(new FileOutputStream(f),
|
||||
UTF_8)) {
|
||||
CHARSET)) {
|
||||
w.write(body);
|
||||
}
|
||||
}
|
||||
|
@ -263,7 +263,7 @@ public static void write(final File f, final String body)
|
|||
*/
|
||||
public static String read(final File file) throws IOException {
|
||||
final byte[] body = IO.readFully(file);
|
||||
return new String(body, 0, body.length, UTF_8);
|
||||
return new String(body, 0, body.length, CHARSET);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
|
||||
package org.eclipse.jgit.junit;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
|
@ -352,7 +352,7 @@ public static String indexState(Repository repo, int includedOptions)
|
|||
if (0 != (includedOptions & CONTENT)) {
|
||||
sb.append(", content:"
|
||||
+ new String(repo.open(entry.getObjectId(),
|
||||
Constants.OBJ_BLOB).getCachedBytes(), UTF_8));
|
||||
Constants.OBJ_BLOB).getCachedBytes(), CHARSET));
|
||||
}
|
||||
if (0 != (includedOptions & ASSUME_UNCHANGED))
|
||||
sb.append(", assume-unchanged:"
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
|
||||
package org.eclipse.jgit.junit;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -199,7 +199,7 @@ protected void deleteTrashFile(final String name) throws IOException {
|
|||
protected static void checkFile(File f, final String checkData)
|
||||
throws IOException {
|
||||
try (Reader r = new InputStreamReader(new FileInputStream(f),
|
||||
UTF_8)) {
|
||||
CHARSET)) {
|
||||
if (checkData.length() > 0) {
|
||||
char[] data = new char[checkData.length()];
|
||||
assertEquals(data.length, r.read(data));
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
|
||||
package org.eclipse.jgit.junit;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
|
@ -268,7 +268,7 @@ public void setAuthorAndCommitter(org.eclipse.jgit.lib.CommitBuilder c) {
|
|||
* @throws Exception
|
||||
*/
|
||||
public RevBlob blob(final String content) throws Exception {
|
||||
return blob(content.getBytes(UTF_8));
|
||||
return blob(content.getBytes(CHARSET));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
*/
|
||||
package org.eclipse.jgit.lfs.server.fs;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
|
@ -211,11 +211,11 @@ private void checkResponseStatus(HttpResponse response) {
|
|||
if (buf.hasArray()) {
|
||||
error = new String(buf.array(),
|
||||
buf.arrayOffset() + buf.position(), buf.remaining(),
|
||||
UTF_8);
|
||||
CHARSET);
|
||||
} else {
|
||||
final byte[] b = new byte[buf.remaining()];
|
||||
buf.duplicate().get(b);
|
||||
error = new String(b, UTF_8);
|
||||
error = new String(b, CHARSET);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
error = statusLine.getReasonPhrase();
|
||||
|
|
|
@ -31,6 +31,7 @@ Import-Package: com.google.gson;version="[2.8.0,3.0.0)",
|
|||
org.eclipse.jgit.lfs.errors;version="[5.0.0,5.1.0)",
|
||||
org.eclipse.jgit.lfs.internal;version="[5.0.0,5.1.0)",
|
||||
org.eclipse.jgit.lfs.lib;version="[5.0.0,5.1.0)",
|
||||
org.eclipse.jgit.lib;version="[5.0.0,5.1.0)",
|
||||
org.eclipse.jgit.nls;version="[5.0.0,5.1.0)",
|
||||
org.eclipse.jgit.transport.http;version="[5.0.0,5.1.0)",
|
||||
org.eclipse.jgit.transport.http.apache;version="[5.0.0,5.1.0)",
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
*/
|
||||
package org.eclipse.jgit.lfs.server;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static org.apache.http.HttpStatus.SC_FORBIDDEN;
|
||||
import static org.apache.http.HttpStatus.SC_INSUFFICIENT_STORAGE;
|
||||
import static org.apache.http.HttpStatus.SC_INTERNAL_SERVER_ERROR;
|
||||
|
@ -202,10 +202,10 @@ public boolean isVerify() {
|
|||
protected void doPost(HttpServletRequest req, HttpServletResponse res)
|
||||
throws ServletException, IOException {
|
||||
Writer w = new BufferedWriter(
|
||||
new OutputStreamWriter(res.getOutputStream(), UTF_8));
|
||||
new OutputStreamWriter(res.getOutputStream(), CHARSET));
|
||||
|
||||
Reader r = new BufferedReader(
|
||||
new InputStreamReader(req.getInputStream(), UTF_8));
|
||||
new InputStreamReader(req.getInputStream(), CHARSET));
|
||||
LfsRequest request = LfsGson.fromJson(r, LfsRequest.class);
|
||||
String path = req.getPathInfo();
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
*/
|
||||
package org.eclipse.jgit.lfs.server.s3;
|
||||
|
||||
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 java.io.UnsupportedEncodingException;
|
||||
|
@ -359,13 +359,13 @@ private static String canonicalizeResourcePath(URL endpoint) {
|
|||
|
||||
private static byte[] hash(String s) {
|
||||
MessageDigest md = Constants.newMessageDigest();
|
||||
md.update(s.getBytes(UTF_8));
|
||||
md.update(s.getBytes(CHARSET));
|
||||
return md.digest();
|
||||
}
|
||||
|
||||
private static byte[] sign(String stringData, byte[] key) {
|
||||
try {
|
||||
byte[] data = stringData.getBytes(UTF_8);
|
||||
byte[] data = stringData.getBytes(CHARSET);
|
||||
Mac mac = Mac.getInstance(HMACSHA256);
|
||||
mac.init(new SecretKeySpec(key, HMACSHA256));
|
||||
return mac.doFinal(data);
|
||||
|
@ -395,7 +395,7 @@ private static String toHex(byte[] bytes) {
|
|||
private static String urlEncode(String url, boolean keepPathSlash) {
|
||||
String encoded;
|
||||
try {
|
||||
encoded = URLEncoder.encode(url, UTF_8.name());
|
||||
encoded = URLEncoder.encode(url, CHARSET.name());
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new RuntimeException(LfsServerText.get().unsupportedUtf8, e);
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
*/
|
||||
package org.eclipse.jgit.lfs.test;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
|
@ -66,7 +66,7 @@ public class LongObjectIdTestUtils {
|
|||
*/
|
||||
public static LongObjectId hash(String s) {
|
||||
MessageDigest md = Constants.newMessageDigest();
|
||||
md.update(s.getBytes(UTF_8));
|
||||
md.update(s.getBytes(CHARSET));
|
||||
return LongObjectId.fromRaw(md.digest());
|
||||
}
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
|
||||
package org.eclipse.jgit.lfs.lib;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.eclipse.jgit.lib.Constants.CHARACTER_ENCODING;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
|
@ -66,7 +66,7 @@ public void testEncoding() throws IOException {
|
|||
assertEquals(
|
||||
"version https://git-lfs.github.com/spec/v1\noid sha256:"
|
||||
+ s + "\nsize 4\n",
|
||||
baos.toString(UTF_8.name()));
|
||||
baos.toString(CHARACTER_ENCODING));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
*/
|
||||
package org.eclipse.jgit.lfs;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
|
@ -134,7 +134,7 @@ public long getSize() {
|
|||
*/
|
||||
public void encode(OutputStream out) {
|
||||
try (PrintStream ps = new PrintStream(out, false,
|
||||
UTF_8.name())) {
|
||||
CHARSET.name())) {
|
||||
ps.print("version "); //$NON-NLS-1$
|
||||
ps.print(VERSION + "\n"); //$NON-NLS-1$
|
||||
ps.print("oid " + HASH_FUNCTION_NAME + ":"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
@ -143,7 +143,7 @@ public void encode(OutputStream out) {
|
|||
ps.print(size + "\n"); //$NON-NLS-1$
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
// should not happen, we are using a standard charset
|
||||
throw new UnsupportedCharsetException(UTF_8.name());
|
||||
throw new UnsupportedCharsetException(CHARSET.name());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -165,7 +165,7 @@ public static LfsPointer parseLfsPointer(InputStream in)
|
|||
long sz = -1;
|
||||
|
||||
try (BufferedReader br = new BufferedReader(
|
||||
new InputStreamReader(in, UTF_8))) {
|
||||
new InputStreamReader(in, CHARSET))) {
|
||||
for (String s = br.readLine(); s != null; s = br.readLine()) {
|
||||
if (s.startsWith("#") || s.length() == 0) { //$NON-NLS-1$
|
||||
continue;
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
*/
|
||||
package org.eclipse.jgit.lfs;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static org.eclipse.jgit.lfs.Protocol.OPERATION_UPLOAD;
|
||||
import static org.eclipse.jgit.lfs.internal.LfsConnectionFactory.toRequest;
|
||||
import static org.eclipse.jgit.transport.http.HttpConnection.HTTP_OK;
|
||||
|
@ -204,7 +204,7 @@ private Map<String, LfsPointer> requestBatchUpload(HttpConnection api,
|
|||
}
|
||||
Gson gson = Protocol.gson();
|
||||
api.getOutputStream().write(
|
||||
gson.toJson(toRequest(OPERATION_UPLOAD, res)).getBytes(UTF_8));
|
||||
gson.toJson(toRequest(OPERATION_UPLOAD, res)).getBytes(CHARSET));
|
||||
int responseCode = api.getResponseCode();
|
||||
if (responseCode != HTTP_OK) {
|
||||
throw new IOException(
|
||||
|
|
|
@ -42,11 +42,12 @@
|
|||
*/
|
||||
package org.eclipse.jgit.lfs;
|
||||
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.text.MessageFormat;
|
||||
|
@ -169,7 +170,7 @@ public static Collection<Path> downloadLfsResource(Lfs lfs, Repository db,
|
|||
.write(gson
|
||||
.toJson(LfsConnectionFactory
|
||||
.toRequest(Protocol.OPERATION_DOWNLOAD, res))
|
||||
.getBytes(StandardCharsets.UTF_8));
|
||||
.getBytes(CHARSET));
|
||||
int responseCode = lfsServerConn.getResponseCode();
|
||||
if (responseCode != HttpConnection.HTTP_OK) {
|
||||
throw new IOException(
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
*/
|
||||
package org.eclipse.jgit.pgm;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
|
@ -612,7 +612,7 @@ private Process spawnAssumingCommandPresent(String... cmdline) {
|
|||
|
||||
private BufferedReader readFromProcess(Process proc) throws Exception {
|
||||
return new BufferedReader(
|
||||
new InputStreamReader(proc.getInputStream(), UTF_8));
|
||||
new InputStreamReader(proc.getInputStream(), CHARSET));
|
||||
}
|
||||
|
||||
private void grepForEntry(String name, String mode, String... cmdline)
|
||||
|
@ -750,7 +750,7 @@ private static String[] zipEntryContent(byte[] zipData, String path)
|
|||
// found!
|
||||
List<String> l = new ArrayList<>();
|
||||
BufferedReader reader = new BufferedReader(
|
||||
new InputStreamReader(in, UTF_8));
|
||||
new InputStreamReader(in, CHARSET));
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null)
|
||||
l.add(line);
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
|
||||
package org.eclipse.jgit.pgm;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
|
@ -151,7 +151,7 @@ private void scan(final URL cUrl) {
|
|||
final BufferedReader cIn;
|
||||
try {
|
||||
final InputStream in = cUrl.openStream();
|
||||
cIn = new BufferedReader(new InputStreamReader(in, UTF_8));
|
||||
cIn = new BufferedReader(new InputStreamReader(in, CHARSET));
|
||||
} catch (IOException err) {
|
||||
// If we cannot read from the service list, go to the next.
|
||||
//
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
|
||||
package org.eclipse.jgit.pgm;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
@ -217,7 +217,7 @@ protected void run(final String[] argv) throws Exception {
|
|||
}
|
||||
|
||||
PrintWriter createErrorWriter() {
|
||||
return new PrintWriter(new OutputStreamWriter(System.err, UTF_8));
|
||||
return new PrintWriter(new OutputStreamWriter(System.err, CHARSET));
|
||||
}
|
||||
|
||||
private void execute(final String[] argv) throws Exception {
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
|
||||
package org.eclipse.jgit.pgm.debug;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static org.eclipse.jgit.lib.Constants.HEAD;
|
||||
import static org.eclipse.jgit.lib.Constants.MASTER;
|
||||
import static org.eclipse.jgit.lib.Constants.R_HEADS;
|
||||
|
@ -154,7 +154,7 @@ private RefList<Ref> readLsRemote()
|
|||
throws IOException, FileNotFoundException {
|
||||
RefList.Builder<Ref> list = new RefList.Builder<>();
|
||||
try (BufferedReader br = new BufferedReader(new InputStreamReader(
|
||||
new FileInputStream(lsRemotePath), UTF_8))) {
|
||||
new FileInputStream(lsRemotePath), CHARSET))) {
|
||||
Ref last = null;
|
||||
String line;
|
||||
while ((line = br.readLine()) != null) {
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
|
||||
package org.eclipse.jgit.pgm.debug;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static org.eclipse.jgit.lib.Constants.HEAD;
|
||||
import static org.eclipse.jgit.lib.Constants.MASTER;
|
||||
import static org.eclipse.jgit.lib.Constants.R_HEADS;
|
||||
|
@ -192,7 +192,7 @@ private void printf(String fmt, Object... args) throws IOException {
|
|||
static List<Ref> readRefs(String inputFile) throws IOException {
|
||||
List<Ref> refs = new ArrayList<>();
|
||||
try (BufferedReader br = new BufferedReader(
|
||||
new InputStreamReader(new FileInputStream(inputFile), UTF_8))) {
|
||||
new InputStreamReader(new FileInputStream(inputFile), CHARSET))) {
|
||||
String line;
|
||||
while ((line = br.readLine()) != null) {
|
||||
ObjectId id = ObjectId.fromString(line.substring(0, 40));
|
||||
|
@ -227,7 +227,7 @@ private static List<LogEntry> readLog(String logPath)
|
|||
|
||||
List<LogEntry> log = new ArrayList<>();
|
||||
try (BufferedReader br = new BufferedReader(
|
||||
new InputStreamReader(new FileInputStream(logPath), UTF_8))) {
|
||||
new InputStreamReader(new FileInputStream(logPath), CHARSET))) {
|
||||
@SuppressWarnings("nls")
|
||||
Pattern pattern = Pattern.compile("([^,]+)" // 1: ref
|
||||
+ ",([0-9]+(?:[.][0-9]+)?)" // 2: time
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
*/
|
||||
package org.eclipse.jgit.ignore;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
|
@ -158,7 +158,7 @@ public CGitIgnoreRule(File gitDir, String pattern) throws IOException {
|
|||
this.gitDir = gitDir;
|
||||
this.pattern = pattern;
|
||||
Files.write(FileUtils.toPath(new File(gitDir, ".gitignore")),
|
||||
(pattern + "\n").getBytes(UTF_8), StandardOpenOption.CREATE,
|
||||
(pattern + "\n").getBytes(CHARSET), StandardOpenOption.CREATE,
|
||||
StandardOpenOption.TRUNCATE_EXISTING,
|
||||
StandardOpenOption.WRITE);
|
||||
}
|
||||
|
@ -188,7 +188,7 @@ private Process startCgitCheckIgnore(String path) throws IOException {
|
|||
Process proc = Runtime.getRuntime().exec(command, new String[0],
|
||||
gitDir);
|
||||
try (OutputStream out = proc.getOutputStream()) {
|
||||
out.write((path + "\n").getBytes(UTF_8));
|
||||
out.write((path + "\n").getBytes(CHARSET));
|
||||
out.flush();
|
||||
}
|
||||
return proc;
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
|
||||
package org.eclipse.jgit.api;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static org.eclipse.jgit.lib.CoreConfig.EolStreamType.AUTO_CRLF;
|
||||
import static org.eclipse.jgit.lib.CoreConfig.EolStreamType.AUTO_LF;
|
||||
import static org.eclipse.jgit.lib.CoreConfig.EolStreamType.DIRECT;
|
||||
|
@ -150,8 +150,8 @@ private void testCheckout(EolStreamType streamTypeText,
|
|||
EolStreamType streamTypeWithBinaryCheck, String output,
|
||||
String expectedConversion) throws Exception {
|
||||
ByteArrayOutputStream b;
|
||||
byte[] outputBytes = output.getBytes(UTF_8);
|
||||
byte[] expectedConversionBytes = expectedConversion.getBytes(UTF_8);
|
||||
byte[] outputBytes = output.getBytes(CHARSET);
|
||||
byte[] expectedConversionBytes = expectedConversion.getBytes(CHARSET);
|
||||
|
||||
// test using output text and assuming it was declared TEXT
|
||||
b = new ByteArrayOutputStream();
|
||||
|
@ -277,8 +277,8 @@ public void testCheckinCRLF() throws Exception {
|
|||
private void testCheckin(EolStreamType streamTypeText,
|
||||
EolStreamType streamTypeWithBinaryCheck, String input,
|
||||
String expectedConversion) throws Exception {
|
||||
byte[] inputBytes = input.getBytes(UTF_8);
|
||||
byte[] expectedConversionBytes = expectedConversion.getBytes(UTF_8);
|
||||
byte[] inputBytes = input.getBytes(CHARSET);
|
||||
byte[] expectedConversionBytes = expectedConversion.getBytes(CHARSET);
|
||||
|
||||
// test using input text and assuming it was declared TEXT
|
||||
try (InputStream in = EolStreamTypeUtil.wrapInputStream(
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
*/
|
||||
package org.eclipse.jgit.api;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -88,7 +88,7 @@ public void testAddAndRemoveNote() throws Exception {
|
|||
git.notesAdd().setObjectId(commit2).setMessage("data").call();
|
||||
Note note = git.notesShow().setObjectId(commit2).call();
|
||||
String content = new String(db.open(note.getData()).getCachedBytes(),
|
||||
UTF_8);
|
||||
CHARSET);
|
||||
assertEquals(content, "data");
|
||||
|
||||
git.notesRemove().setObjectId(commit2).call();
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
*/
|
||||
package org.eclipse.jgit.api;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
@ -592,7 +592,7 @@ public void setUp() throws Exception {
|
|||
private static void writeToFile(File actFile, String string)
|
||||
throws IOException {
|
||||
try (FileOutputStream fos = new FileOutputStream(actFile)) {
|
||||
fos.write(string.getBytes(UTF_8));
|
||||
fos.write(string.getBytes(CHARSET));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -606,7 +606,7 @@ private static void assertFileContentsEqual(File actFile, String string)
|
|||
bos.write(buffer, 0, read);
|
||||
read = fis.read(buffer);
|
||||
}
|
||||
String content = new String(bos.toByteArray(), UTF_8);
|
||||
String content = new String(bos.toByteArray(), CHARSET);
|
||||
assertEquals(string, content);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
*/
|
||||
package org.eclipse.jgit.api;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
@ -396,7 +396,7 @@ public void setUp() throws Exception {
|
|||
private static void writeToFile(File actFile, String string)
|
||||
throws IOException {
|
||||
try (FileOutputStream fos = new FileOutputStream(actFile)) {
|
||||
fos.write(string.getBytes(UTF_8));
|
||||
fos.write(string.getBytes(CHARSET));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -410,7 +410,7 @@ private static void assertFileContentsEqual(File actFile, String string)
|
|||
bos.write(buffer, 0, read);
|
||||
read = fis.read(buffer);
|
||||
}
|
||||
String content = new String(bos.toByteArray(), UTF_8);
|
||||
String content = new String(bos.toByteArray(), CHARSET);
|
||||
assertEquals(string, content);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
*/
|
||||
package org.eclipse.jgit.api;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
import static org.hamcrest.CoreMatchers.not;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
|
@ -1464,7 +1464,7 @@ public void testAuthorScriptConverter() throws Exception {
|
|||
assertEquals("GIT_AUTHOR_DATE='@123456789 -0100'", lines[2]);
|
||||
|
||||
PersonIdent parsedIdent = git.rebase().parseAuthor(
|
||||
convertedAuthor.getBytes(UTF_8));
|
||||
convertedAuthor.getBytes(CHARSET));
|
||||
assertEquals(ident.getName(), parsedIdent.getName());
|
||||
assertEquals(ident.getEmailAddress(), parsedIdent.getEmailAddress());
|
||||
// this is rounded to the last second
|
||||
|
@ -1481,7 +1481,7 @@ public void testAuthorScriptConverter() throws Exception {
|
|||
assertEquals("GIT_AUTHOR_DATE='@123456789 +0930'", lines[2]);
|
||||
|
||||
parsedIdent = git.rebase().parseAuthor(
|
||||
convertedAuthor.getBytes(UTF_8));
|
||||
convertedAuthor.getBytes(CHARSET));
|
||||
assertEquals(ident.getName(), parsedIdent.getName());
|
||||
assertEquals(ident.getEmailAddress(), parsedIdent.getEmailAddress());
|
||||
assertEquals(123456789000L, parsedIdent.getWhen().getTime());
|
||||
|
@ -2104,7 +2104,7 @@ private int countPicks() throws IOException {
|
|||
int count = 0;
|
||||
File todoFile = getTodoFile();
|
||||
try (BufferedReader br = new BufferedReader(new InputStreamReader(
|
||||
new FileInputStream(todoFile), UTF_8))) {
|
||||
new FileInputStream(todoFile), CHARSET))) {
|
||||
String line = br.readLine();
|
||||
while (line != null) {
|
||||
int firstBlank = line.indexOf(' ');
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
|
||||
package org.eclipse.jgit.diff;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
|
@ -240,6 +240,6 @@ public static RawText t(String text) {
|
|||
r.append(text.charAt(i));
|
||||
r.append('\n');
|
||||
}
|
||||
return new RawText(r.toString().getBytes(UTF_8));
|
||||
return new RawText(r.toString().getBytes(CHARSET));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
|
||||
package org.eclipse.jgit.diff;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
@ -136,8 +136,8 @@ public void testComparatorReduceCommonStartEnd() {
|
|||
e = c.reduceCommonStartEnd(t("abQxy"), t("abRxy"), e);
|
||||
assertEquals(new Edit(2, 3, 2, 3), e);
|
||||
|
||||
RawText a = new RawText("p\na b\nQ\nc d\n".getBytes(UTF_8));
|
||||
RawText b = new RawText("p\na b \nR\n c d \n".getBytes(UTF_8));
|
||||
RawText a = new RawText("p\na b\nQ\nc d\n".getBytes(CHARSET));
|
||||
RawText b = new RawText("p\na b \nR\n c d \n".getBytes(CHARSET));
|
||||
e = new Edit(0, 4, 0, 4);
|
||||
e = RawTextComparator.WS_IGNORE_ALL.reduceCommonStartEnd(a, b, e);
|
||||
assertEquals(new Edit(2, 3, 2, 3), e);
|
||||
|
@ -149,14 +149,14 @@ public void testComparatorReduceCommonStartEnd_EmptyLine() {
|
|||
RawText b;
|
||||
Edit e;
|
||||
|
||||
a = new RawText("R\n y\n".getBytes(UTF_8));
|
||||
b = new RawText("S\n\n y\n".getBytes(UTF_8));
|
||||
a = new RawText("R\n y\n".getBytes(CHARSET));
|
||||
b = new RawText("S\n\n y\n".getBytes(CHARSET));
|
||||
e = new Edit(0, 2, 0, 3);
|
||||
e = RawTextComparator.DEFAULT.reduceCommonStartEnd(a, b, e);
|
||||
assertEquals(new Edit(0, 1, 0, 2), e);
|
||||
|
||||
a = new RawText("S\n\n y\n".getBytes(UTF_8));
|
||||
b = new RawText("R\n y\n".getBytes(UTF_8));
|
||||
a = new RawText("S\n\n y\n".getBytes(CHARSET));
|
||||
b = new RawText("R\n y\n".getBytes(CHARSET));
|
||||
e = new Edit(0, 3, 0, 2);
|
||||
e = RawTextComparator.DEFAULT.reduceCommonStartEnd(a, b, e);
|
||||
assertEquals(new Edit(0, 2, 0, 1), e);
|
||||
|
@ -167,8 +167,8 @@ public void testComparatorReduceCommonStartButLastLineNoEol() {
|
|||
RawText a;
|
||||
RawText b;
|
||||
Edit e;
|
||||
a = new RawText("start".getBytes(UTF_8));
|
||||
b = new RawText("start of line".getBytes(UTF_8));
|
||||
a = new RawText("start".getBytes(CHARSET));
|
||||
b = new RawText("start of line".getBytes(CHARSET));
|
||||
e = new Edit(0, 1, 0, 1);
|
||||
e = RawTextComparator.DEFAULT.reduceCommonStartEnd(a, b, e);
|
||||
assertEquals(new Edit(0, 1, 0, 1), e);
|
||||
|
@ -179,8 +179,8 @@ public void testComparatorReduceCommonStartButLastLineNoEol_2() {
|
|||
RawText a;
|
||||
RawText b;
|
||||
Edit e;
|
||||
a = new RawText("start".getBytes(UTF_8));
|
||||
b = new RawText("start of\nlastline".getBytes(UTF_8));
|
||||
a = new RawText("start".getBytes(CHARSET));
|
||||
b = new RawText("start of\nlastline".getBytes(CHARSET));
|
||||
e = new Edit(0, 1, 0, 2);
|
||||
e = RawTextComparator.DEFAULT.reduceCommonStartEnd(a, b, e);
|
||||
assertEquals(new Edit(0, 1, 0, 2), e);
|
||||
|
@ -239,6 +239,6 @@ private static RawText t(String text) {
|
|||
r.append(text.charAt(i));
|
||||
r.append('\n');
|
||||
}
|
||||
return new RawText(r.toString().getBytes(UTF_8));
|
||||
return new RawText(r.toString().getBytes(CHARSET));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
|
||||
package org.eclipse.jgit.diff;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
|
@ -82,7 +82,7 @@ public void testIndexingLargeObject() throws IOException,
|
|||
+ "A\n" //
|
||||
+ "B\n" //
|
||||
+ "B\n" //
|
||||
+ "B\n").getBytes(UTF_8);
|
||||
+ "B\n").getBytes(CHARSET);
|
||||
SimilarityIndex si = new SimilarityIndex();
|
||||
si.hash(new ByteArrayInputStream(in), in.length, false);
|
||||
assertEquals(2, si.size());
|
||||
|
@ -130,12 +130,12 @@ public void testCommonScoreLargeObject_SameFiles_CR_canonicalization()
|
|||
+ "D\r\n" //
|
||||
+ "B\r\n";
|
||||
SimilarityIndex src = new SimilarityIndex();
|
||||
byte[] bytes1 = text.getBytes(UTF_8);
|
||||
byte[] bytes1 = text.getBytes(CHARSET);
|
||||
src.hash(new ByteArrayInputStream(bytes1), bytes1.length, true);
|
||||
src.sort();
|
||||
|
||||
SimilarityIndex dst = new SimilarityIndex();
|
||||
byte[] bytes2 = text.replace("\r", "").getBytes(UTF_8);
|
||||
byte[] bytes2 = text.replace("\r", "").getBytes(CHARSET);
|
||||
dst.hash(new ByteArrayInputStream(bytes2), bytes2.length, true);
|
||||
dst.sort();
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
|
||||
package org.eclipse.jgit.dircache;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static org.eclipse.jgit.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
@ -236,7 +236,7 @@ private static File pathOf(final String name) {
|
|||
private static Map<String, CGitIndexRecord> readLsFiles() throws Exception {
|
||||
final LinkedHashMap<String, CGitIndexRecord> r = new LinkedHashMap<>();
|
||||
try (BufferedReader br = new BufferedReader(new InputStreamReader(
|
||||
new FileInputStream(pathOf("gitgit.lsfiles")), UTF_8))) {
|
||||
new FileInputStream(pathOf("gitgit.lsfiles")), CHARSET))) {
|
||||
String line;
|
||||
while ((line = br.readLine()) != null) {
|
||||
final CGitIndexRecord cr = new CGitIndexRecord(line);
|
||||
|
@ -249,7 +249,7 @@ private static Map<String, CGitIndexRecord> readLsFiles() throws Exception {
|
|||
private static Map<String, CGitLsTreeRecord> readLsTree() throws Exception {
|
||||
final LinkedHashMap<String, CGitLsTreeRecord> r = new LinkedHashMap<>();
|
||||
try (BufferedReader br = new BufferedReader(new InputStreamReader(
|
||||
new FileInputStream(pathOf("gitgit.lstree")), UTF_8))) {
|
||||
new FileInputStream(pathOf("gitgit.lstree")), CHARSET))) {
|
||||
String line;
|
||||
while ((line = br.readLine()) != null) {
|
||||
final CGitLsTreeRecord cr = new CGitLsTreeRecord(line);
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
*/
|
||||
package org.eclipse.jgit.gitrepo;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
|
@ -82,7 +82,7 @@ public void testManifestParser() throws Exception {
|
|||
|
||||
ManifestParser parser = new ManifestParser(
|
||||
null, null, "master", baseUrl, null, null);
|
||||
parser.read(new ByteArrayInputStream(xmlContent.toString().getBytes(UTF_8)));
|
||||
parser.read(new ByteArrayInputStream(xmlContent.toString().getBytes(CHARSET)));
|
||||
// Unfiltered projects should have them all.
|
||||
results.clear();
|
||||
results.add("foo");
|
||||
|
@ -136,7 +136,7 @@ public void testManifestParserWithMissingFetchOnRemote() throws Exception {
|
|||
baseUrl, null, null);
|
||||
try {
|
||||
parser.read(new ByteArrayInputStream(
|
||||
xmlContent.toString().getBytes(UTF_8)));
|
||||
xmlContent.toString().getBytes(CHARSET)));
|
||||
fail("ManifestParser did not throw exception for missing fetch");
|
||||
} catch (IOException e) {
|
||||
assertTrue(e.getCause() instanceof SAXException);
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
*/
|
||||
package org.eclipse.jgit.gitrepo;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
@ -214,7 +214,7 @@ public void runTwiceIsNOP() throws Exception {
|
|||
|
||||
RevCommit commit = cmd
|
||||
.setInputStream(new ByteArrayInputStream(
|
||||
xmlContent.toString().getBytes(UTF_8)))
|
||||
xmlContent.toString().getBytes(CHARSET)))
|
||||
.setRemoteReader(repos)
|
||||
.setURI("platform/")
|
||||
.setTargetURI("platform/superproject")
|
||||
|
@ -225,7 +225,7 @@ public void runTwiceIsNOP() throws Exception {
|
|||
String firstIdStr = commit.getId().name() + ":" + ".gitmodules";
|
||||
commit = new RepoCommand(dest)
|
||||
.setInputStream(new ByteArrayInputStream(
|
||||
xmlContent.toString().getBytes(UTF_8)))
|
||||
xmlContent.toString().getBytes(CHARSET)))
|
||||
.setRemoteReader(repos)
|
||||
.setURI("platform/")
|
||||
.setTargetURI("platform/superproject")
|
||||
|
@ -266,7 +266,7 @@ public void androidSetup() throws Exception {
|
|||
repos.put("platform/base", child);
|
||||
|
||||
RevCommit commit = cmd
|
||||
.setInputStream(new ByteArrayInputStream(xmlContent.toString().getBytes(UTF_8)))
|
||||
.setInputStream(new ByteArrayInputStream(xmlContent.toString().getBytes(CHARSET)))
|
||||
.setRemoteReader(repos)
|
||||
.setURI("platform/")
|
||||
.setTargetURI("platform/superproject")
|
||||
|
@ -308,7 +308,7 @@ public void recordUnreachableRemotes() throws Exception {
|
|||
|
||||
RevCommit commit = new RepoCommand(dest)
|
||||
.setInputStream(new ByteArrayInputStream(
|
||||
xmlContent.toString().getBytes(UTF_8)))
|
||||
xmlContent.toString().getBytes(CHARSET)))
|
||||
.setRemoteReader(new IndexedRepos())
|
||||
.setURI("platform/")
|
||||
.setTargetURI("platform/superproject")
|
||||
|
@ -358,7 +358,7 @@ public void gerritSetup() throws Exception {
|
|||
repos.put("plugins/cookbook", child);
|
||||
|
||||
RevCommit commit = cmd
|
||||
.setInputStream(new ByteArrayInputStream(xmlContent.toString().getBytes(UTF_8)))
|
||||
.setInputStream(new ByteArrayInputStream(xmlContent.toString().getBytes(CHARSET)))
|
||||
.setRemoteReader(repos)
|
||||
.setURI("")
|
||||
.setTargetURI("gerrit")
|
||||
|
@ -412,7 +412,7 @@ public void absoluteRemoteURL() throws Exception {
|
|||
repos.put(repoUrl, child);
|
||||
|
||||
RevCommit commit = cmd
|
||||
.setInputStream(new ByteArrayInputStream(xmlContent.toString().getBytes(UTF_8)))
|
||||
.setInputStream(new ByteArrayInputStream(xmlContent.toString().getBytes(CHARSET)))
|
||||
.setRemoteReader(repos)
|
||||
.setURI(baseUrl)
|
||||
.setTargetURI("gerrit")
|
||||
|
@ -469,7 +469,7 @@ public void absoluteRemoteURLAbsoluteTargetURL() throws Exception {
|
|||
repos.put(repoUrl, child);
|
||||
|
||||
RevCommit commit = cmd
|
||||
.setInputStream(new ByteArrayInputStream(xmlContent.toString().getBytes(UTF_8)))
|
||||
.setInputStream(new ByteArrayInputStream(xmlContent.toString().getBytes(CHARSET)))
|
||||
.setRemoteReader(repos)
|
||||
.setURI(baseUrl)
|
||||
.setTargetURI(abs + "/superproject")
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
*/
|
||||
package org.eclipse.jgit.ignore;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static org.eclipse.jgit.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
|
@ -765,6 +765,6 @@ private InputStream writeToString(String... rules) {
|
|||
for (String line : rules) {
|
||||
data.append(line + "\n");
|
||||
}
|
||||
return new ByteArrayInputStream(data.toString().getBytes(UTF_8));
|
||||
return new ByteArrayInputStream(data.toString().getBytes(CHARSET));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
*/
|
||||
package org.eclipse.jgit.indexdiff;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
@ -128,7 +128,7 @@ private File restoreGitRepo(InputStream in, File testDir, String name)
|
|||
File restoreScript = new File(testDir, name + ".sh");
|
||||
try (OutputStream out = new BufferedOutputStream(
|
||||
new FileOutputStream(restoreScript));
|
||||
Writer writer = new OutputStreamWriter(out, UTF_8)) {
|
||||
Writer writer = new OutputStreamWriter(out, CHARSET)) {
|
||||
writer.write("echo `which git` 1>&2\n");
|
||||
writer.write("echo `git --version` 1>&2\n");
|
||||
writer.write("git init " + name + " && \\\n");
|
||||
|
|
|
@ -45,7 +45,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 static org.eclipse.jgit.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
|
@ -252,7 +252,7 @@ public void testDeleteHeadInBareRepo() throws IOException {
|
|||
|
||||
ObjectId blobId;
|
||||
try (ObjectInserter ins = bareRepo.newObjectInserter()) {
|
||||
blobId = ins.insert(Constants.OBJ_BLOB, "contents".getBytes(UTF_8));
|
||||
blobId = ins.insert(Constants.OBJ_BLOB, "contents".getBytes(CHARSET));
|
||||
ins.flush();
|
||||
}
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
package org.eclipse.jgit.internal.storage.file;
|
||||
|
||||
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 static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
@ -522,7 +522,7 @@ public void test023_createCommitNonAnullii() throws IOException {
|
|||
4294967295000L, 60));
|
||||
commit.setCommitter(new PersonIdent("Joe Hacker", "joe2@example.com",
|
||||
4294967295000L, 60));
|
||||
commit.setEncoding(UTF_8);
|
||||
commit.setEncoding(CHARSET);
|
||||
commit.setMessage("\u00dcbergeeks");
|
||||
ObjectId cid = insertCommit(commit);
|
||||
assertEquals("4680908112778718f37e686cbebcc912730b3154", cid.name());
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
|
||||
package org.eclipse.jgit.junit;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
|
@ -418,6 +418,6 @@ private String blobAsString(AnyObjectId treeish, String path)
|
|||
RevObject obj = tr.get(rw.parseTree(treeish), path);
|
||||
assertSame(RevBlob.class, obj.getClass());
|
||||
ObjectLoader loader = rw.getObjectReader().open(obj);
|
||||
return new String(loader.getCachedBytes(), UTF_8);
|
||||
return new String(loader.getCachedBytes(), CHARSET);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
package org.eclipse.jgit.lib;
|
||||
|
||||
import static java.lang.Integer.valueOf;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static org.eclipse.jgit.junit.JGitTestUtil.concat;
|
||||
import static org.eclipse.jgit.lib.Constants.OBJECT_ID_LENGTH;
|
||||
import static org.eclipse.jgit.lib.Constants.OBJ_BAD;
|
||||
|
@ -1454,7 +1454,7 @@ public void testInvalidTreeDuplicateNames5()
|
|||
StringBuilder b = new StringBuilder();
|
||||
entry(b, "100644 A");
|
||||
entry(b, "100644 a");
|
||||
byte[] data = b.toString().getBytes(UTF_8);
|
||||
byte[] data = b.toString().getBytes(CHARSET);
|
||||
checker.setSafeForWindows(true);
|
||||
assertCorrupt("duplicate entry names", OBJ_TREE, data);
|
||||
assertSkipListAccepts(OBJ_TREE, data);
|
||||
|
@ -1468,7 +1468,7 @@ public void testInvalidTreeDuplicateNames6()
|
|||
StringBuilder b = new StringBuilder();
|
||||
entry(b, "100644 A");
|
||||
entry(b, "100644 a");
|
||||
byte[] data = b.toString().getBytes(UTF_8);
|
||||
byte[] data = b.toString().getBytes(CHARSET);
|
||||
checker.setSafeForMacOS(true);
|
||||
assertCorrupt("duplicate entry names", OBJ_TREE, data);
|
||||
assertSkipListAccepts(OBJ_TREE, data);
|
||||
|
@ -1482,7 +1482,7 @@ public void testInvalidTreeDuplicateNames7()
|
|||
StringBuilder b = new StringBuilder();
|
||||
entry(b, "100644 \u0065\u0301");
|
||||
entry(b, "100644 \u00e9");
|
||||
byte[] data = b.toString().getBytes(UTF_8);
|
||||
byte[] data = b.toString().getBytes(CHARSET);
|
||||
checker.setSafeForMacOS(true);
|
||||
assertCorrupt("duplicate entry names", OBJ_TREE, data);
|
||||
assertSkipListAccepts(OBJ_TREE, data);
|
||||
|
@ -1496,7 +1496,7 @@ public void testInvalidTreeDuplicateNames8()
|
|||
StringBuilder b = new StringBuilder();
|
||||
entry(b, "100644 A");
|
||||
checker.setSafeForMacOS(true);
|
||||
checker.checkTree(b.toString().getBytes(UTF_8));
|
||||
checker.checkTree(b.toString().getBytes(CHARSET));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
*/
|
||||
package org.eclipse.jgit.merge;
|
||||
|
||||
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.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
|
@ -756,7 +756,7 @@ public void checkContentMergeLargeBinaries(MergeStrategy strategy) throws Except
|
|||
}
|
||||
binary[50] = '\0';
|
||||
|
||||
writeTrashFile("file", new String(binary, UTF_8));
|
||||
writeTrashFile("file", new String(binary, CHARSET));
|
||||
git.add().addFilepattern("file").call();
|
||||
RevCommit first = git.commit().setMessage("added file").call();
|
||||
|
||||
|
@ -764,7 +764,7 @@ public void checkContentMergeLargeBinaries(MergeStrategy strategy) throws Except
|
|||
int idx = LINELEN * 1200 + 1;
|
||||
byte save = binary[idx];
|
||||
binary[idx] = '@';
|
||||
writeTrashFile("file", new String(binary, UTF_8));
|
||||
writeTrashFile("file", new String(binary, CHARSET));
|
||||
|
||||
binary[idx] = save;
|
||||
git.add().addFilepattern("file").call();
|
||||
|
@ -773,7 +773,7 @@ public void checkContentMergeLargeBinaries(MergeStrategy strategy) throws Except
|
|||
|
||||
git.checkout().setCreateBranch(true).setStartPoint(first).setName("side").call();
|
||||
binary[LINELEN * 1500 + 1] = '!';
|
||||
writeTrashFile("file", new String(binary, UTF_8));
|
||||
writeTrashFile("file", new String(binary, CHARSET));
|
||||
git.add().addFilepattern("file").call();
|
||||
RevCommit sideCommit = git.commit().setAll(true)
|
||||
.setMessage("modified file l 1500").call();
|
||||
|
@ -935,7 +935,7 @@ public void checkContentMergeConflict_noTree(MergeStrategy strategy)
|
|||
merger.getMergeResults().get("file");
|
||||
try (ByteArrayOutputStream out = new ByteArrayOutputStream()) {
|
||||
fmt.formatMerge(out, merger.getMergeResults().get("file"),
|
||||
"BASE", "OURS", "THEIRS", UTF_8.name());
|
||||
"BASE", "OURS", "THEIRS", CHARSET.name());
|
||||
String expected = "<<<<<<< OURS\n"
|
||||
+ "1master\n"
|
||||
+ "=======\n"
|
||||
|
@ -943,7 +943,7 @@ public void checkContentMergeConflict_noTree(MergeStrategy strategy)
|
|||
+ ">>>>>>> THEIRS\n"
|
||||
+ "2\n"
|
||||
+ "3";
|
||||
assertEquals(expected, new String(out.toByteArray(), UTF_8));
|
||||
assertEquals(expected, new String(out.toByteArray(), CHARSET));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1328,6 +1328,6 @@ private String readBlob(ObjectId treeish, String path) throws Exception {
|
|||
if (obj == null) {
|
||||
return null;
|
||||
}
|
||||
return new String(rw.getObjectReader().open(obj, OBJ_BLOB).getBytes(), UTF_8);
|
||||
return new String(rw.getObjectReader().open(obj, OBJ_BLOB).getBytes(), CHARSET);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
package org.eclipse.jgit.patch;
|
||||
|
||||
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 static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
@ -83,7 +83,7 @@ public void testGetText_NoBinary() throws IOException {
|
|||
@Test
|
||||
public void testGetText_Convert() throws IOException {
|
||||
final Charset csOld = ISO_8859_1;
|
||||
final Charset csNew = UTF_8;
|
||||
final Charset csNew = CHARSET;
|
||||
final Patch p = parseTestPatchFile();
|
||||
assertTrue(p.getErrors().isEmpty());
|
||||
assertEquals(1, p.getFiles().size());
|
||||
|
@ -103,7 +103,7 @@ public void testGetText_Convert() throws IOException {
|
|||
@Test
|
||||
public void testGetText_DiffCc() throws IOException {
|
||||
final Charset csOld = ISO_8859_1;
|
||||
final Charset csNew = UTF_8;
|
||||
final Charset csNew = CHARSET;
|
||||
final Patch p = parseTestPatchFile();
|
||||
assertTrue(p.getErrors().isEmpty());
|
||||
assertEquals(1, p.getFiles().size());
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
package org.eclipse.jgit.revwalk;
|
||||
|
||||
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 static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
@ -114,7 +114,7 @@ public void testParse_NoParents() throws Exception {
|
|||
assertNull(c.getTree());
|
||||
assertNull(c.parents);
|
||||
|
||||
c.parseCanonical(rw, body.toString().getBytes(UTF_8));
|
||||
c.parseCanonical(rw, body.toString().getBytes(CHARSET));
|
||||
assertNotNull(c.getTree());
|
||||
assertEquals(treeId, c.getTree().getId());
|
||||
assertSame(rw.lookupTree(treeId), c.getTree());
|
||||
|
@ -148,7 +148,7 @@ private RevCommit create(final String msg) throws Exception {
|
|||
|
||||
final RevCommit c;
|
||||
c = new RevCommit(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
|
||||
c.parseCanonical(new RevWalk(db), b.toString().getBytes(UTF_8));
|
||||
c.parseCanonical(new RevWalk(db), b.toString().getBytes(CHARSET));
|
||||
return c;
|
||||
}
|
||||
|
||||
|
@ -161,7 +161,7 @@ public void testParse_WeirdHeaderOnlyCommit() throws Exception {
|
|||
|
||||
final RevCommit c;
|
||||
c = new RevCommit(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
|
||||
c.parseCanonical(new RevWalk(db), b.toString().getBytes(UTF_8));
|
||||
c.parseCanonical(new RevWalk(db), b.toString().getBytes(CHARSET));
|
||||
|
||||
assertEquals("", c.getFullMessage());
|
||||
assertEquals("", c.getShortMessage());
|
||||
|
@ -176,7 +176,7 @@ public void testParse_incompleteAuthorAndCommitter() throws Exception {
|
|||
|
||||
final RevCommit c;
|
||||
c = new RevCommit(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
|
||||
c.parseCanonical(new RevWalk(db), b.toString().getBytes(UTF_8));
|
||||
c.parseCanonical(new RevWalk(db), b.toString().getBytes(CHARSET));
|
||||
|
||||
assertEquals(new PersonIdent("", "a_u_thor@example.com", 1218123387000l, 7), c.getAuthorIdent());
|
||||
assertEquals(new PersonIdent("", "", 1218123390000l, -5), c.getCommitterIdent());
|
||||
|
@ -185,13 +185,13 @@ public void testParse_incompleteAuthorAndCommitter() throws Exception {
|
|||
@Test
|
||||
public void testParse_implicit_UTF8_encoded() throws Exception {
|
||||
final ByteArrayOutputStream b = new ByteArrayOutputStream();
|
||||
b.write("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes(UTF_8));
|
||||
b.write("author F\u00f6r fattare <a_u_thor@example.com> 1218123387 +0700\n".getBytes(UTF_8));
|
||||
b.write("committer C O. Miter <c@example.com> 1218123390 -0500\n".getBytes(UTF_8));
|
||||
b.write("\n".getBytes(UTF_8));
|
||||
b.write("Sm\u00f6rg\u00e5sbord\n".getBytes(UTF_8));
|
||||
b.write("\n".getBytes(UTF_8));
|
||||
b.write("\u304d\u308c\u3044\n".getBytes(UTF_8));
|
||||
b.write("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes(CHARSET));
|
||||
b.write("author F\u00f6r fattare <a_u_thor@example.com> 1218123387 +0700\n".getBytes(CHARSET));
|
||||
b.write("committer C O. Miter <c@example.com> 1218123390 -0500\n".getBytes(CHARSET));
|
||||
b.write("\n".getBytes(CHARSET));
|
||||
b.write("Sm\u00f6rg\u00e5sbord\n".getBytes(CHARSET));
|
||||
b.write("\n".getBytes(CHARSET));
|
||||
b.write("\u304d\u308c\u3044\n".getBytes(CHARSET));
|
||||
final RevCommit c;
|
||||
c = new RevCommit(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67")); // bogus id
|
||||
c.parseCanonical(new RevWalk(db), b.toByteArray());
|
||||
|
@ -205,13 +205,13 @@ public void testParse_implicit_UTF8_encoded() throws Exception {
|
|||
@Test
|
||||
public void testParse_implicit_mixed_encoded() throws Exception {
|
||||
final ByteArrayOutputStream b = new ByteArrayOutputStream();
|
||||
b.write("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes(UTF_8));
|
||||
b.write("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes(CHARSET));
|
||||
b.write("author F\u00f6r fattare <a_u_thor@example.com> 1218123387 +0700\n".getBytes(ISO_8859_1));
|
||||
b.write("committer C O. Miter <c@example.com> 1218123390 -0500\n".getBytes(UTF_8));
|
||||
b.write("\n".getBytes(UTF_8));
|
||||
b.write("Sm\u00f6rg\u00e5sbord\n".getBytes(UTF_8));
|
||||
b.write("\n".getBytes(UTF_8));
|
||||
b.write("\u304d\u308c\u3044\n".getBytes(UTF_8));
|
||||
b.write("committer C O. Miter <c@example.com> 1218123390 -0500\n".getBytes(CHARSET));
|
||||
b.write("\n".getBytes(CHARSET));
|
||||
b.write("Sm\u00f6rg\u00e5sbord\n".getBytes(CHARSET));
|
||||
b.write("\n".getBytes(CHARSET));
|
||||
b.write("\u304d\u308c\u3044\n".getBytes(CHARSET));
|
||||
final RevCommit c;
|
||||
c = new RevCommit(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67")); // bogus id
|
||||
c.parseCanonical(new RevWalk(db), b.toByteArray());
|
||||
|
@ -260,14 +260,14 @@ public void testParse_explicit_encoded() throws Exception {
|
|||
@Test
|
||||
public void testParse_explicit_bad_encoded() throws Exception {
|
||||
final ByteArrayOutputStream b = new ByteArrayOutputStream();
|
||||
b.write("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes(UTF_8));
|
||||
b.write("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes(CHARSET));
|
||||
b.write("author F\u00f6r fattare <a_u_thor@example.com> 1218123387 +0700\n".getBytes(ISO_8859_1));
|
||||
b.write("committer C O. Miter <c@example.com> 1218123390 -0500\n".getBytes(UTF_8));
|
||||
b.write("encoding EUC-JP\n".getBytes(UTF_8));
|
||||
b.write("\n".getBytes(UTF_8));
|
||||
b.write("\u304d\u308c\u3044\n".getBytes(UTF_8));
|
||||
b.write("\n".getBytes(UTF_8));
|
||||
b.write("Hi\n".getBytes(UTF_8));
|
||||
b.write("committer C O. Miter <c@example.com> 1218123390 -0500\n".getBytes(CHARSET));
|
||||
b.write("encoding EUC-JP\n".getBytes(CHARSET));
|
||||
b.write("\n".getBytes(CHARSET));
|
||||
b.write("\u304d\u308c\u3044\n".getBytes(CHARSET));
|
||||
b.write("\n".getBytes(CHARSET));
|
||||
b.write("Hi\n".getBytes(CHARSET));
|
||||
final RevCommit c;
|
||||
c = new RevCommit(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67")); // bogus id
|
||||
c.parseCanonical(new RevWalk(db), b.toByteArray());
|
||||
|
@ -291,14 +291,14 @@ public void testParse_explicit_bad_encoded() throws Exception {
|
|||
@Test
|
||||
public void testParse_explicit_bad_encoded2() throws Exception {
|
||||
final ByteArrayOutputStream b = new ByteArrayOutputStream();
|
||||
b.write("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes(UTF_8));
|
||||
b.write("author F\u00f6r fattare <a_u_thor@example.com> 1218123387 +0700\n".getBytes(UTF_8));
|
||||
b.write("committer C O. Miter <c@example.com> 1218123390 -0500\n".getBytes(UTF_8));
|
||||
b.write("encoding ISO-8859-1\n".getBytes(UTF_8));
|
||||
b.write("\n".getBytes(UTF_8));
|
||||
b.write("\u304d\u308c\u3044\n".getBytes(UTF_8));
|
||||
b.write("\n".getBytes(UTF_8));
|
||||
b.write("Hi\n".getBytes(UTF_8));
|
||||
b.write("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes(CHARSET));
|
||||
b.write("author F\u00f6r fattare <a_u_thor@example.com> 1218123387 +0700\n".getBytes(CHARSET));
|
||||
b.write("committer C O. Miter <c@example.com> 1218123390 -0500\n".getBytes(CHARSET));
|
||||
b.write("encoding ISO-8859-1\n".getBytes(CHARSET));
|
||||
b.write("\n".getBytes(CHARSET));
|
||||
b.write("\u304d\u308c\u3044\n".getBytes(CHARSET));
|
||||
b.write("\n".getBytes(CHARSET));
|
||||
b.write("Hi\n".getBytes(CHARSET));
|
||||
final RevCommit c;
|
||||
c = new RevCommit(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67")); // bogus id
|
||||
c.parseCanonical(new RevWalk(db), b.toByteArray());
|
||||
|
@ -313,13 +313,13 @@ public void testParse_explicit_bad_encoded2() throws Exception {
|
|||
public void testParse_incorrectUtf8Name() throws Exception {
|
||||
ByteArrayOutputStream b = new ByteArrayOutputStream();
|
||||
b.write("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n"
|
||||
.getBytes(UTF_8));
|
||||
b.write("author au <a@example.com> 1218123387 +0700\n".getBytes(UTF_8));
|
||||
.getBytes(CHARSET));
|
||||
b.write("author au <a@example.com> 1218123387 +0700\n".getBytes(CHARSET));
|
||||
b.write("committer co <c@example.com> 1218123390 -0500\n"
|
||||
.getBytes(UTF_8));
|
||||
b.write("encoding 'utf8'\n".getBytes(UTF_8));
|
||||
b.write("\n".getBytes(UTF_8));
|
||||
b.write("Sm\u00f6rg\u00e5sbord\n".getBytes(UTF_8));
|
||||
.getBytes(CHARSET));
|
||||
b.write("encoding 'utf8'\n".getBytes(CHARSET));
|
||||
b.write("\n".getBytes(CHARSET));
|
||||
b.write("Sm\u00f6rg\u00e5sbord\n".getBytes(CHARSET));
|
||||
|
||||
RevCommit c = new RevCommit(
|
||||
id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
|
||||
|
@ -338,12 +338,12 @@ public void testParse_incorrectUtf8Name() throws Exception {
|
|||
@Test
|
||||
public void testParse_illegalEncoding() throws Exception {
|
||||
ByteArrayOutputStream b = new ByteArrayOutputStream();
|
||||
b.write("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes(UTF_8));
|
||||
b.write("author au <a@example.com> 1218123387 +0700\n".getBytes(UTF_8));
|
||||
b.write("committer co <c@example.com> 1218123390 -0500\n".getBytes(UTF_8));
|
||||
b.write("encoding utf-8logoutputencoding=gbk\n".getBytes(UTF_8));
|
||||
b.write("\n".getBytes(UTF_8));
|
||||
b.write("message\n".getBytes(UTF_8));
|
||||
b.write("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes(CHARSET));
|
||||
b.write("author au <a@example.com> 1218123387 +0700\n".getBytes(CHARSET));
|
||||
b.write("committer co <c@example.com> 1218123390 -0500\n".getBytes(CHARSET));
|
||||
b.write("encoding utf-8logoutputencoding=gbk\n".getBytes(CHARSET));
|
||||
b.write("\n".getBytes(CHARSET));
|
||||
b.write("message\n".getBytes(CHARSET));
|
||||
|
||||
RevCommit c = new RevCommit(
|
||||
id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
|
||||
|
@ -365,12 +365,12 @@ public void testParse_illegalEncoding() throws Exception {
|
|||
@Test
|
||||
public void testParse_unsupportedEncoding() throws Exception {
|
||||
ByteArrayOutputStream b = new ByteArrayOutputStream();
|
||||
b.write("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes(UTF_8));
|
||||
b.write("author au <a@example.com> 1218123387 +0700\n".getBytes(UTF_8));
|
||||
b.write("committer co <c@example.com> 1218123390 -0500\n".getBytes(UTF_8));
|
||||
b.write("encoding it_IT.UTF8\n".getBytes(UTF_8));
|
||||
b.write("\n".getBytes(UTF_8));
|
||||
b.write("message\n".getBytes(UTF_8));
|
||||
b.write("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes(CHARSET));
|
||||
b.write("author au <a@example.com> 1218123387 +0700\n".getBytes(CHARSET));
|
||||
b.write("committer co <c@example.com> 1218123390 -0500\n".getBytes(CHARSET));
|
||||
b.write("encoding it_IT.UTF8\n".getBytes(CHARSET));
|
||||
b.write("\n".getBytes(CHARSET));
|
||||
b.write("message\n".getBytes(CHARSET));
|
||||
|
||||
RevCommit c = new RevCommit(
|
||||
id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
package org.eclipse.jgit.revwalk;
|
||||
|
||||
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 static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
@ -98,7 +98,7 @@ private void testOneType(final int typeCode) throws Exception {
|
|||
assertNull(c.getObject());
|
||||
assertNull(c.getTagName());
|
||||
|
||||
c.parseCanonical(rw, b.toString().getBytes(UTF_8));
|
||||
c.parseCanonical(rw, b.toString().getBytes(CHARSET));
|
||||
assertNotNull(c.getObject());
|
||||
assertEquals(id, c.getObject().getId());
|
||||
assertSame(rw.lookupAny(id, typeCode), c.getObject());
|
||||
|
@ -141,7 +141,7 @@ public void testParseAllFields() throws Exception {
|
|||
assertNull(c.getObject());
|
||||
assertNull(c.getTagName());
|
||||
|
||||
c.parseCanonical(rw, body.toString().getBytes(UTF_8));
|
||||
c.parseCanonical(rw, body.toString().getBytes(CHARSET));
|
||||
assertNotNull(c.getObject());
|
||||
assertEquals(treeId, c.getObject().getId());
|
||||
assertSame(rw.lookupTree(treeId), c.getObject());
|
||||
|
@ -189,7 +189,7 @@ public void testParseOldStyleNoTagger() throws Exception {
|
|||
assertNull(c.getObject());
|
||||
assertNull(c.getTagName());
|
||||
|
||||
c.parseCanonical(rw, body.toString().getBytes(UTF_8));
|
||||
c.parseCanonical(rw, body.toString().getBytes(CHARSET));
|
||||
assertNotNull(c.getObject());
|
||||
assertEquals(treeId, c.getObject().getId());
|
||||
assertSame(rw.lookupTree(treeId), c.getObject());
|
||||
|
@ -213,7 +213,7 @@ private RevTag create(final String msg) throws Exception {
|
|||
|
||||
final RevTag c;
|
||||
c = new RevTag(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
|
||||
c.parseCanonical(new RevWalk(db), b.toString().getBytes(UTF_8));
|
||||
c.parseCanonical(new RevWalk(db), b.toString().getBytes(CHARSET));
|
||||
return c;
|
||||
}
|
||||
|
||||
|
@ -221,17 +221,17 @@ private RevTag create(final String msg) throws Exception {
|
|||
public void testParse_implicit_UTF8_encoded() throws Exception {
|
||||
final ByteArrayOutputStream b = new ByteArrayOutputStream();
|
||||
b.write("object 9788669ad918b6fcce64af8882fc9a81cb6aba67\n"
|
||||
.getBytes(UTF_8));
|
||||
b.write("type tree\n".getBytes(UTF_8));
|
||||
b.write("tag v1.2.3.4.5\n".getBytes(UTF_8));
|
||||
.getBytes(CHARSET));
|
||||
b.write("type tree\n".getBytes(CHARSET));
|
||||
b.write("tag v1.2.3.4.5\n".getBytes(CHARSET));
|
||||
|
||||
b
|
||||
.write("tagger F\u00f6r fattare <a_u_thor@example.com> 1218123387 +0700\n"
|
||||
.getBytes(UTF_8));
|
||||
b.write("\n".getBytes(UTF_8));
|
||||
b.write("Sm\u00f6rg\u00e5sbord\n".getBytes(UTF_8));
|
||||
b.write("\n".getBytes(UTF_8));
|
||||
b.write("\u304d\u308c\u3044\n".getBytes(UTF_8));
|
||||
.getBytes(CHARSET));
|
||||
b.write("\n".getBytes(CHARSET));
|
||||
b.write("Sm\u00f6rg\u00e5sbord\n".getBytes(CHARSET));
|
||||
b.write("\n".getBytes(CHARSET));
|
||||
b.write("\u304d\u308c\u3044\n".getBytes(CHARSET));
|
||||
final RevTag c;
|
||||
c = new RevTag(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
|
||||
c.parseCanonical(new RevWalk(db), b.toByteArray());
|
||||
|
@ -246,15 +246,15 @@ public void testParse_implicit_UTF8_encoded() throws Exception {
|
|||
public void testParse_implicit_mixed_encoded() throws Exception {
|
||||
final ByteArrayOutputStream b = new ByteArrayOutputStream();
|
||||
b.write("object 9788669ad918b6fcce64af8882fc9a81cb6aba67\n"
|
||||
.getBytes(UTF_8));
|
||||
b.write("type tree\n".getBytes(UTF_8));
|
||||
b.write("tag v1.2.3.4.5\n".getBytes(UTF_8));
|
||||
.getBytes(CHARSET));
|
||||
b.write("type tree\n".getBytes(CHARSET));
|
||||
b.write("tag v1.2.3.4.5\n".getBytes(CHARSET));
|
||||
b.write("tagger F\u00f6r fattare <a_u_thor@example.com> 1218123387 +0700\n"
|
||||
.getBytes(ISO_8859_1));
|
||||
b.write("\n".getBytes(UTF_8));
|
||||
b.write("Sm\u00f6rg\u00e5sbord\n".getBytes(UTF_8));
|
||||
b.write("\n".getBytes(UTF_8));
|
||||
b.write("\u304d\u308c\u3044\n".getBytes(UTF_8));
|
||||
b.write("\n".getBytes(CHARSET));
|
||||
b.write("Sm\u00f6rg\u00e5sbord\n".getBytes(CHARSET));
|
||||
b.write("\n".getBytes(CHARSET));
|
||||
b.write("\u304d\u308c\u3044\n".getBytes(CHARSET));
|
||||
final RevTag c;
|
||||
c = new RevTag(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
|
||||
c.parseCanonical(new RevWalk(db), b.toByteArray());
|
||||
|
@ -307,17 +307,17 @@ public void testParse_explicit_encoded() throws Exception {
|
|||
public void testParse_explicit_bad_encoded() throws Exception {
|
||||
final ByteArrayOutputStream b = new ByteArrayOutputStream();
|
||||
b.write("object 9788669ad918b6fcce64af8882fc9a81cb6aba67\n"
|
||||
.getBytes(UTF_8));
|
||||
b.write("type tree\n".getBytes(UTF_8));
|
||||
b.write("tag v1.2.3.4.5\n".getBytes(UTF_8));
|
||||
.getBytes(CHARSET));
|
||||
b.write("type tree\n".getBytes(CHARSET));
|
||||
b.write("tag v1.2.3.4.5\n".getBytes(CHARSET));
|
||||
b
|
||||
.write("tagger F\u00f6r fattare <a_u_thor@example.com> 1218123387 +0700\n"
|
||||
.getBytes(ISO_8859_1));
|
||||
b.write("encoding EUC-JP\n".getBytes(UTF_8));
|
||||
b.write("\n".getBytes(UTF_8));
|
||||
b.write("\u304d\u308c\u3044\n".getBytes(UTF_8));
|
||||
b.write("\n".getBytes(UTF_8));
|
||||
b.write("Hi\n".getBytes(UTF_8));
|
||||
b.write("encoding EUC-JP\n".getBytes(CHARSET));
|
||||
b.write("\n".getBytes(CHARSET));
|
||||
b.write("\u304d\u308c\u3044\n".getBytes(CHARSET));
|
||||
b.write("\n".getBytes(CHARSET));
|
||||
b.write("Hi\n".getBytes(CHARSET));
|
||||
final RevTag c;
|
||||
c = new RevTag(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
|
||||
c.parseCanonical(new RevWalk(db), b.toByteArray());
|
||||
|
@ -342,17 +342,17 @@ public void testParse_explicit_bad_encoded() throws Exception {
|
|||
public void testParse_explicit_bad_encoded2() throws Exception {
|
||||
final ByteArrayOutputStream b = new ByteArrayOutputStream();
|
||||
b.write("object 9788669ad918b6fcce64af8882fc9a81cb6aba67\n"
|
||||
.getBytes(UTF_8));
|
||||
b.write("type tree\n".getBytes(UTF_8));
|
||||
b.write("tag v1.2.3.4.5\n".getBytes(UTF_8));
|
||||
.getBytes(CHARSET));
|
||||
b.write("type tree\n".getBytes(CHARSET));
|
||||
b.write("tag v1.2.3.4.5\n".getBytes(CHARSET));
|
||||
b
|
||||
.write("tagger F\u00f6r fattare <a_u_thor@example.com> 1218123387 +0700\n"
|
||||
.getBytes(UTF_8));
|
||||
b.write("encoding ISO-8859-1\n".getBytes(UTF_8));
|
||||
b.write("\n".getBytes(UTF_8));
|
||||
b.write("\u304d\u308c\u3044\n".getBytes(UTF_8));
|
||||
b.write("\n".getBytes(UTF_8));
|
||||
b.write("Hi\n".getBytes(UTF_8));
|
||||
.getBytes(CHARSET));
|
||||
b.write("encoding ISO-8859-1\n".getBytes(CHARSET));
|
||||
b.write("\n".getBytes(CHARSET));
|
||||
b.write("\u304d\u308c\u3044\n".getBytes(CHARSET));
|
||||
b.write("\n".getBytes(CHARSET));
|
||||
b.write("Hi\n".getBytes(CHARSET));
|
||||
final RevTag c;
|
||||
c = new RevTag(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
|
||||
c.parseCanonical(new RevWalk(db), b.toByteArray());
|
||||
|
@ -365,13 +365,13 @@ public void testParse_explicit_bad_encoded2() throws Exception {
|
|||
@Test
|
||||
public void testParse_illegalEncoding() throws Exception {
|
||||
ByteArrayOutputStream b = new ByteArrayOutputStream();
|
||||
b.write("object 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes(UTF_8));
|
||||
b.write("type tree\n".getBytes(UTF_8));
|
||||
b.write("tag v1.0\n".getBytes(UTF_8));
|
||||
b.write("tagger t <t@example.com> 1218123387 +0700\n".getBytes(UTF_8));
|
||||
b.write("encoding utf-8logoutputencoding=gbk\n".getBytes(UTF_8));
|
||||
b.write("\n".getBytes(UTF_8));
|
||||
b.write("message\n".getBytes(UTF_8));
|
||||
b.write("object 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes(CHARSET));
|
||||
b.write("type tree\n".getBytes(CHARSET));
|
||||
b.write("tag v1.0\n".getBytes(CHARSET));
|
||||
b.write("tagger t <t@example.com> 1218123387 +0700\n".getBytes(CHARSET));
|
||||
b.write("encoding utf-8logoutputencoding=gbk\n".getBytes(CHARSET));
|
||||
b.write("\n".getBytes(CHARSET));
|
||||
b.write("message\n".getBytes(CHARSET));
|
||||
|
||||
RevTag t = new RevTag(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
|
||||
t.parseCanonical(new RevWalk(db), b.toByteArray());
|
||||
|
@ -384,13 +384,13 @@ public void testParse_illegalEncoding() throws Exception {
|
|||
@Test
|
||||
public void testParse_unsupportedEncoding() throws Exception {
|
||||
ByteArrayOutputStream b = new ByteArrayOutputStream();
|
||||
b.write("object 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes(UTF_8));
|
||||
b.write("type tree\n".getBytes(UTF_8));
|
||||
b.write("tag v1.0\n".getBytes(UTF_8));
|
||||
b.write("tagger t <t@example.com> 1218123387 +0700\n".getBytes(UTF_8));
|
||||
b.write("encoding it_IT.UTF8\n".getBytes(UTF_8));
|
||||
b.write("\n".getBytes(UTF_8));
|
||||
b.write("message\n".getBytes(UTF_8));
|
||||
b.write("object 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes(CHARSET));
|
||||
b.write("type tree\n".getBytes(CHARSET));
|
||||
b.write("tag v1.0\n".getBytes(CHARSET));
|
||||
b.write("tagger t <t@example.com> 1218123387 +0700\n".getBytes(CHARSET));
|
||||
b.write("encoding it_IT.UTF8\n".getBytes(CHARSET));
|
||||
b.write("\n".getBytes(CHARSET));
|
||||
b.write("message\n".getBytes(CHARSET));
|
||||
|
||||
RevTag t = new RevTag(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
|
||||
t.parseCanonical(new RevWalk(db), b.toByteArray());
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
*/
|
||||
package org.eclipse.jgit.storage.file;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static org.eclipse.jgit.util.FileUtils.pathToString;
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
@ -105,7 +105,7 @@ public void testSystemEncoding() throws IOException, ConfigInvalidException {
|
|||
|
||||
@Test
|
||||
public void testUTF8withoutBOM() throws IOException, ConfigInvalidException {
|
||||
final File file = createFile(CONTENT1.getBytes(UTF_8));
|
||||
final File file = createFile(CONTENT1.getBytes(CHARSET));
|
||||
final FileBasedConfig config = new FileBasedConfig(file, FS.DETECTED);
|
||||
config.load();
|
||||
assertEquals(ALICE, config.getString(USER, null, NAME));
|
||||
|
@ -121,7 +121,7 @@ public void testUTF8withBOM() throws IOException, ConfigInvalidException {
|
|||
bos1.write(0xEF);
|
||||
bos1.write(0xBB);
|
||||
bos1.write(0xBF);
|
||||
bos1.write(CONTENT1.getBytes(UTF_8));
|
||||
bos1.write(CONTENT1.getBytes(CHARSET));
|
||||
|
||||
final File file = createFile(bos1.toByteArray());
|
||||
final FileBasedConfig config = new FileBasedConfig(file, FS.DETECTED);
|
||||
|
@ -135,7 +135,7 @@ public void testUTF8withBOM() throws IOException, ConfigInvalidException {
|
|||
bos2.write(0xEF);
|
||||
bos2.write(0xBB);
|
||||
bos2.write(0xBF);
|
||||
bos2.write(CONTENT2.getBytes(UTF_8));
|
||||
bos2.write(CONTENT2.getBytes(CHARSET));
|
||||
assertArrayEquals(bos2.toByteArray(), IO.readFully(file));
|
||||
}
|
||||
|
||||
|
|
|
@ -45,7 +45,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.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
@ -199,7 +199,7 @@ public void testCustomObjectReader() throws Exception {
|
|||
Ref ref = repo.exactRef(refName);
|
||||
assertNotNull(ref);
|
||||
assertEquals(id, ref.getObjectId());
|
||||
assertEquals(data, new String(repo.open(id, OBJ_BLOB).getBytes(), UTF_8));
|
||||
assertEquals(data, new String(repo.open(id, OBJ_BLOB).getBytes(), CHARSET));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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.transport.WalkEncryptionTest.Util.cryptoCipherListPBE;
|
||||
import static org.eclipse.jgit.transport.WalkEncryptionTest.Util.cryptoCipherListTrans;
|
||||
import static org.eclipse.jgit.transport.WalkEncryptionTest.Util.folderDelete;
|
||||
|
@ -360,7 +360,7 @@ static class Util {
|
|||
* @throws Exception
|
||||
*/
|
||||
static String textRead(File file) throws Exception {
|
||||
return new String(Files.readAllBytes(file.toPath()), UTF_8);
|
||||
return new String(Files.readAllBytes(file.toPath()), CHARSET);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -371,7 +371,7 @@ static String textRead(File file) throws Exception {
|
|||
* @throws Exception
|
||||
*/
|
||||
static void textWrite(File file, String text) throws Exception {
|
||||
Files.write(file.toPath(), text.getBytes(UTF_8));
|
||||
Files.write(file.toPath(), text.getBytes(CHARSET));
|
||||
}
|
||||
|
||||
static void verifyFileContent(File fileOne, File fileTwo)
|
||||
|
@ -741,7 +741,7 @@ static void remoteVerify() throws Exception {
|
|||
AmazonS3 s3 = new AmazonS3(props);
|
||||
String file = JGIT_USER + "-" + UUID.randomUUID().toString();
|
||||
String path = JGIT_REMOTE_DIR + "/" + file;
|
||||
s3.put(bucket, path, file.getBytes(UTF_8));
|
||||
s3.put(bucket, path, file.getBytes(CHARSET));
|
||||
s3.delete(bucket, path);
|
||||
}
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
*/
|
||||
package org.eclipse.jgit.util;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
|
@ -93,7 +93,7 @@ private static void assertMatchResult(String pattern, String input, int position
|
|||
}
|
||||
|
||||
private static RawCharSequence raw(String text) {
|
||||
byte[] bytes = text.getBytes(UTF_8);
|
||||
byte[] bytes = text.getBytes(CHARSET);
|
||||
return new RawCharSequence(bytes, 0, bytes.length);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
|
||||
package org.eclipse.jgit.util.io;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
|
@ -129,6 +129,6 @@ private static void test(byte[] input, byte[] expected,
|
|||
}
|
||||
|
||||
private static byte[] asBytes(String in) {
|
||||
return in.getBytes(UTF_8);
|
||||
return in.getBytes(CHARSET);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
|
||||
package org.eclipse.jgit.util.sha1;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
@ -95,15 +95,15 @@ public void test1() throws NoSuchAlgorithmException {
|
|||
.fromString("a9993e364706816aba3e25717850c26c9cd0d89d");
|
||||
|
||||
MessageDigest m = MessageDigest.getInstance("SHA-1");
|
||||
m.update(TEST1.getBytes(UTF_8));
|
||||
m.update(TEST1.getBytes(CHARSET));
|
||||
ObjectId m1 = ObjectId.fromRaw(m.digest());
|
||||
|
||||
SHA1 s = SHA1.newInstance();
|
||||
s.update(TEST1.getBytes(UTF_8));
|
||||
s.update(TEST1.getBytes(CHARSET));
|
||||
ObjectId s1 = ObjectId.fromRaw(s.digest());
|
||||
|
||||
s.reset();
|
||||
s.update(TEST1.getBytes(UTF_8));
|
||||
s.update(TEST1.getBytes(CHARSET));
|
||||
ObjectId s2 = s.toObjectId();
|
||||
|
||||
assertEquals(m1, s1);
|
||||
|
@ -117,15 +117,15 @@ public void test2() throws NoSuchAlgorithmException {
|
|||
.fromString("84983e441c3bd26ebaae4aa1f95129e5e54670f1");
|
||||
|
||||
MessageDigest m = MessageDigest.getInstance("SHA-1");
|
||||
m.update(TEST2.getBytes(UTF_8));
|
||||
m.update(TEST2.getBytes(CHARSET));
|
||||
ObjectId m1 = ObjectId.fromRaw(m.digest());
|
||||
|
||||
SHA1 s = SHA1.newInstance();
|
||||
s.update(TEST2.getBytes(UTF_8));
|
||||
s.update(TEST2.getBytes(CHARSET));
|
||||
ObjectId s1 = ObjectId.fromRaw(s.digest());
|
||||
|
||||
s.reset();
|
||||
s.update(TEST2.getBytes(UTF_8));
|
||||
s.update(TEST2.getBytes(CHARSET));
|
||||
ObjectId s2 = s.toObjectId();
|
||||
|
||||
assertEquals(m1, s1);
|
||||
|
|
|
@ -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 @@ protected void doRun() throws AbortedByHookException {
|
|||
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 @@ protected void doRun() throws AbortedByHookException {
|
|||
hookErrRedirect, getStdinArgs());
|
||||
if (result.isExecutedWithError()) {
|
||||
throw new AbortedByHookException(
|
||||
new String(errorByteArray.toByteArray(), UTF_8),
|
||||
new String(errorByteArray.toByteArray(), CHARSET),
|
||||
getHookName(), result.getExitCode());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 @@ void write(String content) throws IOException {
|
|||
if (content.length() > 0) {
|
||||
nonEmpty = true;
|
||||
}
|
||||
lock.write(content.getBytes(UTF_8));
|
||||
lock.write(content.getBytes(CHARSET));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 boolean contains(AnyObjectId objectId) {
|
|||
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;) {
|
||||
|
|
|
@ -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 @@ String name() {
|
|||
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 @@ long readUpdateIndexDelta() {
|
|||
}
|
||||
|
||||
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 @@ private ObjectId readValueId() {
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -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 @@ void writeValue(ReftableOutputStream os) throws IOException {
|
|||
}
|
||||
|
||||
private static byte[] nameUtf8(Ref ref) {
|
||||
return ref.getName().getBytes(UTF_8);
|
||||
return ref.getName().getBytes(CHARSET);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -559,13 +559,13 @@ static class LogEntry extends Entry {
|
|||
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;
|
||||
|
|
|
@ -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 @@ void writeId(ObjectId id) {
|
|||
}
|
||||
|
||||
void writeVarintString(String s) {
|
||||
writeVarintString(s.getBytes(UTF_8));
|
||||
writeVarintString(s.getBytes(CHARSET));
|
||||
}
|
||||
|
||||
void writeVarintString(byte[] msg) {
|
||||
|
|
|
@ -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 RefCursor allRefs() throws IOException {
|
|||
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 LogCursor seekLog(String refName, long updateIndex)
|
|||
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;
|
||||
|
|
|
@ -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 BlobBasedConfig(Config base, final byte[] blob)
|
|||
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);
|
||||
}
|
||||
|
|
|
@ -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 @@ private void addIncludedConfig(final List<ConfigLine> newEntries,
|
|||
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -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 static byte[] encode(final String str) {
|
|||
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 */
|
||||
|
|
|
@ -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 @@ private static RebaseTodoLine parseLine(byte[] buf, int tokenBegin,
|
|||
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 @@ private static RebaseTodoLine parseLine(byte[] buf, int tokenBegin,
|
|||
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;
|
||||
|
|
|
@ -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)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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 @@ private Charset guessEncoding() {
|
|||
try {
|
||||
return getEncoding();
|
||||
} catch (IllegalCharsetNameException | UnsupportedCharsetException e) {
|
||||
return UTF_8;
|
||||
return CHARSET;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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 @@ void parseCanonical(final RevWalk walk, final byte[] rawTag)
|
|||
|
||||
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 @@ private Charset guessEncoding() {
|
|||
try {
|
||||
return RawParseUtils.parseEncoding(buffer);
|
||||
} catch (IllegalCharsetNameException | UnsupportedCharsetException e) {
|
||||
return UTF_8;
|
||||
return CHARSET;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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 void load() throws IOException, ConfigInvalidException {
|
|||
} 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 void save() throws IOException {
|
|||
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);
|
||||
|
|
|
@ -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 @@ void authorize(final HttpURLConnection c) throws IOException {
|
|||
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) {
|
||||
|
|
|
@ -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 synchronized String createNonce(Repository repo, long timestamp)
|
|||
}
|
||||
|
||||
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$
|
||||
}
|
||||
|
||||
|
|
|
@ -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 @@ void authorize(final String username, final String password) {
|
|||
@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 @@ private static String uri(URL u) {
|
|||
|
||||
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());
|
||||
}
|
||||
|
||||
|
|
|
@ -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 void endTask(String result) {
|
|||
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;
|
||||
|
|
|
@ -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 static PushCertificateIdent parse(String str) {
|
|||
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);
|
||||
}
|
||||
|
|
|
@ -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 @@ static PushCertificate read(TreeWalk tw) throws IOException {
|
|||
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 @@ private ObjectId saveCert(ObjectInserter inserter, DirCache dc,
|
|||
|
||||
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()))) {
|
||||
|
|
|
@ -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 @@
|
|||
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];
|
||||
|
|
|
@ -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 @@ private static void scan(ClassLoader ldr, URL url) {
|
|||
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.
|
||||
//
|
||||
|
|
|
@ -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 static String encodeBytes(byte[] source, int off, int len) {
|
|||
e += 4;
|
||||
}
|
||||
|
||||
return new String(outBuff, 0, e, StandardCharsets.UTF_8);
|
||||
return new String(outBuff, 0, e, CHARSET);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -294,7 +293,7 @@ public static byte[] decode(byte[] source, int off, int len) {
|
|||
* @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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 File resolve(final File dir, final String pn) {
|
|||
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;
|
||||
|
|
|
@ -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 static void encode(final StringBuilder urlstr, final String key) {
|
|||
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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue