summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit
diff options
context:
space:
mode:
authorDavid Ostrovsky <david@ostrovsky.org>2020-11-29 13:06:00 +0100
committerMatthias Sohn <matthias.sohn@sap.com>2020-11-29 22:46:51 +0100
commit23389a63238c50daf0d8d1e3fd2b1d29f4171645 (patch)
treeca8a64314f55368e760f0263a4d9cf3f273ab479 /org.eclipse.jgit
parent5cd485e5dda41d2ef06226a692c64f1aa221eb25 (diff)
downloadjgit-23389a63238c50daf0d8d1e3fd2b1d29f4171645.tar.gz
jgit-23389a63238c50daf0d8d1e3fd2b1d29f4171645.zip
Add constants for parsing git wire protocol version
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>
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigConstants.java8
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/TransferConfig.java28
2 files changed, 31 insertions, 5 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigConstants.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigConstants.java
index 4fcf8e2dcd..834fff5dd9 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigConstants.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigConstants.java
@@ -93,6 +93,12 @@ public final class ConfigConstants {
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
*/
@@ -685,7 +691,7 @@ public final class ConfigConstants {
public static final String CONFIG_INDEX_SECTION = "index";
/**
- * The "index.version" key
+ * The "version" key
*
* @since 5.9
*/
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransferConfig.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransferConfig.java
index cc577fa11e..0b38159c09 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransferConfig.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransferConfig.java
@@ -21,6 +21,7 @@ import java.util.Map;
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;
@@ -60,11 +61,19 @@ public class TransferConfig {
}
/**
- * 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;
@@ -73,6 +82,15 @@ public class TransferConfig {
this.name = name;
}
+ /**
+ * Returns version number
+ *
+ * @return string version
+ */
+ public String version() {
+ return name;
+ }
+
@Nullable
static ProtocolVersion parse(@Nullable String name) {
if (name == null) {
@@ -177,7 +195,9 @@ public class TransferConfig {
"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);