Browse Source

ProtocolV2Parser: Introduce advertise sideband-all option

The flag enabling sideband-all is used in two places: in UploadPack
for advertisement and in the protocol parser to read it from the
request.

This leds to problems in distributed deployments where the two requests of
a fetch can go to different servers with different configurations.

Use the existing allowsidebandall to accept the sideband-all request
(and respond to it) and introduce a new "advertisesidebandall" to toggle
the advertising of the feature.

Change-Id: I892d541bc3f321606c89bad1d333b079dce6b5fa
Signed-off-by: Ivan Frade <ifrade@google.com>
next
Ivan Frade 5 years ago
parent
commit
914e320ac6
  1. 7
      org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java
  2. 14
      org.eclipse.jgit/src/org/eclipse/jgit/transport/TransferConfig.java
  3. 2
      org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java

7
org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java

@ -501,8 +501,11 @@ public class UploadPackTest {
}
@Test
public void testV2CapabilitiesAllowSidebandAll() throws Exception {
checkAdvertisedIfAllowed("uploadpack", "allowsidebandall", "sideband-all");
public void testV2CapabilitiesAdvertiseSidebandAll() throws Exception {
server.getConfig().setBoolean("uploadpack", null, "allowsidebandall",
true);
checkAdvertisedIfAllowed("uploadpack", "advertisesidebandall",
"sideband-all");
checkUnadvertisedIfUnallowed("sideband-all");
}

14
org.eclipse.jgit/src/org/eclipse/jgit/transport/TransferConfig.java

@ -132,6 +132,7 @@ public class TransferConfig {
private final boolean allowReachableSha1InWant;
private final boolean allowFilter;
private final boolean allowSidebandAll;
private final boolean advertiseSidebandAll;
final @Nullable ProtocolVersion protocolVersion;
final String[] hideRefs;
@ -213,6 +214,8 @@ public class TransferConfig {
hideRefs = rc.getStringList("uploadpack", null, "hiderefs");
allowSidebandAll = rc.getBoolean(
"uploadpack", "allowsidebandall", false);
advertiseSidebandAll = rc.getBoolean("uploadpack",
"advertisesidebandall", false);
}
/**
@ -295,13 +298,22 @@ public class TransferConfig {
}
/**
* @return true if clients are allowed to specify a "sideband-all" line
* @return true if the server accepts sideband-all requests (see
* {{@link #isAdvertiseSidebandAll()} for the advertisement)
* @since 5.5
*/
public boolean isAllowSidebandAll() {
return allowSidebandAll;
}
/**
* @return true to advertise sideband all to the clients
* @since 5.6
*/
public boolean isAdvertiseSidebandAll() {
return advertiseSidebandAll && allowSidebandAll;
}
/**
* Get {@link org.eclipse.jgit.transport.RefFilter} respecting configured
* hidden refs.

2
org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java

@ -1325,7 +1325,7 @@ public class UploadPack {
caps.add(COMMAND_FETCH + '='
+ (transferConfig.isAllowFilter() ? OPTION_FILTER + ' ' : "")
+ (advertiseRefInWant ? CAPABILITY_REF_IN_WANT + ' ' : "")
+ (transferConfig.isAllowSidebandAll()
+ (transferConfig.isAdvertiseSidebandAll()
? OPTION_SIDEBAND_ALL + ' '
: "")
+ (cachedPackUriProvider != null ? "packfile-uris " : "")

Loading…
Cancel
Save