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>
This commit is contained in:
parent
bca00aa5f4
commit
914e320ac6
|
@ -501,8 +501,11 @@ public void testV2CapabilitiesRefInWantNotAdvertisedIfUnallowed() throws Excepti
|
|||
}
|
||||
|
||||
@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");
|
||||
}
|
||||
|
||||
|
|
|
@ -132,6 +132,7 @@ static ProtocolVersion parse(@Nullable String name) {
|
|||
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 TransferConfig(Config rc) {
|
|||
hideRefs = rc.getStringList("uploadpack", null, "hiderefs");
|
||||
allowSidebandAll = rc.getBoolean(
|
||||
"uploadpack", "allowsidebandall", false);
|
||||
advertiseSidebandAll = rc.getBoolean("uploadpack",
|
||||
"advertisesidebandall", false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -295,13 +298,22 @@ public boolean isAllowRefInWant() {
|
|||
}
|
||||
|
||||
/**
|
||||
* @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.
|
||||
|
|
|
@ -1325,7 +1325,7 @@ private List<String> getV2CapabilityAdvertisement() {
|
|||
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…
Reference in New Issue