From: Ivan Frade Date: Wed, 9 Oct 2019 23:40:17 +0000 (-0700) Subject: ProtocolV2Parser: Introduce advertise sideband-all option X-Git-Tag: v5.6.0.201911271000-m3~81 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=914e320ac6db23f7461dd997022d7799d0a4794d;p=jgit.git 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 --- diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java index 2f370d8c52..6d53555e9f 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java +++ b/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"); } 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 758d74c3fa..100b433e00 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransferConfig.java +++ b/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. diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java index 6f0e66e6d8..5bee1ce9a7 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java +++ b/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 " : "")