]> source.dussan.org Git - jgit.git/commitdiff
ProtocolV2Parser: Introduce advertise sideband-all option 63/150863/7
authorIvan Frade <ifrade@google.com>
Wed, 9 Oct 2019 23:40:17 +0000 (16:40 -0700)
committerIvan Frade <ifrade@google.com>
Tue, 15 Oct 2019 19:20:37 +0000 (12:20 -0700)
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>
org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java
org.eclipse.jgit/src/org/eclipse/jgit/transport/TransferConfig.java
org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java

index 2f370d8c523033669ad9871aef9e83a97505adfa..6d53555e9ff7f410d22cbfb9da678997ab0a3081 100644 (file)
@@ -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");
        }
 
index 758d74c3fa965e7d0f2acd4c810032ebfa672d9e..100b433e00665f86da089299bab0aa4eb16bbb16 100644 (file)
@@ -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.
index 6f0e66e6d838fa1de58afa2d230f1dd3a7759cbf..5bee1ce9a7eaade2d78a300a3b59865885c1f3aa 100644 (file)
@@ -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 " : "")