Merge branch 'stable-5.9'
* stable-5.9: Add constants for parsing git wire protocol version Change-Id: I1e4174ae8bbefcb71a191dcbf32027d4b35c2b37 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
This commit is contained in:
commit
180dfdefa4
|
@ -38,6 +38,7 @@
|
||||||
import org.eclipse.jgit.junit.TestRepository;
|
import org.eclipse.jgit.junit.TestRepository;
|
||||||
import org.eclipse.jgit.junit.http.AccessEvent;
|
import org.eclipse.jgit.junit.http.AccessEvent;
|
||||||
import org.eclipse.jgit.junit.http.AppServer;
|
import org.eclipse.jgit.junit.http.AppServer;
|
||||||
|
import org.eclipse.jgit.lib.ConfigConstants;
|
||||||
import org.eclipse.jgit.lib.Constants;
|
import org.eclipse.jgit.lib.Constants;
|
||||||
import org.eclipse.jgit.lib.Ref;
|
import org.eclipse.jgit.lib.Ref;
|
||||||
import org.eclipse.jgit.lib.RefUpdate;
|
import org.eclipse.jgit.lib.RefUpdate;
|
||||||
|
@ -49,6 +50,7 @@
|
||||||
import org.eclipse.jgit.transport.PacketLineIn;
|
import org.eclipse.jgit.transport.PacketLineIn;
|
||||||
import org.eclipse.jgit.transport.PacketLineOut;
|
import org.eclipse.jgit.transport.PacketLineOut;
|
||||||
import org.eclipse.jgit.transport.Transport;
|
import org.eclipse.jgit.transport.Transport;
|
||||||
|
import org.eclipse.jgit.transport.TransferConfig;
|
||||||
import org.eclipse.jgit.transport.URIish;
|
import org.eclipse.jgit.transport.URIish;
|
||||||
import org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider;
|
import org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider;
|
||||||
import org.eclipse.jgit.transport.http.HttpConnection;
|
import org.eclipse.jgit.transport.http.HttpConnection;
|
||||||
|
@ -342,8 +344,10 @@ public void testHttpClientWantsV2ButServerNotConfigured() throws Exception {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testV2HttpFirstResponse() throws Exception {
|
public void testV2HttpFirstResponse() throws Exception {
|
||||||
remoteRepository.getRepository().getConfig().setInt(
|
remoteRepository.getRepository().getConfig().setString(
|
||||||
"protocol", null, "version", 2);
|
ConfigConstants.CONFIG_PROTOCOL_SECTION, null,
|
||||||
|
ConfigConstants.CONFIG_KEY_VERSION,
|
||||||
|
TransferConfig.ProtocolVersion.V2.version());
|
||||||
|
|
||||||
String url = smartAuthNoneURI.toString() + "/info/refs?service=git-upload-pack";
|
String url = smartAuthNoneURI.toString() + "/info/refs?service=git-upload-pack";
|
||||||
HttpConnection c = HttpTransport.getConnectionFactory()
|
HttpConnection c = HttpTransport.getConnectionFactory()
|
||||||
|
@ -364,8 +368,10 @@ public void testV2HttpFirstResponse() throws Exception {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testV2HttpSubsequentResponse() throws Exception {
|
public void testV2HttpSubsequentResponse() throws Exception {
|
||||||
remoteRepository.getRepository().getConfig().setInt(
|
remoteRepository.getRepository().getConfig().setString(
|
||||||
"protocol", null, "version", 2);
|
ConfigConstants.CONFIG_PROTOCOL_SECTION, null,
|
||||||
|
ConfigConstants.CONFIG_KEY_VERSION,
|
||||||
|
TransferConfig.ProtocolVersion.V2.version());
|
||||||
|
|
||||||
String url = smartAuthNoneURI.toString() + "/git-upload-pack";
|
String url = smartAuthNoneURI.toString() + "/git-upload-pack";
|
||||||
HttpConnection c = HttpTransport.getConnectionFactory()
|
HttpConnection c = HttpTransport.getConnectionFactory()
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
import org.eclipse.jgit.internal.storage.pack.CachedPack;
|
import org.eclipse.jgit.internal.storage.pack.CachedPack;
|
||||||
import org.eclipse.jgit.internal.storage.pack.CachedPackUriProvider;
|
import org.eclipse.jgit.internal.storage.pack.CachedPackUriProvider;
|
||||||
import org.eclipse.jgit.junit.TestRepository;
|
import org.eclipse.jgit.junit.TestRepository;
|
||||||
|
import org.eclipse.jgit.lib.ConfigConstants;
|
||||||
import org.eclipse.jgit.lib.NullProgressMonitor;
|
import org.eclipse.jgit.lib.NullProgressMonitor;
|
||||||
import org.eclipse.jgit.lib.ObjectId;
|
import org.eclipse.jgit.lib.ObjectId;
|
||||||
import org.eclipse.jgit.lib.ObjectInserter;
|
import org.eclipse.jgit.lib.ObjectInserter;
|
||||||
|
@ -370,7 +371,8 @@ private ByteArrayInputStream uploadPackSetup(String version,
|
||||||
|
|
||||||
ByteArrayInputStream send = linesAsInputStream(inputLines);
|
ByteArrayInputStream send = linesAsInputStream(inputLines);
|
||||||
|
|
||||||
server.getConfig().setString("protocol", null, "version", version);
|
server.getConfig().setString(ConfigConstants.CONFIG_PROTOCOL_SECTION,
|
||||||
|
null, ConfigConstants.CONFIG_KEY_VERSION, version);
|
||||||
UploadPack up = new UploadPack(server);
|
UploadPack up = new UploadPack(server);
|
||||||
if (postConstructionSetup != null) {
|
if (postConstructionSetup != null) {
|
||||||
postConstructionSetup.accept(up);
|
postConstructionSetup.accept(up);
|
||||||
|
@ -2253,7 +2255,9 @@ public void testGetPeerAgentProtocolV0() throws Exception {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetPeerAgentProtocolV2() throws Exception {
|
public void testGetPeerAgentProtocolV2() throws Exception {
|
||||||
server.getConfig().setString("protocol", null, "version", "2");
|
server.getConfig().setString(ConfigConstants.CONFIG_PROTOCOL_SECTION,
|
||||||
|
null, ConfigConstants.CONFIG_KEY_VERSION,
|
||||||
|
TransferConfig.ProtocolVersion.V2.version());
|
||||||
|
|
||||||
RevCommit one = remote.commit().message("1").create();
|
RevCommit one = remote.commit().message("1").create();
|
||||||
remote.update("one", one);
|
remote.update("one", one);
|
||||||
|
|
|
@ -1,5 +1,14 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
<component id="org.eclipse.jgit" version="2">
|
<component id="org.eclipse.jgit" version="2">
|
||||||
|
<resource path="src/org/eclipse/jgit/lib/ConfigConstants.java" type="org.eclipse.jgit.lib.ConfigConstants">
|
||||||
|
<filter id="1141899266">
|
||||||
|
<message_arguments>
|
||||||
|
<message_argument value="5.9"/>
|
||||||
|
<message_argument value="5.10"/>
|
||||||
|
<message_argument value="CONFIG_PROTOCOL_SECTION"/>
|
||||||
|
</message_arguments>
|
||||||
|
</filter>
|
||||||
|
</resource>
|
||||||
<resource path="src/org/eclipse/jgit/lib/TypedConfigGetter.java" type="org.eclipse.jgit.lib.TypedConfigGetter">
|
<resource path="src/org/eclipse/jgit/lib/TypedConfigGetter.java" type="org.eclipse.jgit.lib.TypedConfigGetter">
|
||||||
<filter id="404000815">
|
<filter id="404000815">
|
||||||
<message_arguments>
|
<message_arguments>
|
||||||
|
@ -36,4 +45,13 @@
|
||||||
</message_arguments>
|
</message_arguments>
|
||||||
</filter>
|
</filter>
|
||||||
</resource>
|
</resource>
|
||||||
|
<resource path="src/org/eclipse/jgit/transport/TransferConfig.java" type="org.eclipse.jgit.transport.TransferConfig$ProtocolVersion">
|
||||||
|
<filter id="1175453698">
|
||||||
|
<message_arguments>
|
||||||
|
<message_argument value="5.9"/>
|
||||||
|
<message_argument value="5.10"/>
|
||||||
|
<message_argument value="org.eclipse.jgit.transport.TransferConfig.ProtocolVersion"/>
|
||||||
|
</message_arguments>
|
||||||
|
</filter>
|
||||||
|
</resource>
|
||||||
</component>
|
</component>
|
||||||
|
|
|
@ -92,6 +92,12 @@ public final class ConfigConstants {
|
||||||
*/
|
*/
|
||||||
public static final String CONFIG_GPG_SECTION = "gpg";
|
public static final String CONFIG_GPG_SECTION = "gpg";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The "protocol" section
|
||||||
|
* @since 5.9
|
||||||
|
*/
|
||||||
|
public static final String CONFIG_PROTOCOL_SECTION = "protocol";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The "format" key
|
* The "format" key
|
||||||
* @since 5.2
|
* @since 5.2
|
||||||
|
@ -685,7 +691,7 @@ public final class ConfigConstants {
|
||||||
public static final String CONFIG_INDEX_SECTION = "index";
|
public static final String CONFIG_INDEX_SECTION = "index";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The "index.version" key
|
* The "version" key
|
||||||
*
|
*
|
||||||
* @since 5.9
|
* @since 5.9
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
import org.eclipse.jgit.annotations.Nullable;
|
import org.eclipse.jgit.annotations.Nullable;
|
||||||
import org.eclipse.jgit.internal.storage.file.LazyObjectIdSetFile;
|
import org.eclipse.jgit.internal.storage.file.LazyObjectIdSetFile;
|
||||||
import org.eclipse.jgit.lib.Config;
|
import org.eclipse.jgit.lib.Config;
|
||||||
|
import org.eclipse.jgit.lib.ConfigConstants;
|
||||||
import org.eclipse.jgit.lib.Config.SectionParser;
|
import org.eclipse.jgit.lib.Config.SectionParser;
|
||||||
import org.eclipse.jgit.lib.ObjectChecker;
|
import org.eclipse.jgit.lib.ObjectChecker;
|
||||||
import org.eclipse.jgit.lib.ObjectIdSet;
|
import org.eclipse.jgit.lib.ObjectIdSet;
|
||||||
|
@ -60,11 +61,19 @@ public enum FsckMode {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A git configuration variable for which versions of the Git protocol to prefer.
|
* A git configuration variable for which versions of the Git protocol to
|
||||||
* Used in protocol.version.
|
* prefer. Used in protocol.version.
|
||||||
|
*
|
||||||
|
* @since 5.9
|
||||||
|
*/
|
||||||
|
public enum ProtocolVersion {
|
||||||
|
/**
|
||||||
|
* Git wire protocol version 0 (the default).
|
||||||
*/
|
*/
|
||||||
enum ProtocolVersion {
|
|
||||||
V0("0"), //$NON-NLS-1$
|
V0("0"), //$NON-NLS-1$
|
||||||
|
/**
|
||||||
|
* Git wire protocol version 2.
|
||||||
|
*/
|
||||||
V2("2"); //$NON-NLS-1$
|
V2("2"); //$NON-NLS-1$
|
||||||
|
|
||||||
final String name;
|
final String name;
|
||||||
|
@ -73,6 +82,15 @@ enum ProtocolVersion {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns version number
|
||||||
|
*
|
||||||
|
* @return string version
|
||||||
|
*/
|
||||||
|
public String version() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
static ProtocolVersion parse(@Nullable String name) {
|
static ProtocolVersion parse(@Nullable String name) {
|
||||||
if (name == null) {
|
if (name == null) {
|
||||||
|
@ -177,7 +195,9 @@ public TransferConfig(Config rc) {
|
||||||
"uploadpack", "allowreachablesha1inwant", false);
|
"uploadpack", "allowreachablesha1inwant", false);
|
||||||
allowFilter = rc.getBoolean(
|
allowFilter = rc.getBoolean(
|
||||||
"uploadpack", "allowfilter", false);
|
"uploadpack", "allowfilter", false);
|
||||||
protocolVersion = ProtocolVersion.parse(rc.getString("protocol", null, "version"));
|
protocolVersion = ProtocolVersion.parse(rc
|
||||||
|
.getString(ConfigConstants.CONFIG_PROTOCOL_SECTION, null,
|
||||||
|
ConfigConstants.CONFIG_KEY_VERSION));
|
||||||
hideRefs = rc.getStringList("uploadpack", null, "hiderefs");
|
hideRefs = rc.getStringList("uploadpack", null, "hiderefs");
|
||||||
allowSidebandAll = rc.getBoolean(
|
allowSidebandAll = rc.getBoolean(
|
||||||
"uploadpack", "allowsidebandall", false);
|
"uploadpack", "allowsidebandall", false);
|
||||||
|
|
Loading…
Reference in New Issue