Merge branch 'master' into stable-5.1
* master: UploadPackTest: Avoid unnecessarily boxing int into Integer Parse signature of GPG-signed commits Deprecate Constants.CHARSET in favor of StandardCharsets.UTF_8 Simplify file creation in ResetCommandTest Specify charset when constructing InputStreamReader Update Orbit to S20180829155938 for 2018-09 RC1 Replace useminimalnegotation flag with maxhaves flag Extract protocol v2 fetch request parsing to its own class FetchV2Request: Rename shallowSince to deepenSince FetchV2Request: Correct typo in parameter name FetchV2Request round up (doneReceived, renamings) Use right variable in error message about depth UploadPack: avoid conflating shallow commit lists in protocol v2 Bazel: Use hyphen instead of underscore in external repository names Format BUILD files with buildifier 0.15.0 Upgrade maven-compiler-plugin to 3.8.0 Change-Id: Ibc6feb828e4ff20a3158e6b75dcfce7617e00b0e Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
This commit is contained in:
commit
771ca345e5
|
@ -43,6 +43,7 @@
|
|||
|
||||
package org.eclipse.jgit.http.server;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.eclipse.jgit.http.server.ServletUtils.getRepository;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -73,7 +74,7 @@ public void doGet(final HttpServletRequest req,
|
|||
final Repository db = getRepository(req);
|
||||
try (OutputStreamWriter out = new OutputStreamWriter(
|
||||
new SmartOutputStream(req, rsp, true),
|
||||
Constants.CHARSET)) {
|
||||
UTF_8)) {
|
||||
final RefAdvertiser adv = new RefAdvertiser() {
|
||||
@Override
|
||||
protected void writeOne(CharSequence line)
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
|
||||
package org.eclipse.jgit.http.test;
|
||||
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
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;
|
||||
|
@ -1081,7 +1081,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(CHARSET));
|
||||
"testInvalidWant".getBytes(UTF_8));
|
||||
|
||||
Repository dst = createBareRepository();
|
||||
try (Transport t = Transport.open(dst, remoteURI);
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
|
||||
package org.eclipse.jgit.junit;
|
||||
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
|
@ -246,7 +246,7 @@ public static void write(File f, String body)
|
|||
throws IOException {
|
||||
FileUtils.mkdirs(f.getParentFile(), true);
|
||||
try (Writer w = new OutputStreamWriter(new FileOutputStream(f),
|
||||
CHARSET)) {
|
||||
UTF_8)) {
|
||||
w.write(body);
|
||||
}
|
||||
}
|
||||
|
@ -263,7 +263,7 @@ public static void write(File f, String body)
|
|||
*/
|
||||
public static String read(File file) throws IOException {
|
||||
final byte[] body = IO.readFully(file);
|
||||
return new String(body, 0, body.length, CHARSET);
|
||||
return new String(body, 0, body.length, UTF_8);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
|
||||
package org.eclipse.jgit.junit;
|
||||
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
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(), CHARSET));
|
||||
Constants.OBJ_BLOB).getCachedBytes(), UTF_8));
|
||||
}
|
||||
if (0 != (includedOptions & ASSUME_UNCHANGED))
|
||||
sb.append(", assume-unchanged:"
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
|
||||
package org.eclipse.jgit.junit;
|
||||
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -192,7 +192,7 @@ protected void deleteTrashFile(String name) throws IOException {
|
|||
protected static void checkFile(File f, String checkData)
|
||||
throws IOException {
|
||||
try (Reader r = new InputStreamReader(new FileInputStream(f),
|
||||
CHARSET)) {
|
||||
UTF_8)) {
|
||||
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 org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
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(String content) throws Exception {
|
||||
return blob(content.getBytes(CHARSET));
|
||||
return blob(content.getBytes(UTF_8));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
*/
|
||||
package org.eclipse.jgit.lfs.server.fs;
|
||||
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
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(),
|
||||
CHARSET);
|
||||
UTF_8);
|
||||
} else {
|
||||
final byte[] b = new byte[buf.remaining()];
|
||||
buf.duplicate().get(b);
|
||||
error = new String(b, CHARSET);
|
||||
error = new String(b, UTF_8);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
error = statusLine.getReasonPhrase();
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
*/
|
||||
package org.eclipse.jgit.lfs.server;
|
||||
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
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(), CHARSET));
|
||||
new OutputStreamWriter(res.getOutputStream(), UTF_8));
|
||||
|
||||
Reader r = new BufferedReader(
|
||||
new InputStreamReader(req.getInputStream(), CHARSET));
|
||||
new InputStreamReader(req.getInputStream(), UTF_8));
|
||||
LfsRequest request = LfsGson.fromJson(r, LfsRequest.class);
|
||||
String path = req.getPathInfo();
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
*/
|
||||
package org.eclipse.jgit.lfs.server.s3;
|
||||
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
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(CHARSET));
|
||||
md.update(s.getBytes(UTF_8));
|
||||
return md.digest();
|
||||
}
|
||||
|
||||
private static byte[] sign(String stringData, byte[] key) {
|
||||
try {
|
||||
byte[] data = stringData.getBytes(CHARSET);
|
||||
byte[] data = stringData.getBytes(UTF_8);
|
||||
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, CHARSET.name());
|
||||
encoded = URLEncoder.encode(url, UTF_8.name());
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new RuntimeException(LfsServerText.get().unsupportedUtf8, e);
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
*/
|
||||
package org.eclipse.jgit.lfs.test;
|
||||
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
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(CHARSET));
|
||||
md.update(s.getBytes(UTF_8));
|
||||
return LongObjectId.fromRaw(md.digest());
|
||||
}
|
||||
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
|
||||
package org.eclipse.jgit.lfs.lib;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static java.nio.charset.StandardCharsets.US_ASCII;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
|
@ -62,7 +63,6 @@
|
|||
import org.eclipse.jgit.junit.JGitTestUtil;
|
||||
import org.eclipse.jgit.lfs.errors.InvalidLongObjectIdException;
|
||||
import org.eclipse.jgit.lfs.test.LongObjectIdTestUtils;
|
||||
import org.eclipse.jgit.lib.Constants;
|
||||
import org.eclipse.jgit.util.FileUtils;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
|
@ -393,7 +393,7 @@ public void testCopyToWriter() throws IOException {
|
|||
AnyLongObjectId id1 = LongObjectIdTestUtils.hash("test");
|
||||
ByteArrayOutputStream os = new ByteArrayOutputStream(64);
|
||||
try (OutputStreamWriter w = new OutputStreamWriter(os,
|
||||
Constants.CHARSET)) {
|
||||
UTF_8)) {
|
||||
id1.copyTo(w);
|
||||
}
|
||||
assertEquals(id1, LongObjectId.fromString(os.toByteArray(), 0));
|
||||
|
@ -404,7 +404,7 @@ public void testCopyToWriterWithBuf() throws IOException {
|
|||
AnyLongObjectId id1 = LongObjectIdTestUtils.hash("test");
|
||||
ByteArrayOutputStream os = new ByteArrayOutputStream(64);
|
||||
try (OutputStreamWriter w = new OutputStreamWriter(os,
|
||||
Constants.CHARSET)) {
|
||||
UTF_8)) {
|
||||
char[] buf = new char[64];
|
||||
id1.copyTo(buf, w);
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
*/
|
||||
package org.eclipse.jgit.lfs;
|
||||
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
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,
|
||||
CHARSET.name())) {
|
||||
UTF_8.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(CHARSET.name());
|
||||
throw new UnsupportedCharsetException(UTF_8.name());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -165,7 +165,7 @@ public static LfsPointer parseLfsPointer(InputStream in)
|
|||
long sz = -1;
|
||||
|
||||
try (BufferedReader br = new BufferedReader(
|
||||
new InputStreamReader(in, CHARSET))) {
|
||||
new InputStreamReader(in, UTF_8))) {
|
||||
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 org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
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;
|
||||
|
@ -208,7 +208,7 @@ private Map<String, LfsPointer> requestBatchUpload(HttpConnection api,
|
|||
}
|
||||
Gson gson = Protocol.gson();
|
||||
api.getOutputStream().write(
|
||||
gson.toJson(toRequest(OPERATION_UPLOAD, res)).getBytes(CHARSET));
|
||||
gson.toJson(toRequest(OPERATION_UPLOAD, res)).getBytes(UTF_8));
|
||||
int responseCode = api.getResponseCode();
|
||||
if (responseCode != HTTP_OK) {
|
||||
throw new IOException(
|
||||
|
@ -221,7 +221,7 @@ private Map<String, LfsPointer> requestBatchUpload(HttpConnection api,
|
|||
private void uploadContents(HttpConnection api,
|
||||
Map<String, LfsPointer> oid2ptr) throws IOException {
|
||||
try (JsonReader reader = new JsonReader(
|
||||
new InputStreamReader(api.getInputStream()))) {
|
||||
new InputStreamReader(api.getInputStream(), UTF_8))) {
|
||||
for (Protocol.ObjectInfo o : parseObjects(reader)) {
|
||||
if (o.actions == null) {
|
||||
continue;
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
*/
|
||||
package org.eclipse.jgit.lfs;
|
||||
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
@ -170,7 +170,7 @@ public static Collection<Path> downloadLfsResource(Lfs lfs, Repository db,
|
|||
.write(gson
|
||||
.toJson(LfsConnectionFactory
|
||||
.toRequest(Protocol.OPERATION_DOWNLOAD, res))
|
||||
.getBytes(CHARSET));
|
||||
.getBytes(UTF_8));
|
||||
int responseCode = lfsServerConn.getResponseCode();
|
||||
if (responseCode != HttpConnection.HTTP_OK) {
|
||||
throw new IOException(
|
||||
|
@ -179,7 +179,8 @@ public static Collection<Path> downloadLfsResource(Lfs lfs, Repository db,
|
|||
Integer.valueOf(responseCode)));
|
||||
}
|
||||
try (JsonReader reader = new JsonReader(
|
||||
new InputStreamReader(lfsServerConn.getInputStream()))) {
|
||||
new InputStreamReader(lfsServerConn.getInputStream(),
|
||||
UTF_8))) {
|
||||
Protocol.Response resp = gson.fromJson(reader,
|
||||
Protocol.Response.class);
|
||||
for (Protocol.ObjectInfo o : resp.objects) {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<?pde?>
|
||||
<!-- generated with https://github.com/mbarbero/fr.obeo.releng.targetplatform -->
|
||||
<target name="jgit-4.5" sequenceNumber="1535482766">
|
||||
<target name="jgit-4.5" sequenceNumber="1535782734">
|
||||
<locations>
|
||||
<location includeMode="slicer" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="true" type="InstallableUnit">
|
||||
<unit id="org.eclipse.jetty.client" version="9.4.11.v20180605"/>
|
||||
|
@ -66,7 +66,7 @@
|
|||
<unit id="org.slf4j.impl.log4j12.source" version="1.7.2.v20131105-2200"/>
|
||||
<unit id="com.jcraft.jzlib" version="1.1.1.v201205102305"/>
|
||||
<unit id="com.jcraft.jzlib.source" version="1.1.1.v201205102305"/>
|
||||
<repository location="http://download.eclipse.org/tools/orbit/downloads/drops/S20180820175350/repository"/>
|
||||
<repository location="http://download.eclipse.org/tools/orbit/downloads/drops/S20180829155938/repository"/>
|
||||
</location>
|
||||
<location includeMode="slicer" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="true" type="InstallableUnit">
|
||||
<unit id="org.eclipse.osgi" version="0.0.0"/>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
target "jgit-4.5" with source configurePhase
|
||||
|
||||
include "projects/jetty-9.4.11.tpd"
|
||||
include "orbit/S20180820175350-2018-09.tpd"
|
||||
include "orbit/S20180829155938-2018-09.tpd"
|
||||
|
||||
location "http://download.eclipse.org/releases/mars/" {
|
||||
org.eclipse.osgi lazy
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<?pde?>
|
||||
<!-- generated with https://github.com/mbarbero/fr.obeo.releng.targetplatform -->
|
||||
<target name="jgit-4.6" sequenceNumber="1535482748">
|
||||
<target name="jgit-4.6" sequenceNumber="1535782721">
|
||||
<locations>
|
||||
<location includeMode="slicer" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="true" type="InstallableUnit">
|
||||
<unit id="org.eclipse.jetty.client" version="9.4.11.v20180605"/>
|
||||
|
@ -66,7 +66,7 @@
|
|||
<unit id="org.slf4j.impl.log4j12.source" version="1.7.2.v20131105-2200"/>
|
||||
<unit id="com.jcraft.jzlib" version="1.1.1.v201205102305"/>
|
||||
<unit id="com.jcraft.jzlib.source" version="1.1.1.v201205102305"/>
|
||||
<repository location="http://download.eclipse.org/tools/orbit/downloads/drops/S20180820175350/repository"/>
|
||||
<repository location="http://download.eclipse.org/tools/orbit/downloads/drops/S20180829155938/repository"/>
|
||||
</location>
|
||||
<location includeMode="slicer" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="true" type="InstallableUnit">
|
||||
<unit id="org.eclipse.osgi" version="0.0.0"/>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
target "jgit-4.6" with source configurePhase
|
||||
|
||||
include "projects/jetty-9.4.11.tpd"
|
||||
include "orbit/S20180820175350-2018-09.tpd"
|
||||
include "orbit/S20180829155938-2018-09.tpd"
|
||||
|
||||
location "http://download.eclipse.org/releases/neon/" {
|
||||
org.eclipse.osgi lazy
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<?pde?>
|
||||
<!-- generated with https://github.com/mbarbero/fr.obeo.releng.targetplatform -->
|
||||
<target name="jgit-4.7" sequenceNumber="1535482722">
|
||||
<target name="jgit-4.7" sequenceNumber="1535782702">
|
||||
<locations>
|
||||
<location includeMode="slicer" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="true" type="InstallableUnit">
|
||||
<unit id="org.eclipse.jetty.client" version="9.4.11.v20180605"/>
|
||||
|
@ -66,7 +66,7 @@
|
|||
<unit id="org.slf4j.impl.log4j12.source" version="1.7.2.v20131105-2200"/>
|
||||
<unit id="com.jcraft.jzlib" version="1.1.1.v201205102305"/>
|
||||
<unit id="com.jcraft.jzlib.source" version="1.1.1.v201205102305"/>
|
||||
<repository location="http://download.eclipse.org/tools/orbit/downloads/drops/S20180820175350/repository"/>
|
||||
<repository location="http://download.eclipse.org/tools/orbit/downloads/drops/S20180829155938/repository"/>
|
||||
</location>
|
||||
<location includeMode="slicer" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="true" type="InstallableUnit">
|
||||
<unit id="org.eclipse.osgi" version="0.0.0"/>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
target "jgit-4.7" with source configurePhase
|
||||
|
||||
include "projects/jetty-9.4.11.tpd"
|
||||
include "orbit/S20180820175350-2018-09.tpd"
|
||||
include "orbit/S20180829155938-2018-09.tpd"
|
||||
|
||||
location "http://download.eclipse.org/releases/oxygen/" {
|
||||
org.eclipse.osgi lazy
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<?pde?>
|
||||
<!-- generated with https://github.com/mbarbero/fr.obeo.releng.targetplatform -->
|
||||
<target name="jgit-4.8" sequenceNumber="1535482708">
|
||||
<target name="jgit-4.8" sequenceNumber="1535782689">
|
||||
<locations>
|
||||
<location includeMode="slicer" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="true" type="InstallableUnit">
|
||||
<unit id="org.eclipse.jetty.client" version="9.4.11.v20180605"/>
|
||||
|
@ -66,7 +66,7 @@
|
|||
<unit id="org.slf4j.impl.log4j12.source" version="1.7.2.v20131105-2200"/>
|
||||
<unit id="com.jcraft.jzlib" version="1.1.1.v201205102305"/>
|
||||
<unit id="com.jcraft.jzlib.source" version="1.1.1.v201205102305"/>
|
||||
<repository location="http://download.eclipse.org/tools/orbit/downloads/drops/S20180820175350/repository"/>
|
||||
<repository location="http://download.eclipse.org/tools/orbit/downloads/drops/S20180829155938/repository"/>
|
||||
</location>
|
||||
<location includeMode="slicer" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="true" type="InstallableUnit">
|
||||
<unit id="org.eclipse.osgi" version="0.0.0"/>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
target "jgit-4.8" with source configurePhase
|
||||
|
||||
include "projects/jetty-9.4.11.tpd"
|
||||
include "orbit/S20180820175350-2018-09.tpd"
|
||||
include "orbit/S20180829155938-2018-09.tpd"
|
||||
|
||||
location "http://download.eclipse.org/releases/photon/" {
|
||||
org.eclipse.osgi lazy
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<?pde?>
|
||||
<!-- generated with https://github.com/mbarbero/fr.obeo.releng.targetplatform -->
|
||||
<target name="jgit-4.9-staging" sequenceNumber="1535482688">
|
||||
<target name="jgit-4.9-staging" sequenceNumber="1535782680">
|
||||
<locations>
|
||||
<location includeMode="slicer" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="true" type="InstallableUnit">
|
||||
<unit id="org.eclipse.jetty.client" version="9.4.11.v20180605"/>
|
||||
|
@ -66,7 +66,7 @@
|
|||
<unit id="org.slf4j.impl.log4j12.source" version="1.7.2.v20131105-2200"/>
|
||||
<unit id="com.jcraft.jzlib" version="1.1.1.v201205102305"/>
|
||||
<unit id="com.jcraft.jzlib.source" version="1.1.1.v201205102305"/>
|
||||
<repository location="http://download.eclipse.org/tools/orbit/downloads/drops/S20180820175350/repository"/>
|
||||
<repository location="http://download.eclipse.org/tools/orbit/downloads/drops/S20180829155938/repository"/>
|
||||
</location>
|
||||
<location includeMode="slicer" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="true" type="InstallableUnit">
|
||||
<unit id="org.eclipse.osgi" version="0.0.0"/>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
target "jgit-4.9-staging" with source configurePhase
|
||||
|
||||
include "projects/jetty-9.4.11.tpd"
|
||||
include "orbit/S20180820175350-2018-09.tpd"
|
||||
include "orbit/S20180829155938-2018-09.tpd"
|
||||
|
||||
location "http://download.eclipse.org/staging/2018-09/" {
|
||||
org.eclipse.osgi lazy
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
target "S20180820175350-2018-09" with source configurePhase
|
||||
target "S20180829155938-2018-09" with source configurePhase
|
||||
// see http://download.eclipse.org/tools/orbit/downloads/
|
||||
|
||||
location "http://download.eclipse.org/tools/orbit/downloads/drops/S20180820175350/repository" {
|
||||
location "http://download.eclipse.org/tools/orbit/downloads/drops/S20180829155938/repository" {
|
||||
org.apache.ant [1.9.6.v201510161327,1.9.6.v201510161327]
|
||||
org.apache.ant.source [1.9.6.v201510161327,1.9.6.v201510161327]
|
||||
org.apache.commons.codec [1.10.0.v20180409-1845,1.10.0.v20180409-1845]
|
|
@ -42,7 +42,7 @@
|
|||
*/
|
||||
package org.eclipse.jgit.pgm;
|
||||
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
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(), CHARSET));
|
||||
new InputStreamReader(proc.getInputStream(), UTF_8));
|
||||
}
|
||||
|
||||
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, CHARSET));
|
||||
new InputStreamReader(in, UTF_8));
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null)
|
||||
l.add(line);
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
|
||||
package org.eclipse.jgit.pgm;
|
||||
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
|
@ -148,7 +148,7 @@ private Enumeration<URL> catalogs() {
|
|||
|
||||
private void scan(URL cUrl) {
|
||||
try (BufferedReader cIn = new BufferedReader(
|
||||
new InputStreamReader(cUrl.openStream(), CHARSET))) {
|
||||
new InputStreamReader(cUrl.openStream(), UTF_8))) {
|
||||
String line;
|
||||
while ((line = cIn.readLine()) != null) {
|
||||
if (line.length() > 0 && !line.startsWith("#")) //$NON-NLS-1$
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
|
||||
package org.eclipse.jgit.pgm;
|
||||
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
@ -227,7 +227,7 @@ protected void run(String[] argv) throws Exception {
|
|||
}
|
||||
|
||||
PrintWriter createErrorWriter() {
|
||||
return new PrintWriter(new OutputStreamWriter(System.err, CHARSET));
|
||||
return new PrintWriter(new OutputStreamWriter(System.err, UTF_8));
|
||||
}
|
||||
|
||||
private void execute(String[] argv) throws Exception {
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
|
||||
package org.eclipse.jgit.pgm.debug;
|
||||
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
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), CHARSET))) {
|
||||
new FileInputStream(lsRemotePath), UTF_8))) {
|
||||
Ref last = null;
|
||||
String line;
|
||||
while ((line = br.readLine()) != null) {
|
||||
|
|
|
@ -43,6 +43,8 @@
|
|||
|
||||
package org.eclipse.jgit.pgm.debug;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
|
@ -141,7 +143,7 @@ private void recreateCommitGraph() throws IOException {
|
|||
try (RevWalk rw = new RevWalk(db);
|
||||
final BufferedReader br = new BufferedReader(
|
||||
new InputStreamReader(new FileInputStream(graph),
|
||||
Constants.CHARSET))) {
|
||||
UTF_8))) {
|
||||
String line;
|
||||
while ((line = br.readLine()) != null) {
|
||||
final String[] parts = line.split("[ \t]{1,}"); //$NON-NLS-1$
|
||||
|
@ -280,7 +282,7 @@ private Map<String, Ref> computeNewRefs() throws IOException {
|
|||
try (RevWalk rw = new RevWalk(db);
|
||||
BufferedReader br = new BufferedReader(
|
||||
new InputStreamReader(new FileInputStream(refList),
|
||||
Constants.CHARSET))) {
|
||||
UTF_8))) {
|
||||
String line;
|
||||
while ((line = br.readLine()) != null) {
|
||||
final String[] parts = line.split("[ \t]{1,}"); //$NON-NLS-1$
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
|
||||
package org.eclipse.jgit.pgm.debug;
|
||||
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
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), CHARSET))) {
|
||||
new InputStreamReader(new FileInputStream(inputFile), UTF_8))) {
|
||||
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), CHARSET))) {
|
||||
new InputStreamReader(new FileInputStream(logPath), UTF_8))) {
|
||||
@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 org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
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(CHARSET), StandardOpenOption.CREATE,
|
||||
(pattern + "\n").getBytes(UTF_8), 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(CHARSET));
|
||||
out.write((path + "\n").getBytes(UTF_8));
|
||||
out.flush();
|
||||
}
|
||||
return proc;
|
||||
|
|
|
@ -44,6 +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.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
@ -56,7 +57,6 @@
|
|||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
||||
import org.eclipse.jgit.lib.Constants;
|
||||
import org.eclipse.jgit.util.MutableInteger;
|
||||
import org.eclipse.jgit.util.RawParseUtils;
|
||||
import org.eclipse.jgit.util.TemporaryBuffer;
|
||||
|
@ -176,7 +176,7 @@ void onCommit(String commitId, byte[] buf) {
|
|||
i.added = RawParseUtils.parseBase10(buf, ptr.value, ptr);
|
||||
i.deleted = RawParseUtils.parseBase10(buf, ptr.value + 1, ptr);
|
||||
final int eol = RawParseUtils.nextLF(buf, ptr.value);
|
||||
final String name = RawParseUtils.decode(Constants.CHARSET,
|
||||
final String name = RawParseUtils.decode(UTF_8,
|
||||
buf, ptr.value + 1, eol - 1);
|
||||
files.put(name, i);
|
||||
ptr.value = eol;
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
|
||||
package org.eclipse.jgit.api;
|
||||
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
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(CHARSET);
|
||||
byte[] expectedConversionBytes = expectedConversion.getBytes(CHARSET);
|
||||
byte[] outputBytes = output.getBytes(UTF_8);
|
||||
byte[] expectedConversionBytes = expectedConversion.getBytes(UTF_8);
|
||||
|
||||
// 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(CHARSET);
|
||||
byte[] expectedConversionBytes = expectedConversion.getBytes(CHARSET);
|
||||
byte[] inputBytes = input.getBytes(UTF_8);
|
||||
byte[] expectedConversionBytes = expectedConversion.getBytes(UTF_8);
|
||||
|
||||
// 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 org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
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(),
|
||||
CHARSET);
|
||||
UTF_8);
|
||||
assertEquals(content, "data");
|
||||
|
||||
git.notesRemove().setObjectId(commit2).call();
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
*/
|
||||
package org.eclipse.jgit.api;
|
||||
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
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(CHARSET));
|
||||
fos.write(string.getBytes(UTF_8));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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(), CHARSET);
|
||||
String content = new String(bos.toByteArray(), UTF_8);
|
||||
assertEquals(string, content);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
*/
|
||||
package org.eclipse.jgit.api;
|
||||
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
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(CHARSET));
|
||||
fos.write(string.getBytes(UTF_8));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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(), CHARSET);
|
||||
String content = new String(bos.toByteArray(), UTF_8);
|
||||
assertEquals(string, content);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
*/
|
||||
package org.eclipse.jgit.api;
|
||||
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
import static org.hamcrest.CoreMatchers.not;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
|
@ -1468,7 +1468,7 @@ public void testAuthorScriptConverter() throws Exception {
|
|||
assertEquals("GIT_AUTHOR_DATE='@123456789 -0100'", lines[2]);
|
||||
|
||||
PersonIdent parsedIdent = git.rebase().parseAuthor(
|
||||
convertedAuthor.getBytes(CHARSET));
|
||||
convertedAuthor.getBytes(UTF_8));
|
||||
assertEquals(ident.getName(), parsedIdent.getName());
|
||||
assertEquals(ident.getEmailAddress(), parsedIdent.getEmailAddress());
|
||||
// this is rounded to the last second
|
||||
|
@ -1485,7 +1485,7 @@ public void testAuthorScriptConverter() throws Exception {
|
|||
assertEquals("GIT_AUTHOR_DATE='@123456789 +0930'", lines[2]);
|
||||
|
||||
parsedIdent = git.rebase().parseAuthor(
|
||||
convertedAuthor.getBytes(CHARSET));
|
||||
convertedAuthor.getBytes(UTF_8));
|
||||
assertEquals(ident.getName(), parsedIdent.getName());
|
||||
assertEquals(ident.getEmailAddress(), parsedIdent.getEmailAddress());
|
||||
assertEquals(123456789000L, parsedIdent.getWhen().getTime());
|
||||
|
@ -2164,7 +2164,7 @@ private int countPicks() throws IOException {
|
|||
int count = 0;
|
||||
File todoFile = getTodoFile();
|
||||
try (BufferedReader br = new BufferedReader(new InputStreamReader(
|
||||
new FileInputStream(todoFile), CHARSET))) {
|
||||
new FileInputStream(todoFile), UTF_8))) {
|
||||
String line = br.readLine();
|
||||
while (line != null) {
|
||||
int firstBlank = line.indexOf(' ');
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2011-2013, Chris Aniszczyk <caniszczyk@gmail.com>
|
||||
* Copyright (C) 2011-2018, Chris Aniszczyk <caniszczyk@gmail.com>
|
||||
* and other copyright owners as documented in the project's IP log.
|
||||
*
|
||||
* This program and the accompanying materials are made available
|
||||
|
@ -52,7 +52,6 @@
|
|||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
import org.eclipse.jgit.api.ResetCommand.ResetType;
|
||||
import org.eclipse.jgit.api.errors.GitAPIException;
|
||||
|
@ -94,45 +93,25 @@ public void setupRepository() throws IOException, JGitInternalException,
|
|||
git = new Git(db);
|
||||
initialCommit = git.commit().setMessage("initial commit").call();
|
||||
|
||||
// create file
|
||||
indexFile = writeTrashFile("a.txt", "content");
|
||||
|
||||
// create nested file
|
||||
File dir = new File(db.getWorkTree(), "dir");
|
||||
FileUtils.mkdir(dir);
|
||||
File nestedFile = new File(dir, "b.txt");
|
||||
FileUtils.createNewFile(nestedFile);
|
||||
writeTrashFile("dir/b.txt", "content");
|
||||
|
||||
try (PrintWriter nestedFileWriter = new PrintWriter(nestedFile)) {
|
||||
nestedFileWriter.print("content");
|
||||
nestedFileWriter.flush();
|
||||
// add files and commit them
|
||||
git.add().addFilepattern("a.txt").addFilepattern("dir/b.txt").call();
|
||||
secondCommit = git.commit().setMessage("adding a.txt and dir/b.txt").call();
|
||||
|
||||
// create file
|
||||
indexFile = new File(db.getWorkTree(), "a.txt");
|
||||
FileUtils.createNewFile(indexFile);
|
||||
try (PrintWriter writer = new PrintWriter(indexFile)) {
|
||||
writer.print("content");
|
||||
writer.flush();
|
||||
prestage = DirCache.read(db.getIndexFile(), db.getFS()).getEntry(indexFile.getName());
|
||||
|
||||
// add file and commit it
|
||||
git.add().addFilepattern("dir").addFilepattern("a.txt").call();
|
||||
secondCommit = git.commit()
|
||||
.setMessage("adding a.txt and dir/b.txt").call();
|
||||
|
||||
prestage = DirCache.read(db.getIndexFile(), db.getFS())
|
||||
.getEntry(indexFile.getName());
|
||||
|
||||
// modify file and add to index
|
||||
writer.print("new content");
|
||||
}
|
||||
nestedFileWriter.print("new content");
|
||||
}
|
||||
git.add().addFilepattern("a.txt").addFilepattern("dir").call();
|
||||
// modify files and add to index
|
||||
writeTrashFile("a.txt", "new content");
|
||||
writeTrashFile("dir/b.txt", "new content");
|
||||
git.add().addFilepattern("a.txt").addFilepattern("dir/b.txt").call();
|
||||
|
||||
// create a file not added to the index
|
||||
untrackedFile = new File(db.getWorkTree(),
|
||||
"notAddedToIndex.txt");
|
||||
FileUtils.createNewFile(untrackedFile);
|
||||
try (PrintWriter writer2 = new PrintWriter(untrackedFile)) {
|
||||
writer2.print("content");
|
||||
}
|
||||
untrackedFile = writeTrashFile("notAddedToIndex.txt", "content");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
*/
|
||||
package org.eclipse.jgit.attributes;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
|
@ -57,7 +58,6 @@
|
|||
import java.util.Set;
|
||||
|
||||
import org.eclipse.jgit.junit.RepositoryTestCase;
|
||||
import org.eclipse.jgit.lib.Constants;
|
||||
import org.eclipse.jgit.lib.StoredConfig;
|
||||
import org.eclipse.jgit.treewalk.FileTreeIterator;
|
||||
import org.eclipse.jgit.treewalk.TreeWalk;
|
||||
|
@ -127,14 +127,14 @@ private LinkedHashMap<String, Attributes> cgitAttributes(
|
|||
builder.directory(db.getWorkTree());
|
||||
builder.environment().put("HOME", fs.userHome().getAbsolutePath());
|
||||
ExecutionResult result = fs.execute(builder, new ByteArrayInputStream(
|
||||
input.toString().getBytes(Constants.CHARSET)));
|
||||
input.toString().getBytes(UTF_8)));
|
||||
String errorOut = toString(result.getStderr());
|
||||
assertEquals("External git failed", "exit 0\n",
|
||||
"exit " + result.getRc() + '\n' + errorOut);
|
||||
LinkedHashMap<String, Attributes> map = new LinkedHashMap<>();
|
||||
try (BufferedReader r = new BufferedReader(new InputStreamReader(
|
||||
new BufferedInputStream(result.getStdout().openInputStream()),
|
||||
Constants.CHARSET))) {
|
||||
UTF_8))) {
|
||||
r.lines().forEach(line -> {
|
||||
// Parse the line and add to result map
|
||||
int start = 0;
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
|
||||
package org.eclipse.jgit.diff;
|
||||
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
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(CHARSET));
|
||||
return new RawText(r.toString().getBytes(UTF_8));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
|
||||
package org.eclipse.jgit.diff;
|
||||
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
|
@ -147,8 +147,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(CHARSET));
|
||||
RawText b = new RawText("p\na b \nR\n c d \n".getBytes(CHARSET));
|
||||
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));
|
||||
e = new Edit(0, 4, 0, 4);
|
||||
e = RawTextComparator.WS_IGNORE_ALL.reduceCommonStartEnd(a, b, e);
|
||||
assertEquals(new Edit(2, 3, 2, 3), e);
|
||||
|
@ -160,14 +160,14 @@ public void testComparatorReduceCommonStartEnd_EmptyLine() {
|
|||
RawText b;
|
||||
Edit e;
|
||||
|
||||
a = new RawText("R\n y\n".getBytes(CHARSET));
|
||||
b = new RawText("S\n\n y\n".getBytes(CHARSET));
|
||||
a = new RawText("R\n y\n".getBytes(UTF_8));
|
||||
b = new RawText("S\n\n y\n".getBytes(UTF_8));
|
||||
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(CHARSET));
|
||||
b = new RawText("R\n y\n".getBytes(CHARSET));
|
||||
a = new RawText("S\n\n y\n".getBytes(UTF_8));
|
||||
b = new RawText("R\n y\n".getBytes(UTF_8));
|
||||
e = new Edit(0, 3, 0, 2);
|
||||
e = RawTextComparator.DEFAULT.reduceCommonStartEnd(a, b, e);
|
||||
assertEquals(new Edit(0, 2, 0, 1), e);
|
||||
|
@ -178,8 +178,8 @@ public void testComparatorReduceCommonStartButLastLineNoEol() {
|
|||
RawText a;
|
||||
RawText b;
|
||||
Edit e;
|
||||
a = new RawText("start".getBytes(CHARSET));
|
||||
b = new RawText("start of line".getBytes(CHARSET));
|
||||
a = new RawText("start".getBytes(UTF_8));
|
||||
b = new RawText("start of line".getBytes(UTF_8));
|
||||
e = new Edit(0, 1, 0, 1);
|
||||
e = RawTextComparator.DEFAULT.reduceCommonStartEnd(a, b, e);
|
||||
assertEquals(new Edit(0, 1, 0, 1), e);
|
||||
|
@ -190,8 +190,8 @@ public void testComparatorReduceCommonStartButLastLineNoEol_2() {
|
|||
RawText a;
|
||||
RawText b;
|
||||
Edit e;
|
||||
a = new RawText("start".getBytes(CHARSET));
|
||||
b = new RawText("start of\nlastline".getBytes(CHARSET));
|
||||
a = new RawText("start".getBytes(UTF_8));
|
||||
b = new RawText("start of\nlastline".getBytes(UTF_8));
|
||||
e = new Edit(0, 1, 0, 2);
|
||||
e = RawTextComparator.DEFAULT.reduceCommonStartEnd(a, b, e);
|
||||
assertEquals(new Edit(0, 1, 0, 2), e);
|
||||
|
@ -250,6 +250,6 @@ private static RawText t(String text) {
|
|||
r.append(text.charAt(i));
|
||||
r.append('\n');
|
||||
}
|
||||
return new RawText(r.toString().getBytes(CHARSET));
|
||||
return new RawText(r.toString().getBytes(UTF_8));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
|
||||
package org.eclipse.jgit.diff;
|
||||
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
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(CHARSET);
|
||||
+ "B\n").getBytes(UTF_8);
|
||||
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(CHARSET);
|
||||
byte[] bytes1 = text.getBytes(UTF_8);
|
||||
src.hash(new ByteArrayInputStream(bytes1), bytes1.length, true);
|
||||
src.sort();
|
||||
|
||||
SimilarityIndex dst = new SimilarityIndex();
|
||||
byte[] bytes2 = text.replace("\r", "").getBytes(CHARSET);
|
||||
byte[] bytes2 = text.replace("\r", "").getBytes(UTF_8);
|
||||
dst.hash(new ByteArrayInputStream(bytes2), bytes2.length, true);
|
||||
dst.sort();
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
|
||||
package org.eclipse.jgit.dircache;
|
||||
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
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(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")), CHARSET))) {
|
||||
new FileInputStream(pathOf("gitgit.lsfiles")), UTF_8))) {
|
||||
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")), CHARSET))) {
|
||||
new FileInputStream(pathOf("gitgit.lstree")), UTF_8))) {
|
||||
String line;
|
||||
while ((line = br.readLine()) != null) {
|
||||
final CGitLsTreeRecord cr = new CGitLsTreeRecord(line);
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
*/
|
||||
package org.eclipse.jgit.gitrepo;
|
||||
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
@ -85,7 +85,7 @@ public void testManifestParser() throws Exception {
|
|||
|
||||
ManifestParser parser = new ManifestParser(
|
||||
null, null, "master", baseUrl, null, null);
|
||||
parser.read(new ByteArrayInputStream(xmlContent.toString().getBytes(CHARSET)));
|
||||
parser.read(new ByteArrayInputStream(xmlContent.toString().getBytes(UTF_8)));
|
||||
// Unfiltered projects should have them all.
|
||||
results.clear();
|
||||
results.add("foo");
|
||||
|
@ -139,7 +139,7 @@ public void testManifestParserWithMissingFetchOnRemote() throws Exception {
|
|||
baseUrl, null, null);
|
||||
try {
|
||||
parser.read(new ByteArrayInputStream(
|
||||
xmlContent.toString().getBytes(CHARSET)));
|
||||
xmlContent.toString().getBytes(UTF_8)));
|
||||
fail("ManifestParser did not throw exception for missing fetch");
|
||||
} catch (IOException e) {
|
||||
assertTrue(e.getCause() instanceof SAXException);
|
||||
|
@ -164,7 +164,7 @@ public void testRemoveProject() throws Exception {
|
|||
ManifestParser parser = new ManifestParser(null, null, "master",
|
||||
"https://git.google.com/", null, null);
|
||||
parser.read(new ByteArrayInputStream(
|
||||
xmlContent.toString().getBytes(CHARSET)));
|
||||
xmlContent.toString().getBytes(UTF_8)));
|
||||
|
||||
assertEquals(Stream.of("bar", "baz").collect(Collectors.toSet()),
|
||||
parser.getProjects().stream().map(RepoProject::getName)
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
*/
|
||||
package org.eclipse.jgit.gitrepo;
|
||||
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
@ -217,7 +217,7 @@ public void runTwiceIsNOP() throws Exception {
|
|||
|
||||
RevCommit commit = cmd
|
||||
.setInputStream(new ByteArrayInputStream(
|
||||
xmlContent.toString().getBytes(CHARSET)))
|
||||
xmlContent.toString().getBytes(UTF_8)))
|
||||
.setRemoteReader(repos).setURI("platform/")
|
||||
.setTargetURI("platform/superproject")
|
||||
.setRecordRemoteBranch(true).setRecordSubmoduleLabels(true)
|
||||
|
@ -226,7 +226,7 @@ public void runTwiceIsNOP() throws Exception {
|
|||
String firstIdStr = commit.getId().name() + ":" + ".gitmodules";
|
||||
commit = new RepoCommand(dest)
|
||||
.setInputStream(new ByteArrayInputStream(
|
||||
xmlContent.toString().getBytes(CHARSET)))
|
||||
xmlContent.toString().getBytes(UTF_8)))
|
||||
.setRemoteReader(repos).setURI("platform/")
|
||||
.setTargetURI("platform/superproject")
|
||||
.setRecordRemoteBranch(true).setRecordSubmoduleLabels(true)
|
||||
|
@ -254,7 +254,7 @@ public void androidSetup() throws Exception {
|
|||
|
||||
RevCommit commit = cmd
|
||||
.setInputStream(new ByteArrayInputStream(
|
||||
xmlContent.toString().getBytes(CHARSET)))
|
||||
xmlContent.toString().getBytes(UTF_8)))
|
||||
.setRemoteReader(repos).setURI("platform/")
|
||||
.setTargetURI("platform/superproject")
|
||||
.setRecordRemoteBranch(true).setRecordSubmoduleLabels(true)
|
||||
|
@ -288,7 +288,7 @@ public void recordUnreachableRemotes() throws Exception {
|
|||
try (Repository dest = cloneRepository(db, true)) {
|
||||
RevCommit commit = new RepoCommand(dest)
|
||||
.setInputStream(new ByteArrayInputStream(
|
||||
xmlContent.toString().getBytes(CHARSET)))
|
||||
xmlContent.toString().getBytes(UTF_8)))
|
||||
.setRemoteReader(new IndexedRepos()).setURI("platform/")
|
||||
.setTargetURI("platform/superproject")
|
||||
.setRecordRemoteBranch(true).setIgnoreRemoteFailures(true)
|
||||
|
@ -327,7 +327,7 @@ public void gerritSetup() throws Exception {
|
|||
|
||||
RevCommit commit = cmd
|
||||
.setInputStream(new ByteArrayInputStream(
|
||||
xmlContent.toString().getBytes(CHARSET)))
|
||||
xmlContent.toString().getBytes(UTF_8)))
|
||||
.setRemoteReader(repos).setURI("").setTargetURI("gerrit")
|
||||
.setRecordRemoteBranch(true).setRecordSubmoduleLabels(true)
|
||||
.call();
|
||||
|
@ -376,7 +376,7 @@ public void absoluteRemoteURL() throws Exception {
|
|||
|
||||
RevCommit commit = cmd
|
||||
.setInputStream(new ByteArrayInputStream(
|
||||
xmlContent.toString().getBytes(CHARSET)))
|
||||
xmlContent.toString().getBytes(UTF_8)))
|
||||
.setRemoteReader(repos).setURI(baseUrl)
|
||||
.setTargetURI("gerrit").setRecordRemoteBranch(true)
|
||||
.setRecordSubmoduleLabels(true).call();
|
||||
|
@ -431,7 +431,7 @@ public void absoluteRemoteURLAbsoluteTargetURL() throws Exception {
|
|||
|
||||
RevCommit commit = cmd
|
||||
.setInputStream(new ByteArrayInputStream(
|
||||
xmlContent.toString().getBytes(CHARSET)))
|
||||
xmlContent.toString().getBytes(UTF_8)))
|
||||
.setRemoteReader(repos).setURI(baseUrl)
|
||||
.setTargetURI(abs + "/superproject")
|
||||
.setRecordRemoteBranch(true)
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
*/
|
||||
package org.eclipse.jgit.ignore;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
|
@ -56,7 +57,6 @@
|
|||
import java.util.Set;
|
||||
|
||||
import org.eclipse.jgit.junit.RepositoryTestCase;
|
||||
import org.eclipse.jgit.lib.Constants;
|
||||
import org.eclipse.jgit.lib.StoredConfig;
|
||||
import org.eclipse.jgit.treewalk.FileTreeIterator;
|
||||
import org.eclipse.jgit.treewalk.TreeWalk;
|
||||
|
@ -113,7 +113,7 @@ private String[] cgitIgnored() throws Exception {
|
|||
"exit " + result.getRc() + '\n' + errorOut);
|
||||
try (BufferedReader r = new BufferedReader(new InputStreamReader(
|
||||
new BufferedInputStream(result.getStdout().openInputStream()),
|
||||
Constants.CHARSET))) {
|
||||
UTF_8))) {
|
||||
return r.lines().toArray(String[]::new);
|
||||
}
|
||||
}
|
||||
|
@ -131,7 +131,7 @@ private String[] cgitUntracked() throws Exception {
|
|||
"exit " + result.getRc() + '\n' + errorOut);
|
||||
try (BufferedReader r = new BufferedReader(new InputStreamReader(
|
||||
new BufferedInputStream(result.getStdout().openInputStream()),
|
||||
Constants.CHARSET))) {
|
||||
UTF_8))) {
|
||||
return r.lines().toArray(String[]::new);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
*/
|
||||
package org.eclipse.jgit.ignore;
|
||||
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.eclipse.jgit.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
|
@ -767,6 +767,6 @@ private InputStream writeToString(String... rules) {
|
|||
for (String line : rules) {
|
||||
data.append(line + "\n");
|
||||
}
|
||||
return new ByteArrayInputStream(data.toString().getBytes(CHARSET));
|
||||
return new ByteArrayInputStream(data.toString().getBytes(UTF_8));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
*/
|
||||
package org.eclipse.jgit.indexdiff;
|
||||
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
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, CHARSET)) {
|
||||
Writer writer = new OutputStreamWriter(out, UTF_8)) {
|
||||
writer.write("echo `which git` 1>&2\n");
|
||||
writer.write("echo `git --version` 1>&2\n");
|
||||
writer.write("git init " + name + " && \\\n");
|
||||
|
@ -170,7 +170,7 @@ private void copy(InputStream from, File to) throws IOException {
|
|||
|
||||
private String readStream(InputStream stream) throws IOException {
|
||||
try (BufferedReader in = new BufferedReader(
|
||||
new InputStreamReader(stream))) {
|
||||
new InputStreamReader(stream, UTF_8))) {
|
||||
StringBuilder out = new StringBuilder();
|
||||
String line;
|
||||
while ((line = in.readLine()) != null) {
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
package org.eclipse.jgit.internal.storage.file;
|
||||
|
||||
import static org.eclipse.jgit.junit.Assert.assertEquals;
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.eclipse.jgit.lib.Constants.LOCK_SUFFIX;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
|
@ -263,7 +263,7 @@ public void testDeleteHeadInBareRepo() throws IOException {
|
|||
|
||||
ObjectId blobId;
|
||||
try (ObjectInserter ins = bareRepo.newObjectInserter()) {
|
||||
blobId = ins.insert(Constants.OBJ_BLOB, "contents".getBytes(CHARSET));
|
||||
blobId = ins.insert(Constants.OBJ_BLOB, "contents".getBytes(UTF_8));
|
||||
ins.flush();
|
||||
}
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
package org.eclipse.jgit.internal.storage.file;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.ISO_8859_1;
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
@ -368,7 +368,7 @@ public void test006_ReadUglyConfig() throws IOException,
|
|||
+ " email = A U Thor <thor@example.com> # Just an example...\n"
|
||||
+ " name = \"A Thor \\\\ \\\"\\t \"\n"
|
||||
+ " defaultCheckInComment = a many line\\ncomment\\n to test\n";
|
||||
assertEquals(expectedStr, new String(IO.readFully(cfg), Constants.CHARSET));
|
||||
assertEquals(expectedStr, new String(IO.readFully(cfg), UTF_8));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -517,7 +517,7 @@ public void test023_createCommitNonAnullii() throws IOException {
|
|||
4294967295000L, 60));
|
||||
commit.setCommitter(new PersonIdent("Joe Hacker", "joe2@example.com",
|
||||
4294967295000L, 60));
|
||||
commit.setEncoding(CHARSET);
|
||||
commit.setEncoding(UTF_8);
|
||||
commit.setMessage("\u00dcbergeeks");
|
||||
ObjectId cid = insertCommit(commit);
|
||||
assertEquals("4680908112778718f37e686cbebcc912730b3154", cid.name());
|
||||
|
@ -559,7 +559,7 @@ public void test026_CreateCommitMultipleparents() throws IOException {
|
|||
final ObjectId treeId;
|
||||
try (ObjectInserter oi = db.newObjectInserter()) {
|
||||
final ObjectId blobId = oi.insert(Constants.OBJ_BLOB,
|
||||
"and this is the data in me\n".getBytes(Constants.CHARSET
|
||||
"and this is the data in me\n".getBytes(UTF_8
|
||||
.name()));
|
||||
TreeFormatter fmt = new TreeFormatter();
|
||||
fmt.append("i-am-a-file", FileMode.REGULAR_FILE, blobId);
|
||||
|
@ -666,9 +666,9 @@ public void test028_LockPackedRef() throws IOException {
|
|||
ObjectId id2;
|
||||
try (ObjectInserter ins = db.newObjectInserter()) {
|
||||
id1 = ins.insert(
|
||||
Constants.OBJ_BLOB, "contents1".getBytes(Constants.CHARSET));
|
||||
Constants.OBJ_BLOB, "contents1".getBytes(UTF_8));
|
||||
id2 = ins.insert(
|
||||
Constants.OBJ_BLOB, "contents2".getBytes(Constants.CHARSET));
|
||||
Constants.OBJ_BLOB, "contents2".getBytes(UTF_8));
|
||||
ins.flush();
|
||||
}
|
||||
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
|
||||
package org.eclipse.jgit.internal.storage.file;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
@ -77,7 +78,7 @@ public void setUp() throws Exception {
|
|||
try (BufferedReader br = new BufferedReader(new InputStreamReader(
|
||||
new FileInputStream(JGitTestUtil
|
||||
.getTestResourceFile("all_packed_objects.txt")),
|
||||
Constants.CHARSET))) {
|
||||
UTF_8))) {
|
||||
String line;
|
||||
while ((line = br.readLine()) != null) {
|
||||
final String[] parts = line.split(" {1,}");
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
|
||||
package org.eclipse.jgit.junit;
|
||||
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
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(), CHARSET);
|
||||
return new String(loader.getCachedBytes(), UTF_8);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
package org.eclipse.jgit.lib;
|
||||
|
||||
import static java.lang.Integer.valueOf;
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
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(CHARSET);
|
||||
byte[] data = b.toString().getBytes(UTF_8);
|
||||
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(CHARSET);
|
||||
byte[] data = b.toString().getBytes(UTF_8);
|
||||
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(CHARSET);
|
||||
byte[] data = b.toString().getBytes(UTF_8);
|
||||
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(CHARSET));
|
||||
checker.checkTree(b.toString().getBytes(UTF_8));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -42,6 +42,8 @@
|
|||
*/
|
||||
package org.eclipse.jgit.merge;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
@ -881,7 +883,7 @@ private String contentAsString(Repository r, ObjectId treeId, String path)
|
|||
StringBuilder result = new StringBuilder();
|
||||
ObjectReader or = r.newObjectReader();
|
||||
try (BufferedReader br = new BufferedReader(
|
||||
new InputStreamReader(or.open(blobId).openStream()))) {
|
||||
new InputStreamReader(or.open(blobId).openStream(), UTF_8))) {
|
||||
String line;
|
||||
boolean first = true;
|
||||
while ((line = br.readLine()) != null) {
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
*/
|
||||
package org.eclipse.jgit.merge;
|
||||
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.eclipse.jgit.lib.Constants.OBJ_BLOB;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
|
@ -793,7 +793,7 @@ public void checkContentMergeLargeBinaries(MergeStrategy strategy) throws Except
|
|||
}
|
||||
binary[50] = '\0';
|
||||
|
||||
writeTrashFile("file", new String(binary, CHARSET));
|
||||
writeTrashFile("file", new String(binary, UTF_8));
|
||||
git.add().addFilepattern("file").call();
|
||||
RevCommit first = git.commit().setMessage("added file").call();
|
||||
|
||||
|
@ -801,7 +801,7 @@ public void checkContentMergeLargeBinaries(MergeStrategy strategy) throws Except
|
|||
int idx = LINELEN * 1200 + 1;
|
||||
byte save = binary[idx];
|
||||
binary[idx] = '@';
|
||||
writeTrashFile("file", new String(binary, CHARSET));
|
||||
writeTrashFile("file", new String(binary, UTF_8));
|
||||
|
||||
binary[idx] = save;
|
||||
git.add().addFilepattern("file").call();
|
||||
|
@ -810,7 +810,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, CHARSET));
|
||||
writeTrashFile("file", new String(binary, UTF_8));
|
||||
git.add().addFilepattern("file").call();
|
||||
RevCommit sideCommit = git.commit().setAll(true)
|
||||
.setMessage("modified file l 1500").call();
|
||||
|
@ -972,7 +972,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", CHARSET.name());
|
||||
"BASE", "OURS", "THEIRS", UTF_8.name());
|
||||
String expected = "<<<<<<< OURS\n"
|
||||
+ "1master\n"
|
||||
+ "=======\n"
|
||||
|
@ -980,7 +980,7 @@ public void checkContentMergeConflict_noTree(MergeStrategy strategy)
|
|||
+ ">>>>>>> THEIRS\n"
|
||||
+ "2\n"
|
||||
+ "3";
|
||||
assertEquals(expected, new String(out.toByteArray(), CHARSET));
|
||||
assertEquals(expected, new String(out.toByteArray(), UTF_8));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1367,6 +1367,7 @@ private String readBlob(ObjectId treeish, String path) throws Exception {
|
|||
if (obj == null) {
|
||||
return null;
|
||||
}
|
||||
return new String(rw.getObjectReader().open(obj, OBJ_BLOB).getBytes(), CHARSET);
|
||||
return new String(rw.getObjectReader().open(obj, OBJ_BLOB).getBytes(),
|
||||
UTF_8);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
package org.eclipse.jgit.patch;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.ISO_8859_1;
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
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 = CHARSET;
|
||||
final Charset csNew = UTF_8;
|
||||
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 = CHARSET;
|
||||
final Charset csNew = UTF_8;
|
||||
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 org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
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(CHARSET));
|
||||
c.parseCanonical(rw, body.toString().getBytes(UTF_8));
|
||||
assertNotNull(c.getTree());
|
||||
assertEquals(treeId, c.getTree().getId());
|
||||
assertSame(rw.lookupTree(treeId), c.getTree());
|
||||
|
@ -148,7 +148,7 @@ private RevCommit create(String msg) throws Exception {
|
|||
|
||||
final RevCommit c;
|
||||
c = new RevCommit(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
|
||||
c.parseCanonical(new RevWalk(db), b.toString().getBytes(CHARSET));
|
||||
c.parseCanonical(new RevWalk(db), b.toString().getBytes(UTF_8));
|
||||
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(CHARSET));
|
||||
c.parseCanonical(new RevWalk(db), b.toString().getBytes(UTF_8));
|
||||
|
||||
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(CHARSET));
|
||||
c.parseCanonical(new RevWalk(db), b.toString().getBytes(UTF_8));
|
||||
|
||||
assertEquals(new PersonIdent("", "a_u_thor@example.com", 1218123387000l, 7), c.getAuthorIdent());
|
||||
assertEquals(new PersonIdent("", "", 1218123390000l, -5), c.getCommitterIdent());
|
||||
|
@ -185,18 +185,18 @@ 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(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));
|
||||
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));
|
||||
final RevCommit c;
|
||||
c = new RevCommit(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67")); // bogus id
|
||||
c.parseCanonical(new RevWalk(db), b.toByteArray());
|
||||
|
||||
assertSame(Constants.CHARSET, c.getEncoding());
|
||||
assertSame(UTF_8, c.getEncoding());
|
||||
assertEquals("F\u00f6r fattare", c.getAuthorIdent().getName());
|
||||
assertEquals("Sm\u00f6rg\u00e5sbord", c.getShortMessage());
|
||||
assertEquals("Sm\u00f6rg\u00e5sbord\n\n\u304d\u308c\u3044\n", c.getFullMessage());
|
||||
|
@ -205,18 +205,18 @@ 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(CHARSET));
|
||||
b.write("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes(UTF_8));
|
||||
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(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));
|
||||
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));
|
||||
final RevCommit c;
|
||||
c = new RevCommit(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67")); // bogus id
|
||||
c.parseCanonical(new RevWalk(db), b.toByteArray());
|
||||
|
||||
assertSame(Constants.CHARSET, c.getEncoding());
|
||||
assertSame(UTF_8, c.getEncoding());
|
||||
assertEquals("F\u00f6r fattare", c.getAuthorIdent().getName());
|
||||
assertEquals("Sm\u00f6rg\u00e5sbord", c.getShortMessage());
|
||||
assertEquals("Sm\u00f6rg\u00e5sbord\n\n\u304d\u308c\u3044\n", c.getFullMessage());
|
||||
|
@ -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(CHARSET));
|
||||
b.write("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes(UTF_8));
|
||||
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(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));
|
||||
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));
|
||||
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(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));
|
||||
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));
|
||||
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(CHARSET));
|
||||
b.write("author au <a@example.com> 1218123387 +0700\n".getBytes(CHARSET));
|
||||
.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(CHARSET));
|
||||
b.write("encoding 'utf8'\n".getBytes(CHARSET));
|
||||
b.write("\n".getBytes(CHARSET));
|
||||
b.write("Sm\u00f6rg\u00e5sbord\n".getBytes(CHARSET));
|
||||
.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));
|
||||
|
||||
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(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));
|
||||
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));
|
||||
|
||||
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(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));
|
||||
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));
|
||||
|
||||
RevCommit c = new RevCommit(
|
||||
id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
|
||||
|
@ -486,4 +486,36 @@ public void testParse_GitStyleMessageWithCRLF() throws Exception {
|
|||
private static ObjectId id(String str) {
|
||||
return ObjectId.fromString(str);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParse_gpgSig() throws Exception {
|
||||
String commit = "tree e3a1035abd2b319bb01e57d69b0ba6cab289297e\n" +
|
||||
"parent 54e895b87c0768d2317a2b17062e3ad9f76a8105\n" +
|
||||
"committer A U Thor <author@xample.com 1528968566 +0200\n" +
|
||||
"gpgsig -----BEGIN PGP SIGNATURE-----\n" +
|
||||
" \n" +
|
||||
" wsBcBAABCAAQBQJbGB4pCRBK7hj4Ov3rIwAAdHIIAENrvz23867ZgqrmyPemBEZP\n" +
|
||||
" U24B1Tlq/DWvce2buaxmbNQngKZ0pv2s8VMc11916WfTIC9EKvioatmpjduWvhqj\n" +
|
||||
" znQTFyiMor30pyYsfrqFuQZvqBW01o8GEWqLg8zjf9Rf0R3LlOEw86aT8CdHRlm6\n" +
|
||||
" wlb22xb8qoX4RB+LYfz7MhK5F+yLOPXZdJnAVbuyoMGRnDpwdzjL5Hj671+XJxN5\n" +
|
||||
" SasRdhxkkfw/ZnHxaKEc4juMz8Nziz27elRwhOQqlTYoXNJnsV//wy5Losd7aKi1\n" +
|
||||
" xXXyUpndEOmT0CIcKHrN/kbYoVL28OJaxoBuva3WYQaRrzEe3X02NMxZe9gkSqA=\n" +
|
||||
" =TClh\n" +
|
||||
" -----END PGP SIGNATURE-----\n" +
|
||||
"some other header\n\n" +
|
||||
"commit message";
|
||||
|
||||
final RevCommit c;
|
||||
c = new RevCommit(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
|
||||
c.parseCanonical(new RevWalk(db), commit.getBytes(UTF_8));
|
||||
String gpgSig = new String(c.getRawGpgSignature(), UTF_8);
|
||||
assertTrue(gpgSig.startsWith("-----BEGIN"));
|
||||
assertTrue(gpgSig.endsWith("END PGP SIGNATURE-----"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParse_NoGpgSig() throws Exception {
|
||||
final RevCommit c = create("a message");
|
||||
assertNull(c.getRawGpgSignature());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
package org.eclipse.jgit.revwalk;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.ISO_8859_1;
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
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(int typeCode) throws Exception {
|
|||
assertNull(c.getObject());
|
||||
assertNull(c.getTagName());
|
||||
|
||||
c.parseCanonical(rw, b.toString().getBytes(CHARSET));
|
||||
c.parseCanonical(rw, b.toString().getBytes(UTF_8));
|
||||
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(CHARSET));
|
||||
c.parseCanonical(rw, body.toString().getBytes(UTF_8));
|
||||
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(CHARSET));
|
||||
c.parseCanonical(rw, body.toString().getBytes(UTF_8));
|
||||
assertNotNull(c.getObject());
|
||||
assertEquals(treeId, c.getObject().getId());
|
||||
assertSame(rw.lookupTree(treeId), c.getObject());
|
||||
|
@ -213,7 +213,7 @@ private RevTag create(String msg) throws Exception {
|
|||
|
||||
final RevTag c;
|
||||
c = new RevTag(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
|
||||
c.parseCanonical(new RevWalk(db), b.toString().getBytes(CHARSET));
|
||||
c.parseCanonical(new RevWalk(db), b.toString().getBytes(UTF_8));
|
||||
return c;
|
||||
}
|
||||
|
||||
|
@ -221,17 +221,17 @@ private RevTag create(String msg) throws Exception {
|
|||
public void testParse_implicit_UTF8_encoded() throws Exception {
|
||||
final ByteArrayOutputStream b = new ByteArrayOutputStream();
|
||||
b.write("object 9788669ad918b6fcce64af8882fc9a81cb6aba67\n"
|
||||
.getBytes(CHARSET));
|
||||
b.write("type tree\n".getBytes(CHARSET));
|
||||
b.write("tag v1.2.3.4.5\n".getBytes(CHARSET));
|
||||
.getBytes(UTF_8));
|
||||
b.write("type tree\n".getBytes(UTF_8));
|
||||
b.write("tag v1.2.3.4.5\n".getBytes(UTF_8));
|
||||
|
||||
b
|
||||
.write("tagger F\u00f6r fattare <a_u_thor@example.com> 1218123387 +0700\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));
|
||||
.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));
|
||||
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(CHARSET));
|
||||
b.write("type tree\n".getBytes(CHARSET));
|
||||
b.write("tag v1.2.3.4.5\n".getBytes(CHARSET));
|
||||
.getBytes(UTF_8));
|
||||
b.write("type tree\n".getBytes(UTF_8));
|
||||
b.write("tag v1.2.3.4.5\n".getBytes(UTF_8));
|
||||
b.write("tagger F\u00f6r fattare <a_u_thor@example.com> 1218123387 +0700\n"
|
||||
.getBytes(ISO_8859_1));
|
||||
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));
|
||||
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));
|
||||
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(CHARSET));
|
||||
b.write("type tree\n".getBytes(CHARSET));
|
||||
b.write("tag v1.2.3.4.5\n".getBytes(CHARSET));
|
||||
.getBytes(UTF_8));
|
||||
b.write("type tree\n".getBytes(UTF_8));
|
||||
b.write("tag v1.2.3.4.5\n".getBytes(UTF_8));
|
||||
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(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));
|
||||
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));
|
||||
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(CHARSET));
|
||||
b.write("type tree\n".getBytes(CHARSET));
|
||||
b.write("tag v1.2.3.4.5\n".getBytes(CHARSET));
|
||||
.getBytes(UTF_8));
|
||||
b.write("type tree\n".getBytes(UTF_8));
|
||||
b.write("tag v1.2.3.4.5\n".getBytes(UTF_8));
|
||||
b
|
||||
.write("tagger F\u00f6r fattare <a_u_thor@example.com> 1218123387 +0700\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));
|
||||
.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));
|
||||
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(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));
|
||||
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));
|
||||
|
||||
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(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));
|
||||
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));
|
||||
|
||||
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 org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
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(CHARSET));
|
||||
final File file = createFile(CONTENT1.getBytes(UTF_8));
|
||||
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(CHARSET));
|
||||
bos1.write(CONTENT1.getBytes(UTF_8));
|
||||
|
||||
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(CHARSET));
|
||||
bos2.write(CONTENT2.getBytes(UTF_8));
|
||||
assertArrayEquals(bos2.toByteArray(), IO.readFully(file));
|
||||
}
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
|
||||
package org.eclipse.jgit.transport;
|
||||
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.eclipse.jgit.lib.Constants.OBJ_BLOB;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
@ -199,7 +199,8 @@ 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(), CHARSET));
|
||||
assertEquals(data,
|
||||
new String(repo.open(id, OBJ_BLOB).getBytes(), UTF_8));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
|
||||
package org.eclipse.jgit.transport;
|
||||
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
|
@ -76,7 +76,7 @@ public void setUp() throws Exception {
|
|||
|
||||
private void config(String data) throws IOException {
|
||||
try (OutputStreamWriter fw = new OutputStreamWriter(
|
||||
new FileOutputStream(configFile), CHARSET)) {
|
||||
new FileOutputStream(configFile), UTF_8)) {
|
||||
fw.write(data);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
|
||||
package org.eclipse.jgit.transport;
|
||||
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
|
@ -94,7 +94,7 @@ private void config(String data) throws IOException {
|
|||
long lastMtime = configFile.lastModified();
|
||||
do {
|
||||
try (final OutputStreamWriter fw = new OutputStreamWriter(
|
||||
new FileOutputStream(configFile), CHARSET)) {
|
||||
new FileOutputStream(configFile), UTF_8)) {
|
||||
fw.write(data);
|
||||
}
|
||||
} while (lastMtime == configFile.lastModified());
|
||||
|
|
|
@ -0,0 +1,336 @@
|
|||
/*
|
||||
* Copyright (C) 2018, Google LLC.
|
||||
* and other copyright owners as documented in the project's IP log.
|
||||
*
|
||||
* This program and the accompanying materials are made available
|
||||
* under the terms of the Eclipse Distribution License v1.0 which
|
||||
* accompanies this distribution, is reproduced below, and is
|
||||
* available at http://www.eclipse.org/org/documents/edl-v10.php
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the following
|
||||
* conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
*
|
||||
* - Neither the name of the Eclipse Foundation, Inc. nor the
|
||||
* names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package org.eclipse.jgit.transport;
|
||||
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.hasItems;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.eclipse.jgit.errors.PackProtocolException;
|
||||
import org.eclipse.jgit.internal.storage.dfs.DfsRepositoryDescription;
|
||||
import org.eclipse.jgit.internal.storage.dfs.InMemoryRepository;
|
||||
import org.eclipse.jgit.junit.TestRepository;
|
||||
import org.eclipse.jgit.lib.Config;
|
||||
import org.eclipse.jgit.lib.ObjectId;
|
||||
import org.eclipse.jgit.revwalk.RevCommit;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
|
||||
public class ProtocolV2ParserTest {
|
||||
|
||||
@Rule
|
||||
public ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
private TestRepository<InMemoryRepository> testRepo;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
testRepo = new TestRepository<>(newRepo("protocol-v2-parser-test"));
|
||||
}
|
||||
|
||||
private static InMemoryRepository newRepo(String name) {
|
||||
return new InMemoryRepository(new DfsRepositoryDescription(name));
|
||||
}
|
||||
|
||||
private static class ConfigBuilder {
|
||||
|
||||
private boolean allowRefInWant;
|
||||
|
||||
private boolean allowFilter;
|
||||
|
||||
private ConfigBuilder() {
|
||||
}
|
||||
|
||||
static ConfigBuilder start() {
|
||||
return new ConfigBuilder();
|
||||
}
|
||||
|
||||
static TransferConfig getDefault() {
|
||||
return start().done();
|
||||
}
|
||||
|
||||
ConfigBuilder allowRefInWant() {
|
||||
allowRefInWant = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
ConfigBuilder allowFilter() {
|
||||
allowFilter = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
TransferConfig done() {
|
||||
Config rc = new Config();
|
||||
rc.setBoolean("uploadpack", null, "allowrefinwant", allowRefInWant);
|
||||
rc.setBoolean("uploadpack", null, "allowfilter", allowFilter);
|
||||
return new TransferConfig(rc);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert the input lines to the PacketLine that the parser reads.
|
||||
*/
|
||||
private static PacketLineIn formatAsPacketLine(String... inputLines)
|
||||
throws IOException {
|
||||
ByteArrayOutputStream send = new ByteArrayOutputStream();
|
||||
PacketLineOut pckOut = new PacketLineOut(send);
|
||||
for (String line : inputLines) {
|
||||
if (line == PacketLineIn.END) {
|
||||
pckOut.end();
|
||||
} else if (line == PacketLineIn.DELIM) {
|
||||
pckOut.writeDelim();
|
||||
} else {
|
||||
pckOut.writeString(line);
|
||||
}
|
||||
}
|
||||
|
||||
return new PacketLineIn(new ByteArrayInputStream(send.toByteArray()));
|
||||
}
|
||||
|
||||
private static List<String> objIdsAsStrings(Collection<ObjectId> objIds) {
|
||||
// TODO(ifrade) Translate this to a matcher, so it would read as
|
||||
// assertThat(req.wantsIds(), hasObjectIds("...", "..."))
|
||||
return objIds.stream().map(ObjectId::name).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/*
|
||||
* Succesful fetch with the basic core commands of the protocol.
|
||||
*/
|
||||
@Test
|
||||
public void testFetchBasicArguments()
|
||||
throws PackProtocolException, IOException {
|
||||
PacketLineIn pckIn = formatAsPacketLine(
|
||||
PacketLineIn.DELIM,
|
||||
"thin-pack", "no-progress", "include-tag", "ofs-delta",
|
||||
"want 4624442d68ee402a94364191085b77137618633e",
|
||||
"want f900c8326a43303685c46b279b9f70411bff1a4b",
|
||||
"have 554f6e41067b9e3e565b6988a8294fac1cb78f4b",
|
||||
"have abc760ab9ad72f08209943251b36cb886a578f87", "done",
|
||||
PacketLineIn.END);
|
||||
ProtocolV2Parser parser = new ProtocolV2Parser(
|
||||
ConfigBuilder.getDefault());
|
||||
FetchV2Request request = parser.parseFetchRequest(pckIn,
|
||||
testRepo.getRepository().getRefDatabase());
|
||||
assertTrue(request.getOptions()
|
||||
.contains(GitProtocolConstants.OPTION_THIN_PACK));
|
||||
assertTrue(request.getOptions()
|
||||
.contains(GitProtocolConstants.OPTION_NO_PROGRESS));
|
||||
assertTrue(request.getOptions()
|
||||
.contains(GitProtocolConstants.OPTION_INCLUDE_TAG));
|
||||
assertTrue(request.getOptions()
|
||||
.contains(GitProtocolConstants.CAPABILITY_OFS_DELTA));
|
||||
assertThat(objIdsAsStrings(request.getWantsIds()),
|
||||
hasItems("4624442d68ee402a94364191085b77137618633e",
|
||||
"f900c8326a43303685c46b279b9f70411bff1a4b"));
|
||||
assertThat(objIdsAsStrings(request.getPeerHas()),
|
||||
hasItems("554f6e41067b9e3e565b6988a8294fac1cb78f4b",
|
||||
"abc760ab9ad72f08209943251b36cb886a578f87"));
|
||||
assertTrue(request.getWantedRefs().isEmpty());
|
||||
assertTrue(request.wasDoneReceived());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFetchWithShallow_deepen() throws IOException {
|
||||
PacketLineIn pckIn = formatAsPacketLine(
|
||||
PacketLineIn.DELIM,
|
||||
"deepen 15",
|
||||
"deepen-relative",
|
||||
"shallow 28274d02c489f4c7e68153056e9061a46f62d7a0",
|
||||
"shallow 145e683b229dcab9d0e2ccb01b386f9ecc17d29d",
|
||||
PacketLineIn.END);
|
||||
ProtocolV2Parser parser = new ProtocolV2Parser(
|
||||
ConfigBuilder.getDefault());
|
||||
FetchV2Request request = parser.parseFetchRequest(pckIn,
|
||||
testRepo.getRepository().getRefDatabase());
|
||||
assertThat(objIdsAsStrings(request.getClientShallowCommits()),
|
||||
hasItems("28274d02c489f4c7e68153056e9061a46f62d7a0",
|
||||
"145e683b229dcab9d0e2ccb01b386f9ecc17d29d"));
|
||||
assertTrue(request.getDeepenNotRefs().isEmpty());
|
||||
assertEquals(15, request.getDepth());
|
||||
assertTrue(request.getOptions()
|
||||
.contains(GitProtocolConstants.OPTION_DEEPEN_RELATIVE));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFetchWithShallow_deepenNot() throws IOException {
|
||||
PacketLineIn pckIn = formatAsPacketLine(PacketLineIn.DELIM,
|
||||
"shallow 28274d02c489f4c7e68153056e9061a46f62d7a0",
|
||||
"shallow 145e683b229dcab9d0e2ccb01b386f9ecc17d29d",
|
||||
"deepen-not a08595f76159b09d57553e37a5123f1091bb13e7",
|
||||
PacketLineIn.END);
|
||||
ProtocolV2Parser parser = new ProtocolV2Parser(
|
||||
ConfigBuilder.getDefault());
|
||||
FetchV2Request request = parser.parseFetchRequest(pckIn,
|
||||
testRepo.getRepository().getRefDatabase());
|
||||
assertThat(objIdsAsStrings(request.getClientShallowCommits()),
|
||||
hasItems("28274d02c489f4c7e68153056e9061a46f62d7a0",
|
||||
"145e683b229dcab9d0e2ccb01b386f9ecc17d29d"));
|
||||
assertThat(request.getDeepenNotRefs(),
|
||||
hasItems("a08595f76159b09d57553e37a5123f1091bb13e7"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFetchWithShallow_deepenSince() throws IOException {
|
||||
PacketLineIn pckIn = formatAsPacketLine(PacketLineIn.DELIM,
|
||||
"shallow 28274d02c489f4c7e68153056e9061a46f62d7a0",
|
||||
"shallow 145e683b229dcab9d0e2ccb01b386f9ecc17d29d",
|
||||
"deepen-since 123123123",
|
||||
PacketLineIn.END);
|
||||
ProtocolV2Parser parser = new ProtocolV2Parser(
|
||||
ConfigBuilder.getDefault());
|
||||
FetchV2Request request = parser.parseFetchRequest(pckIn,
|
||||
testRepo.getRepository().getRefDatabase());
|
||||
assertThat(objIdsAsStrings(request.getClientShallowCommits()),
|
||||
hasItems("28274d02c489f4c7e68153056e9061a46f62d7a0",
|
||||
"145e683b229dcab9d0e2ccb01b386f9ecc17d29d"));
|
||||
assertEquals(123123123, request.getDeepenSince());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFetchWithNoneFilter() throws IOException {
|
||||
PacketLineIn pckIn = formatAsPacketLine(PacketLineIn.DELIM,
|
||||
"filter blob:none",
|
||||
PacketLineIn.END);
|
||||
ProtocolV2Parser parser = new ProtocolV2Parser(
|
||||
ConfigBuilder.start().allowFilter().done());
|
||||
FetchV2Request request = parser.parseFetchRequest(pckIn,
|
||||
testRepo.getRepository().getRefDatabase());
|
||||
assertEquals(0, request.getFilterBlobLimit());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFetchWithBlobSizeFilter() throws IOException {
|
||||
PacketLineIn pckIn = formatAsPacketLine(PacketLineIn.DELIM,
|
||||
"filter blob:limit=15",
|
||||
PacketLineIn.END);
|
||||
ProtocolV2Parser parser = new ProtocolV2Parser(
|
||||
ConfigBuilder.start().allowFilter().done());
|
||||
FetchV2Request request = parser.parseFetchRequest(pckIn,
|
||||
testRepo.getRepository().getRefDatabase());
|
||||
assertEquals(15, request.getFilterBlobLimit());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFetchMustNotHaveMultipleFilters() throws IOException {
|
||||
thrown.expect(PackProtocolException.class);
|
||||
PacketLineIn pckIn = formatAsPacketLine(PacketLineIn.DELIM,
|
||||
"filter blob:none",
|
||||
"filter blob:limit=12",
|
||||
PacketLineIn.END);
|
||||
ProtocolV2Parser parser = new ProtocolV2Parser(
|
||||
ConfigBuilder.start().allowFilter().done());
|
||||
FetchV2Request request = parser.parseFetchRequest(pckIn,
|
||||
testRepo.getRepository().getRefDatabase());
|
||||
assertEquals(0, request.getFilterBlobLimit());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFetchFilterWithoutAllowFilter() throws IOException {
|
||||
thrown.expect(PackProtocolException.class);
|
||||
PacketLineIn pckIn = formatAsPacketLine(PacketLineIn.DELIM,
|
||||
"filter blob:limit=12", PacketLineIn.END);
|
||||
ProtocolV2Parser parser = new ProtocolV2Parser(
|
||||
ConfigBuilder.getDefault());
|
||||
parser.parseFetchRequest(pckIn,
|
||||
testRepo.getRepository().getRefDatabase());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFetchWithRefInWant() throws Exception {
|
||||
RevCommit one = testRepo.commit().message("1").create();
|
||||
RevCommit two = testRepo.commit().message("2").create();
|
||||
testRepo.update("branchA", one);
|
||||
testRepo.update("branchB", two);
|
||||
|
||||
PacketLineIn pckIn = formatAsPacketLine(PacketLineIn.DELIM,
|
||||
"want e4980cdc48cfa1301493ca94eb70523f6788b819",
|
||||
"want-ref refs/heads/branchA",
|
||||
PacketLineIn.END);
|
||||
ProtocolV2Parser parser = new ProtocolV2Parser(
|
||||
ConfigBuilder.start().allowRefInWant().done());
|
||||
|
||||
|
||||
FetchV2Request request = parser.parseFetchRequest(pckIn,
|
||||
testRepo.getRepository().getRefDatabase());
|
||||
assertEquals(1, request.getWantedRefs().size());
|
||||
assertThat(request.getWantedRefs().keySet(),
|
||||
hasItems("refs/heads/branchA"));
|
||||
assertEquals(2, request.getWantsIds().size());
|
||||
assertThat(objIdsAsStrings(request.getWantsIds()),
|
||||
hasItems("e4980cdc48cfa1301493ca94eb70523f6788b819",
|
||||
one.getName()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFetchWithRefInWantUnknownRef() throws Exception {
|
||||
thrown.expect(PackProtocolException.class);
|
||||
thrown.expectMessage(containsString("refs/heads/branchC"));
|
||||
|
||||
PacketLineIn pckIn = formatAsPacketLine(PacketLineIn.DELIM,
|
||||
"want e4980cdc48cfa1301493ca94eb70523f6788b819",
|
||||
"want-ref refs/heads/branchC",
|
||||
PacketLineIn.END);
|
||||
ProtocolV2Parser parser = new ProtocolV2Parser(
|
||||
ConfigBuilder.start().allowRefInWant().done());
|
||||
|
||||
RevCommit one = testRepo.commit().message("1").create();
|
||||
RevCommit two = testRepo.commit().message("2").create();
|
||||
testRepo.update("branchA", one);
|
||||
testRepo.update("branchB", two);
|
||||
|
||||
parser.parseFetchRequest(pckIn,
|
||||
testRepo.getRepository().getRefDatabase());
|
||||
}
|
||||
|
||||
}
|
|
@ -77,6 +77,7 @@ public class TestProtocolTest {
|
|||
"+refs/heads/master:refs/heads/master");
|
||||
|
||||
private static final int HAVES_PER_ROUND = 32;
|
||||
private static final int MAX_HAVES = 256;
|
||||
|
||||
private static class User {
|
||||
private final String name;
|
||||
|
@ -187,7 +188,7 @@ public void testFullNegotiation() throws Exception {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testMinimalNegotiation() throws Exception {
|
||||
public void testMaxHaves() throws Exception {
|
||||
TestProtocol<User> proto = registerDefault();
|
||||
URIish uri = proto.register(new User("user"), remote.getRepository());
|
||||
|
||||
|
@ -200,28 +201,13 @@ public void testMinimalNegotiation() throws Exception {
|
|||
RevCommit master = remote.branch("master").commit()
|
||||
.add("readme.txt", "unique commit").create();
|
||||
|
||||
TestProtocol.setFetchConfig(new FetchConfig(true, true));
|
||||
TestProtocol.setFetchConfig(new FetchConfig(true, MAX_HAVES));
|
||||
try (Git git = new Git(local.getRepository())) {
|
||||
assertNull(local.getRepository().exactRef("refs/heads/master"));
|
||||
git.fetch().setRemote(uri.toString()).setRefSpecs(MASTER).call();
|
||||
assertEquals(master, local.getRepository()
|
||||
.exactRef("refs/heads/master").getObjectId());
|
||||
assertTrue(havesCount <= 2 * HAVES_PER_ROUND);
|
||||
|
||||
// Update the remote master and add local branches for 5 more rounds
|
||||
// of negotiation, where the local branch commits have newer
|
||||
// timestamps. Negotiation should send 5 rounds for those newer
|
||||
// branches before getting to the round that sends its stale version
|
||||
// of master.
|
||||
master = remote.branch("master").commit().parent(master).create();
|
||||
local.tick(2 * HAVES_PER_ROUND);
|
||||
for (int i = 0; i < 5 * HAVES_PER_ROUND; i++) {
|
||||
local.branch("local-" + i).commit().create();
|
||||
}
|
||||
git.fetch().setRemote(uri.toString()).setRefSpecs(MASTER).call();
|
||||
assertEquals(master, local.getRepository()
|
||||
.exactRef("refs/heads/master").getObjectId());
|
||||
assertEquals(6 * HAVES_PER_ROUND, havesCount);
|
||||
assertTrue(havesCount <= MAX_HAVES);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.notNullValue;
|
||||
import static org.hamcrest.Matchers.theInstance;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
@ -577,12 +578,11 @@ public void testV2CapabilitiesRefInWantNotAdvertisedIfAdvertisingForbidden() thr
|
|||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("boxing")
|
||||
public void testV2EmptyRequest() throws Exception {
|
||||
ByteArrayInputStream recvStream = uploadPackV2(PacketLineIn.END);
|
||||
// Verify that there is nothing more after the capability
|
||||
// advertisement.
|
||||
assertThat(recvStream.available(), is(0));
|
||||
assertEquals(0, recvStream.available());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -735,7 +735,7 @@ private ReceivedPackStatistics parsePack(ByteArrayInputStream recvStream, Progre
|
|||
pp.parse(NullProgressMonitor.INSTANCE);
|
||||
|
||||
// Ensure that there is nothing left in the stream.
|
||||
assertThat(recvStream.read(), is(-1));
|
||||
assertEquals(-1, recvStream.read());
|
||||
|
||||
return pp.getReceivedPackStatistics();
|
||||
}
|
||||
|
@ -1417,6 +1417,44 @@ public void testV2FetchWantRefAndDeepen() throws Exception {
|
|||
assertFalse(client.hasObject(parent.toObjectId()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testV2FetchMissingShallow() throws Exception {
|
||||
RevCommit one = remote.commit().message("1").create();
|
||||
RevCommit two = remote.commit().message("2").parent(one).create();
|
||||
RevCommit three = remote.commit().message("3").parent(two).create();
|
||||
remote.update("three", three);
|
||||
|
||||
server.getConfig().setBoolean("uploadpack", null, "allowrefinwant",
|
||||
true);
|
||||
|
||||
ByteArrayInputStream recvStream = uploadPackV2("command=fetch\n",
|
||||
PacketLineIn.DELIM,
|
||||
"want-ref refs/heads/three\n",
|
||||
"deepen 3",
|
||||
"shallow 0123012301230123012301230123012301230123",
|
||||
"shallow " + two.getName() + '\n',
|
||||
"done\n",
|
||||
PacketLineIn.END);
|
||||
PacketLineIn pckIn = new PacketLineIn(recvStream);
|
||||
|
||||
assertThat(pckIn.readString(), is("shallow-info"));
|
||||
assertThat(pckIn.readString(),
|
||||
is("shallow " + one.toObjectId().getName()));
|
||||
assertThat(pckIn.readString(),
|
||||
is("unshallow " + two.toObjectId().getName()));
|
||||
assertThat(pckIn.readString(), theInstance(PacketLineIn.DELIM));
|
||||
assertThat(pckIn.readString(), is("wanted-refs"));
|
||||
assertThat(pckIn.readString(),
|
||||
is(three.toObjectId().getName() + " refs/heads/three"));
|
||||
assertThat(pckIn.readString(), theInstance(PacketLineIn.DELIM));
|
||||
assertThat(pckIn.readString(), is("packfile"));
|
||||
parsePack(recvStream);
|
||||
|
||||
assertTrue(client.hasObject(one.toObjectId()));
|
||||
assertTrue(client.hasObject(two.toObjectId()));
|
||||
assertTrue(client.hasObject(three.toObjectId()));
|
||||
}
|
||||
|
||||
private static class RejectAllRefFilter implements RefFilter {
|
||||
@Override
|
||||
public Map<String, Ref> filter(Map<String, Ref> refs) {
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
|
||||
package org.eclipse.jgit.transport;
|
||||
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
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()), CHARSET);
|
||||
return new String(Files.readAllBytes(file.toPath()), UTF_8);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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(CHARSET));
|
||||
Files.write(file.toPath(), text.getBytes(UTF_8));
|
||||
}
|
||||
|
||||
static void verifyFileContent(File fileOne, File fileTwo)
|
||||
|
@ -420,7 +420,7 @@ static String publicAddress() throws Exception {
|
|||
c.setConnectTimeout(500);
|
||||
c.setReadTimeout(500);
|
||||
try (BufferedReader reader = new BufferedReader(
|
||||
new InputStreamReader(c.getInputStream()))) {
|
||||
new InputStreamReader(c.getInputStream(), UTF_8))) {
|
||||
return reader.readLine();
|
||||
}
|
||||
} catch (UnknownHostException | SocketTimeoutException e) {
|
||||
|
@ -738,7 +738,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(CHARSET));
|
||||
s3.put(bucket, path, file.getBytes(UTF_8));
|
||||
s3.delete(bucket, path);
|
||||
}
|
||||
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
|
||||
package org.eclipse.jgit.treewalk;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.eclipse.jgit.lib.FileMode.REGULAR_FILE;
|
||||
import static org.eclipse.jgit.lib.FileMode.SYMLINK;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
@ -110,7 +111,7 @@ private static byte[] entry(final FileMode mode, final String name,
|
|||
}
|
||||
|
||||
private String path() {
|
||||
return RawParseUtils.decode(Constants.CHARSET, ctp.path,
|
||||
return RawParseUtils.decode(UTF_8, ctp.path,
|
||||
ctp.pathOffset, ctp.pathLen);
|
||||
}
|
||||
|
||||
|
@ -370,7 +371,7 @@ public void testFreakingHugePathName() throws Exception {
|
|||
final String name = b.toString();
|
||||
ctp.reset(entry(m644, name, hash_a));
|
||||
assertFalse(ctp.eof());
|
||||
assertEquals(name, RawParseUtils.decode(Constants.CHARSET, ctp.path,
|
||||
assertEquals(name, RawParseUtils.decode(UTF_8, ctp.path,
|
||||
ctp.pathOffset, ctp.pathLen));
|
||||
}
|
||||
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
|
||||
package org.eclipse.jgit.treewalk;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
@ -822,6 +823,6 @@ private static void assertEntry(String sha1string, String path, TreeWalk tw)
|
|||
}
|
||||
|
||||
private static String nameOf(AbstractTreeIterator i) {
|
||||
return RawParseUtils.decode(Constants.CHARSET, i.path, 0, i.pathLen);
|
||||
return RawParseUtils.decode(UTF_8, i.path, 0, i.pathLen);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,7 +52,24 @@
|
|||
import org.eclipse.jgit.lib.Constants;
|
||||
import org.junit.Test;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
public class RawParseUtilsTest {
|
||||
String commit = "tree e3a1035abd2b319bb01e57d69b0ba6cab289297e\n" +
|
||||
"parent 54e895b87c0768d2317a2b17062e3ad9f76a8105\n" +
|
||||
"committer A U Thor <author@xample.com 1528968566 +0200\n" +
|
||||
"gpgsig -----BEGIN PGP SIGNATURE-----\n" +
|
||||
" \n" +
|
||||
" wsBcBAABCAAQBQJbGB4pCRBK7hj4Ov3rIwAAdHIIAENrvz23867ZgqrmyPemBEZP\n" +
|
||||
" U24B1Tlq/DWvce2buaxmbNQngKZ0pv2s8VMc11916WfTIC9EKvioatmpjduWvhqj\n" +
|
||||
" znQTFyiMor30pyYsfrqFuQZvqBW01o8GEWqLg8zjf9Rf0R3LlOEw86aT8CdHRlm6\n" +
|
||||
" wlb22xb8qoX4RB+LYfz7MhK5F+yLOPXZdJnAVbuyoMGRnDpwdzjL5Hj671+XJxN5\n" +
|
||||
" SasRdhxkkfw/ZnHxaKEc4juMz8Nziz27elRwhOQqlTYoXNJnsV//wy5Losd7aKi1\n" +
|
||||
" xXXyUpndEOmT0CIcKHrN/kbYoVL28OJaxoBuva3WYQaRrzEe3X02NMxZe9gkSqA=\n" +
|
||||
" =TClh\n" +
|
||||
" -----END PGP SIGNATURE-----\n" +
|
||||
"some other header\n\n" +
|
||||
"commit message";
|
||||
|
||||
@Test
|
||||
public void testParseEncoding_ISO8859_1_encoding() {
|
||||
|
@ -79,4 +96,30 @@ public void testParseEncoding_badEncoding() {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHeaderStart() {
|
||||
byte[] headerName = "some".getBytes(UTF_8);
|
||||
byte[] commitBytes = commit.getBytes(UTF_8);
|
||||
assertEquals(625, RawParseUtils.headerStart(headerName, commitBytes, 0));
|
||||
assertEquals(625, RawParseUtils.headerStart(headerName, commitBytes, 4));
|
||||
|
||||
byte[] missingHeaderName = "missing".getBytes(UTF_8);
|
||||
assertEquals(-1, RawParseUtils.headerStart(missingHeaderName,
|
||||
commitBytes, 0));
|
||||
|
||||
byte[] fauxHeaderName = "other".getBytes(UTF_8);
|
||||
assertEquals(-1, RawParseUtils.headerStart(fauxHeaderName, commitBytes, 625 + 4));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHeaderEnd() {
|
||||
byte[] commitBytes = commit.getBytes(UTF_8);
|
||||
int[] expected = new int[] {45, 93, 148, 619, 637};
|
||||
int start = 0;
|
||||
for (int i = 0; i < expected.length; i++) {
|
||||
start = RawParseUtils.headerEnd(commitBytes, start);
|
||||
assertEquals(expected[i], start);
|
||||
start += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
*/
|
||||
package org.eclipse.jgit.util;
|
||||
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
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(CHARSET);
|
||||
byte[] bytes = text.getBytes(UTF_8);
|
||||
return new RawCharSequence(bytes, 0, bytes.length);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
|
||||
package org.eclipse.jgit.util.io;
|
||||
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
|
@ -132,6 +132,6 @@ private static void test(byte[] input, byte[] expected,
|
|||
}
|
||||
|
||||
private static byte[] asBytes(String in) {
|
||||
return in.getBytes(CHARSET);
|
||||
return in.getBytes(UTF_8);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
|
||||
package org.eclipse.jgit.util.sha1;
|
||||
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
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(CHARSET));
|
||||
m.update(TEST1.getBytes(UTF_8));
|
||||
ObjectId m1 = ObjectId.fromRaw(m.digest());
|
||||
|
||||
SHA1 s = SHA1.newInstance();
|
||||
s.update(TEST1.getBytes(CHARSET));
|
||||
s.update(TEST1.getBytes(UTF_8));
|
||||
ObjectId s1 = ObjectId.fromRaw(s.digest());
|
||||
|
||||
s.reset();
|
||||
s.update(TEST1.getBytes(CHARSET));
|
||||
s.update(TEST1.getBytes(UTF_8));
|
||||
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(CHARSET));
|
||||
m.update(TEST2.getBytes(UTF_8));
|
||||
ObjectId m1 = ObjectId.fromRaw(m.digest());
|
||||
|
||||
SHA1 s = SHA1.newInstance();
|
||||
s.update(TEST2.getBytes(CHARSET));
|
||||
s.update(TEST2.getBytes(UTF_8));
|
||||
ObjectId s1 = ObjectId.fromRaw(s.digest());
|
||||
|
||||
s.reset();
|
||||
s.update(TEST2.getBytes(CHARSET));
|
||||
s.update(TEST2.getBytes(UTF_8));
|
||||
ObjectId s2 = s.toObjectId();
|
||||
|
||||
assertEquals(m1, s1);
|
||||
|
|
|
@ -42,6 +42,8 @@
|
|||
*/
|
||||
package org.eclipse.jgit.attributes;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
@ -50,8 +52,6 @@
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.jgit.lib.Constants;
|
||||
|
||||
/**
|
||||
* Represents a bundle of attributes inherited from a base directory.
|
||||
*
|
||||
|
@ -115,7 +115,7 @@ else if (patternEndTab == -1)
|
|||
}
|
||||
|
||||
private static BufferedReader asReader(InputStream in) {
|
||||
return new BufferedReader(new InputStreamReader(in, Constants.CHARSET));
|
||||
return new BufferedReader(new InputStreamReader(in, UTF_8));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -46,6 +46,8 @@
|
|||
|
||||
package org.eclipse.jgit.dircache;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.EOFException;
|
||||
import java.io.IOException;
|
||||
|
@ -772,7 +774,7 @@ private static void checkPath(byte[] path) {
|
|||
}
|
||||
|
||||
static String toString(byte[] path) {
|
||||
return Constants.CHARSET.decode(ByteBuffer.wrap(path)).toString();
|
||||
return UTF_8.decode(ByteBuffer.wrap(path)).toString();
|
||||
}
|
||||
|
||||
static int getMaximumInfoLength(boolean extended) {
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
|
||||
package org.eclipse.jgit.dircache;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.eclipse.jgit.lib.FileMode.TREE;
|
||||
import static org.eclipse.jgit.lib.TreeFormatter.entrySize;
|
||||
|
||||
|
@ -276,7 +277,7 @@ public ObjectId getObjectId() {
|
|||
*/
|
||||
public String getNameString() {
|
||||
final ByteBuffer bb = ByteBuffer.wrap(encodedName);
|
||||
return Constants.CHARSET.decode(bb).toString();
|
||||
return UTF_8.decode(bb).toString();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
*/
|
||||
package org.eclipse.jgit.hooks;
|
||||
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
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,
|
||||
CHARSET.name());
|
||||
UTF_8.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(), CHARSET),
|
||||
new String(errorByteArray.toByteArray(), UTF_8),
|
||||
getHookName(), result.getExitCode());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,6 +42,8 @@
|
|||
*/
|
||||
package org.eclipse.jgit.ignore;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
@ -50,8 +52,6 @@
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.jgit.lib.Constants;
|
||||
|
||||
/**
|
||||
* Represents a bundle of ignore rules inherited from a base directory.
|
||||
*
|
||||
|
@ -121,7 +121,7 @@ public void parse(InputStream in) throws IOException {
|
|||
}
|
||||
|
||||
private static BufferedReader asReader(InputStream in) {
|
||||
return new BufferedReader(new InputStreamReader(in, Constants.CHARSET));
|
||||
return new BufferedReader(new InputStreamReader(in, UTF_8));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
|
||||
package org.eclipse.jgit.internal.storage.dfs;
|
||||
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
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(CHARSET), ext);
|
||||
return new ByteArrayDfsStreamKey(repo, name.getBytes(UTF_8), ext);
|
||||
}
|
||||
|
||||
final int hash;
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
|
||||
package org.eclipse.jgit.internal.storage.file;
|
||||
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
@ -171,6 +171,6 @@ void write(String content) throws IOException {
|
|||
if (content.length() > 0) {
|
||||
nonEmpty = true;
|
||||
}
|
||||
lock.write(content.getBytes(CHARSET));
|
||||
lock.write(content.getBytes(UTF_8));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
|
||||
package org.eclipse.jgit.internal.storage.file;
|
||||
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
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, CHARSET);
|
||||
Reader rin = new InputStreamReader(fin, UTF_8);
|
||||
BufferedReader br = new BufferedReader(rin)) {
|
||||
MutableObjectId id = new MutableObjectId();
|
||||
for (String line; (line = br.readLine()) != null;) {
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
|
||||
package org.eclipse.jgit.internal.storage.file;
|
||||
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.eclipse.jgit.lib.Constants.HEAD;
|
||||
import static org.eclipse.jgit.lib.Constants.LOGS;
|
||||
import static org.eclipse.jgit.lib.Constants.OBJECT_ID_STRING_LENGTH;
|
||||
|
@ -945,7 +945,7 @@ private PackedRefList readPackedRefs() throws IOException {
|
|||
try (BufferedReader br = new BufferedReader(new InputStreamReader(
|
||||
new DigestInputStream(new FileInputStream(packedRefsFile),
|
||||
digest),
|
||||
CHARSET))) {
|
||||
UTF_8))) {
|
||||
try {
|
||||
return new PackedRefList(parsePackedRefs(br), snapshot,
|
||||
ObjectId.fromRaw(digest.digest()));
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
|
||||
package org.eclipse.jgit.internal.storage.reftable;
|
||||
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
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(CHARSET, nameBuf, 0, len);
|
||||
return RawParseUtils.decode(UTF_8, nameBuf, 0, len);
|
||||
}
|
||||
|
||||
boolean match(byte[] match, boolean matchIsPrefix) {
|
||||
|
@ -171,7 +171,7 @@ long readUpdateIndexDelta() {
|
|||
}
|
||||
|
||||
Ref readRef() throws IOException {
|
||||
String name = RawParseUtils.decode(CHARSET, nameBuf, 0, nameLen);
|
||||
String name = RawParseUtils.decode(UTF_8, 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(CHARSET, buf, ptr, end);
|
||||
String s = RawParseUtils.decode(UTF_8, buf, ptr, end);
|
||||
ptr = end;
|
||||
return s;
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
|
||||
package org.eclipse.jgit.internal.storage.reftable;
|
||||
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
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(CHARSET);
|
||||
return ref.getName().getBytes(UTF_8);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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(CHARSET);
|
||||
this.email = who.getEmailAddress().getBytes(CHARSET);
|
||||
this.msg = message.getBytes(CHARSET);
|
||||
this.name = who.getName().getBytes(UTF_8);
|
||||
this.email = who.getEmailAddress().getBytes(UTF_8);
|
||||
this.msg = message.getBytes(UTF_8);
|
||||
}
|
||||
|
||||
static byte[] key(String ref, long index) {
|
||||
byte[] name = ref.getBytes(CHARSET);
|
||||
byte[] name = ref.getBytes(UTF_8);
|
||||
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 org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
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(CHARSET));
|
||||
writeVarintString(s.getBytes(UTF_8));
|
||||
}
|
||||
|
||||
void writeVarintString(byte[] msg) {
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
|
||||
package org.eclipse.jgit.internal.storage.reftable;
|
||||
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
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(CHARSET);
|
||||
byte[] key = refName.getBytes(UTF_8);
|
||||
RefCursorImpl i = new RefCursorImpl(refEnd, key, false);
|
||||
i.block = seek(REF_BLOCK_TYPE, key, refIndex, 0, refEnd);
|
||||
return i;
|
||||
|
@ -193,7 +193,7 @@ public RefCursor seekRef(String refName) throws IOException {
|
|||
public RefCursor seekRefsWithPrefix(String prefix) throws IOException {
|
||||
initRefIndex();
|
||||
|
||||
byte[] key = prefix.getBytes(CHARSET);
|
||||
byte[] key = prefix.getBytes(UTF_8);
|
||||
RefCursorImpl i = new RefCursorImpl(refEnd, key, true);
|
||||
i.block = seek(REF_BLOCK_TYPE, key, refIndex, 0, refEnd);
|
||||
return i;
|
||||
|
@ -232,7 +232,7 @@ public LogCursor seekLog(String refName, long updateIndex)
|
|||
initLogIndex();
|
||||
if (logPosition > 0) {
|
||||
byte[] key = LogEntry.key(refName, updateIndex);
|
||||
byte[] match = refName.getBytes(CHARSET);
|
||||
byte[] match = refName.getBytes(UTF_8);
|
||||
LogCursorImpl i = new LogCursorImpl(logEnd, match);
|
||||
i.block = seek(LOG_BLOCK_TYPE, key, logIndex, logPosition, logEnd);
|
||||
return i;
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
|
||||
package org.eclipse.jgit.lib;
|
||||
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
|
@ -83,7 +83,7 @@ public BlobBasedConfig(Config base, byte[] blob)
|
|||
super(base);
|
||||
final String decoded;
|
||||
if (isUtf8(blob)) {
|
||||
decoded = RawParseUtils.decode(CHARSET, blob, 3, blob.length);
|
||||
decoded = RawParseUtils.decode(UTF_8, blob, 3, blob.length);
|
||||
} else {
|
||||
decoded = RawParseUtils.decode(blob);
|
||||
}
|
||||
|
|
|
@ -45,6 +45,8 @@
|
|||
|
||||
package org.eclipse.jgit.lib;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStreamWriter;
|
||||
|
@ -93,7 +95,7 @@ public class CommitBuilder {
|
|||
*/
|
||||
public CommitBuilder() {
|
||||
parentIds = EMPTY_OBJECTID_LIST;
|
||||
encoding = Constants.CHARSET;
|
||||
encoding = UTF_8;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -314,7 +316,7 @@ public byte[] build() throws UnsupportedEncodingException {
|
|||
w.flush();
|
||||
os.write('\n');
|
||||
|
||||
if (getEncoding() != Constants.CHARSET) {
|
||||
if (getEncoding() != UTF_8) {
|
||||
os.write(hencoding);
|
||||
os.write(' ');
|
||||
os.write(Constants.encodeASCII(getEncoding().name()));
|
||||
|
@ -375,7 +377,7 @@ public String toString() {
|
|||
r.append(committer != null ? committer.toString() : "NOT_SET");
|
||||
r.append("\n");
|
||||
|
||||
if (encoding != null && encoding != Constants.CHARSET) {
|
||||
if (encoding != null && encoding != UTF_8) {
|
||||
r.append("encoding ");
|
||||
r.append(encoding.name());
|
||||
r.append("\n");
|
||||
|
|
|
@ -51,7 +51,7 @@
|
|||
|
||||
package org.eclipse.jgit.lib;
|
||||
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
|
@ -1168,7 +1168,7 @@ private void addIncludedConfig(final List<ConfigLine> newEntries,
|
|||
|
||||
String decoded;
|
||||
if (isUtf8(bytes)) {
|
||||
decoded = RawParseUtils.decode(CHARSET, bytes, 3, bytes.length);
|
||||
decoded = RawParseUtils.decode(UTF_8, bytes, 3, bytes.length);
|
||||
} else {
|
||||
decoded = RawParseUtils.decode(bytes);
|
||||
}
|
||||
|
|
|
@ -227,7 +227,13 @@ public final class Constants {
|
|||
*/
|
||||
public static final byte[] PACK_SIGNATURE = { 'P', 'A', 'C', 'K' };
|
||||
|
||||
/** Native character encoding for commit messages, file names... */
|
||||
/**
|
||||
* Native character encoding for commit messages, file names...
|
||||
*
|
||||
* @deprecated Use {@link java.nio.charset.StandardCharsets#UTF_8} directly
|
||||
* instead.
|
||||
**/
|
||||
@Deprecated
|
||||
public static final Charset CHARSET;
|
||||
|
||||
/** Native character encoding for commit messages, file names... */
|
||||
|
@ -638,7 +644,7 @@ public static byte[] encodeASCII(String s) {
|
|||
* @see #CHARACTER_ENCODING
|
||||
*/
|
||||
public static byte[] encode(String str) {
|
||||
final ByteBuffer bb = Constants.CHARSET.encode(str);
|
||||
final ByteBuffer bb = UTF_8.encode(str);
|
||||
final int len = bb.limit();
|
||||
if (bb.hasArray() && bb.arrayOffset() == 0) {
|
||||
final byte[] arr = bb.array();
|
||||
|
@ -655,7 +661,7 @@ public static byte[] encode(String str) {
|
|||
if (OBJECT_ID_LENGTH != newMessageDigest().getDigestLength())
|
||||
throw new LinkageError(JGitText.get().incorrectOBJECT_ID_LENGTH);
|
||||
CHARSET = UTF_8;
|
||||
CHARACTER_ENCODING = CHARSET.name();
|
||||
CHARACTER_ENCODING = UTF_8.name();
|
||||
}
|
||||
|
||||
/** name of the file containing the commit msg for a merge commit */
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
|
||||
package org.eclipse.jgit.lib;
|
||||
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
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, CHARSET);
|
||||
nextSpace - tokenBegin - 1, UTF_8);
|
||||
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, CHARSET);
|
||||
nextSpace - tokenBegin - 1, UTF_8);
|
||||
tokenBegin = nextSpace;
|
||||
commit = AbbreviatedObjectId.fromString(commitToken);
|
||||
break;
|
||||
|
|
|
@ -45,6 +45,8 @@
|
|||
|
||||
package org.eclipse.jgit.lib;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStreamWriter;
|
||||
|
@ -181,7 +183,7 @@ public void setMessage(String newMessage) {
|
|||
public byte[] build() {
|
||||
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
||||
try (OutputStreamWriter w = new OutputStreamWriter(os,
|
||||
Constants.CHARSET)) {
|
||||
UTF_8)) {
|
||||
w.write("object "); //$NON-NLS-1$
|
||||
getObjectId().copyTo(w);
|
||||
w.write('\n');
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
|
||||
package org.eclipse.jgit.lib;
|
||||
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
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, CHARSET)));
|
||||
this(new PrintWriter(new OutputStreamWriter(System.err, UTF_8)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
|
||||
package org.eclipse.jgit.patch;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.eclipse.jgit.lib.Constants.encodeASCII;
|
||||
import static org.eclipse.jgit.util.RawParseUtils.decode;
|
||||
import static org.eclipse.jgit.util.RawParseUtils.decodeNoFallback;
|
||||
|
@ -63,7 +64,6 @@
|
|||
import org.eclipse.jgit.diff.EditList;
|
||||
import org.eclipse.jgit.internal.JGitText;
|
||||
import org.eclipse.jgit.lib.AbbreviatedObjectId;
|
||||
import org.eclipse.jgit.lib.Constants;
|
||||
import org.eclipse.jgit.lib.FileMode;
|
||||
import org.eclipse.jgit.util.QuotedString;
|
||||
import org.eclipse.jgit.util.RawParseUtils;
|
||||
|
@ -198,7 +198,7 @@ public int getEndOffset() {
|
|||
* Convert the patch script for this file into a string.
|
||||
* <p>
|
||||
* The default character encoding
|
||||
* ({@link org.eclipse.jgit.lib.Constants#CHARSET}) is assumed for both the
|
||||
* ({@link java.nio.charset.StandardCharsets#UTF_8}) is assumed for both the
|
||||
* old and new files.
|
||||
*
|
||||
* @return the patch script, as a Unicode string.
|
||||
|
@ -240,8 +240,9 @@ String getScriptText(Charset[] charsetGuess) {
|
|||
|
||||
if (trySimpleConversion(charsetGuess)) {
|
||||
Charset cs = charsetGuess != null ? charsetGuess[0] : null;
|
||||
if (cs == null)
|
||||
cs = Constants.CHARSET;
|
||||
if (cs == null) {
|
||||
cs = UTF_8;
|
||||
}
|
||||
try {
|
||||
return decodeNoFallback(cs, buf, startOffset, endOffset);
|
||||
} catch (CharacterCodingException cee) {
|
||||
|
@ -290,8 +291,9 @@ private String[] extractFileLines(Charset[] csGuess) {
|
|||
final String[] r = new String[tmp.length];
|
||||
for (int i = 0; i < tmp.length; i++) {
|
||||
Charset cs = csGuess != null ? csGuess[i] : null;
|
||||
if (cs == null)
|
||||
cs = Constants.CHARSET;
|
||||
if (cs == null) {
|
||||
cs = UTF_8;
|
||||
}
|
||||
r[i] = RawParseUtils.decode(cs, tmp[i].toByteArray());
|
||||
}
|
||||
return r;
|
||||
|
@ -429,7 +431,7 @@ int parseGitFileName(int ptr, int end) {
|
|||
oldPath = QuotedString.GIT_PATH.dequote(buf, bol, sp - 1);
|
||||
oldPath = p1(oldPath);
|
||||
} else {
|
||||
oldPath = decode(Constants.CHARSET, buf, aStart, sp - 1);
|
||||
oldPath = decode(UTF_8, buf, aStart, sp - 1);
|
||||
}
|
||||
newPath = oldPath;
|
||||
return eol;
|
||||
|
@ -572,7 +574,7 @@ private String parseName(String expect, int ptr, int end) {
|
|||
tab--;
|
||||
if (ptr == tab)
|
||||
tab = end;
|
||||
r = decode(Constants.CHARSET, buf, ptr, tab - 1);
|
||||
r = decode(UTF_8, buf, ptr, tab - 1);
|
||||
}
|
||||
|
||||
if (r.equals(DEV_NULL))
|
||||
|
|
|
@ -43,9 +43,10 @@
|
|||
|
||||
package org.eclipse.jgit.patch;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import org.eclipse.jgit.lib.Constants;
|
||||
import org.eclipse.jgit.util.RawParseUtils;
|
||||
|
||||
/**
|
||||
|
@ -120,7 +121,7 @@ public int getOffset() {
|
|||
*/
|
||||
public String getLineText() {
|
||||
final int eol = RawParseUtils.nextLF(buf, offset);
|
||||
return RawParseUtils.decode(Constants.CHARSET, buf, offset, eol);
|
||||
return RawParseUtils.decode(UTF_8, buf, offset, eol);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
|
|
|
@ -44,13 +44,14 @@
|
|||
|
||||
package org.eclipse.jgit.revwalk;
|
||||
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.IllegalCharsetNameException;
|
||||
import java.nio.charset.UnsupportedCharsetException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -389,6 +390,34 @@ public final byte[] getRawBuffer() {
|
|||
return buffer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the gpg signature from the raw buffer.
|
||||
* <p>
|
||||
* This method parses and returns the raw content of the gpgsig lines. This
|
||||
* method is fairly expensive and produces a new byte[] instance on each
|
||||
* invocation. Callers should invoke this method only if they are certain
|
||||
* they will need, and should cache the return value for as long as
|
||||
* necessary to use all information from it.
|
||||
* <p>
|
||||
* RevFilter implementations should try to use
|
||||
* {@link org.eclipse.jgit.util.RawParseUtils} to scan the
|
||||
* {@link #getRawBuffer()} instead, as this will allow faster evaluation of
|
||||
* commits.
|
||||
*
|
||||
* @return contents of the gpg signature; null if the commit was not signed.
|
||||
* @since 5.1
|
||||
*/
|
||||
public final @Nullable byte[] getRawGpgSignature() {
|
||||
final byte[] raw = buffer;
|
||||
final byte[] header = {'g', 'p', 'g', 's', 'i', 'g'};
|
||||
final int start = RawParseUtils.headerStart(header, raw, 0);
|
||||
if (start < 0) {
|
||||
return null;
|
||||
}
|
||||
final int end = RawParseUtils.headerEnd(raw, start);
|
||||
return Arrays.copyOfRange(raw, start, end);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the author identity from the raw buffer.
|
||||
* <p>
|
||||
|
@ -541,7 +570,7 @@ private Charset guessEncoding() {
|
|||
try {
|
||||
return getEncoding();
|
||||
} catch (IllegalCharsetNameException | UnsupportedCharsetException e) {
|
||||
return CHARSET;
|
||||
return UTF_8;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
|
||||
package org.eclipse.jgit.revwalk;
|
||||
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
|
@ -169,7 +169,7 @@ void parseCanonical(RevWalk walk, byte[] rawTag)
|
|||
|
||||
int p = pos.value += 4; // "tag "
|
||||
final int nameEnd = RawParseUtils.nextLF(rawTag, p) - 1;
|
||||
tagName = RawParseUtils.decode(CHARSET, rawTag, p, nameEnd);
|
||||
tagName = RawParseUtils.decode(UTF_8, 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 CHARSET;
|
||||
return UTF_8;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@
|
|||
|
||||
package org.eclipse.jgit.storage.file;
|
||||
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
|
@ -166,7 +166,7 @@ public void load() throws IOException, ConfigInvalidException {
|
|||
} else {
|
||||
final String decoded;
|
||||
if (isUtf8(in)) {
|
||||
decoded = RawParseUtils.decode(CHARSET,
|
||||
decoded = RawParseUtils.decode(UTF_8,
|
||||
in, 3, in.length);
|
||||
utf8Bom = true;
|
||||
} else {
|
||||
|
@ -224,7 +224,7 @@ public void save() throws IOException {
|
|||
bos.write(0xEF);
|
||||
bos.write(0xBB);
|
||||
bos.write(0xBF);
|
||||
bos.write(text.getBytes(CHARSET));
|
||||
bos.write(text.getBytes(UTF_8));
|
||||
out = bos.toByteArray();
|
||||
} else {
|
||||
out = Constants.encode(text);
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
|
||||
package org.eclipse.jgit.transport;
|
||||
|
||||
import static org.eclipse.jgit.lib.Constants.CHARSET;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
|
@ -635,7 +635,7 @@ void authorize(HttpURLConnection c) throws IOException {
|
|||
try {
|
||||
final Mac m = Mac.getInstance(HMAC);
|
||||
m.init(privateKey);
|
||||
sec = Base64.encodeBytes(m.doFinal(s.toString().getBytes(CHARSET)));
|
||||
sec = Base64.encodeBytes(m.doFinal(s.toString().getBytes(UTF_8)));
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
throw new IOException(MessageFormat.format(JGitText.get().noHMACsupport, HMAC, e.getMessage()));
|
||||
} catch (InvalidKeyException e) {
|
||||
|
|
|
@ -52,7 +52,6 @@
|
|||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.jgit.errors.PackProtocolException;
|
||||
|
@ -235,12 +234,12 @@ public abstract class BasePackFetchConnection extends BasePackConnection
|
|||
|
||||
private boolean noProgress;
|
||||
|
||||
private Set<AnyObjectId> minimalNegotiationSet;
|
||||
|
||||
private String lockMessage;
|
||||
|
||||
private PackLock packLock;
|
||||
|
||||
private int maxHaves;
|
||||
|
||||
/** RPC state, if {@link BasePackConnection#statelessRPC} is true. */
|
||||
private TemporaryBuffer.Heap state;
|
||||
|
||||
|
@ -261,12 +260,12 @@ public BasePackFetchConnection(PackTransport packTransport) {
|
|||
if (local != null) {
|
||||
final FetchConfig cfg = getFetchConfig();
|
||||
allowOfsDelta = cfg.allowOfsDelta;
|
||||
if (cfg.minimalNegotiation) {
|
||||
minimalNegotiationSet = new HashSet<>();
|
||||
}
|
||||
maxHaves = cfg.maxHaves;
|
||||
} else {
|
||||
allowOfsDelta = true;
|
||||
maxHaves = Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
includeTags = transport.getTagOpt() != TagOpt.NO_TAGS;
|
||||
thinPack = transport.isFetchThin();
|
||||
filterBlobLimit = transport.getFilterBlobLimit();
|
||||
|
@ -294,17 +293,16 @@ public BasePackFetchConnection(PackTransport packTransport) {
|
|||
static class FetchConfig {
|
||||
final boolean allowOfsDelta;
|
||||
|
||||
final boolean minimalNegotiation;
|
||||
final int maxHaves;
|
||||
|
||||
FetchConfig(Config c) {
|
||||
allowOfsDelta = c.getBoolean("repack", "usedeltabaseoffset", true); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
minimalNegotiation = c.getBoolean("fetch", "useminimalnegotiation", //$NON-NLS-1$ //$NON-NLS-2$
|
||||
false);
|
||||
maxHaves = c.getInt("fetch", "maxhaves", Integer.MAX_VALUE); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
|
||||
FetchConfig(boolean allowOfsDelta, boolean minimalNegotiation) {
|
||||
FetchConfig(boolean allowOfsDelta, int maxHaves) {
|
||||
this.allowOfsDelta = allowOfsDelta;
|
||||
this.minimalNegotiation = minimalNegotiation;
|
||||
this.maxHaves = maxHaves;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -518,15 +516,6 @@ private boolean sendWants(Collection<Ref> want) throws IOException {
|
|||
}
|
||||
line.append('\n');
|
||||
p.writeString(line.toString());
|
||||
if (minimalNegotiationSet != null) {
|
||||
Ref current = local.exactRef(r.getName());
|
||||
if (current != null) {
|
||||
ObjectId o = current.getObjectId();
|
||||
if (o != null && !o.equals(ObjectId.zeroId())) {
|
||||
minimalNegotiationSet.add(o);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (first) {
|
||||
return false;
|
||||
|
@ -610,9 +599,6 @@ private void negotiate(ProgressMonitor monitor) throws IOException,
|
|||
pckOut.writeString("have " + o.name() + "\n"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
havesSent++;
|
||||
havesSinceLastContinue++;
|
||||
if (minimalNegotiationSet != null) {
|
||||
minimalNegotiationSet.remove(o);
|
||||
}
|
||||
|
||||
if ((31 & havesSent) != 0) {
|
||||
// We group the have lines into blocks of 32, each marked
|
||||
|
@ -646,16 +632,6 @@ private void negotiate(ProgressMonitor monitor) throws IOException,
|
|||
// pack on the remote side. Keep doing that.
|
||||
//
|
||||
resultsPending--;
|
||||
if (minimalNegotiationSet != null
|
||||
&& minimalNegotiationSet.isEmpty()) {
|
||||
// Minimal negotiation was requested and we sent out our
|
||||
// current reference values for our wants, so terminate
|
||||
// negotiation early.
|
||||
if (statelessRPC) {
|
||||
state.writeTo(out, null);
|
||||
}
|
||||
break SEND_HAVES;
|
||||
}
|
||||
break READ_RESULT;
|
||||
|
||||
case ACK:
|
||||
|
@ -686,14 +662,6 @@ private void negotiate(ProgressMonitor monitor) throws IOException,
|
|||
if (anr == AckNackResult.ACK_READY) {
|
||||
receivedReady = true;
|
||||
}
|
||||
if (minimalNegotiationSet != null && minimalNegotiationSet.isEmpty()) {
|
||||
// Minimal negotiation was requested and we sent out our current reference
|
||||
// values for our wants, so terminate negotiation early.
|
||||
if (statelessRPC) {
|
||||
state.writeTo(out, null);
|
||||
}
|
||||
break SEND_HAVES;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -709,7 +677,8 @@ private void negotiate(ProgressMonitor monitor) throws IOException,
|
|||
state.writeTo(out, null);
|
||||
}
|
||||
|
||||
if (receivedContinue && havesSinceLastContinue > MAX_HAVES) {
|
||||
if (receivedContinue && havesSinceLastContinue > MAX_HAVES
|
||||
|| havesSent >= maxHaves) {
|
||||
// Our history must be really different from the remote's.
|
||||
// We just sent a whole slew of have lines, and it did not
|
||||
// recognize any of them. Avoid sending our entire history
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue