This would allow other JGit users to access and reuse the constants.
Change-Id: I1608802f45586af5f8582afa592e26679e9cebe3
Signed-off-by: David Ostrovsky <david@ostrovsky.org>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
import org.eclipse.jgit.junit.TestRepository;
import org.eclipse.jgit.junit.http.AccessEvent;
import org.eclipse.jgit.junit.http.AppServer;
+import org.eclipse.jgit.lib.ConfigConstants;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.lib.RefUpdate;
import org.eclipse.jgit.transport.PacketLineIn;
import org.eclipse.jgit.transport.PacketLineOut;
import org.eclipse.jgit.transport.Transport;
+import org.eclipse.jgit.transport.TransferConfig;
import org.eclipse.jgit.transport.URIish;
import org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider;
import org.eclipse.jgit.transport.http.HttpConnection;
@Test
public void testV2HttpFirstResponse() throws Exception {
- remoteRepository.getRepository().getConfig().setInt(
- "protocol", null, "version", 2);
+ remoteRepository.getRepository().getConfig().setString(
+ ConfigConstants.CONFIG_PROTOCOL_SECTION, null,
+ ConfigConstants.CONFIG_KEY_VERSION,
+ TransferConfig.ProtocolVersion.V2.version());
String url = smartAuthNoneURI.toString() + "/info/refs?service=git-upload-pack";
HttpConnection c = HttpTransport.getConnectionFactory()
@Test
public void testV2HttpSubsequentResponse() throws Exception {
- remoteRepository.getRepository().getConfig().setInt(
- "protocol", null, "version", 2);
+ remoteRepository.getRepository().getConfig().setString(
+ ConfigConstants.CONFIG_PROTOCOL_SECTION, null,
+ ConfigConstants.CONFIG_KEY_VERSION,
+ TransferConfig.ProtocolVersion.V2.version());
String url = smartAuthNoneURI.toString() + "/git-upload-pack";
HttpConnection c = HttpTransport.getConnectionFactory()
import org.eclipse.jgit.internal.storage.pack.CachedPack;
import org.eclipse.jgit.internal.storage.pack.CachedPackUriProvider;
import org.eclipse.jgit.junit.TestRepository;
+import org.eclipse.jgit.lib.ConfigConstants;
import org.eclipse.jgit.lib.NullProgressMonitor;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.ObjectInserter;
ByteArrayInputStream send = linesAsInputStream(inputLines);
- server.getConfig().setString("protocol", null, "version", "2");
+ server.getConfig().setString(ConfigConstants.CONFIG_PROTOCOL_SECTION,
+ null, ConfigConstants.CONFIG_KEY_VERSION,
+ TransferConfig.ProtocolVersion.V2.version());
UploadPack up = new UploadPack(server);
if (postConstructionSetup != null) {
postConstructionSetup.accept(up);
@Test
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();
remote.update("one", one);
*/
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
* @since 5.2
public static final String CONFIG_INDEX_SECTION = "index";
/**
- * The "index.version" key
+ * The "version" key
*
* @since 5.9
*/
import org.eclipse.jgit.annotations.Nullable;
import org.eclipse.jgit.internal.storage.file.LazyObjectIdSetFile;
import org.eclipse.jgit.lib.Config;
+import org.eclipse.jgit.lib.ConfigConstants;
import org.eclipse.jgit.lib.Config.SectionParser;
import org.eclipse.jgit.lib.ObjectChecker;
import org.eclipse.jgit.lib.ObjectIdSet;
}
/**
- * A git configuration variable for which versions of the Git protocol to prefer.
- * Used in protocol.version.
+ * A git configuration variable for which versions of the Git protocol to
+ * prefer. Used in protocol.version.
+ *
+ * @since 5.9
*/
- enum ProtocolVersion {
+ public enum ProtocolVersion {
+ /**
+ * Git wire protocol version 0 (the default).
+ */
V0("0"), //$NON-NLS-1$
+ /**
+ * Git wire protocol version 2.
+ */
V2("2"); //$NON-NLS-1$
final String name;
this.name = name;
}
+ /**
+ * Returns version number
+ *
+ * @return string version
+ */
+ public String version() {
+ return name;
+ }
+
@Nullable
static ProtocolVersion parse(@Nullable String name) {
if (name == null) {
"uploadpack", "allowreachablesha1inwant", false);
allowFilter = rc.getBoolean(
"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");
allowSidebandAll = rc.getBoolean(
"uploadpack", "allowsidebandall", false);