summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Tan <jonathantanmy@google.com>2018-05-02 15:43:50 -0700
committerJonathan Nieder <jrn@google.com>2018-06-04 22:09:06 -0700
commite319a6f8d4e014214fe5433b1ffc7e5d528f3541 (patch)
treec37326cd5dd744224693c7428550668fd55ad838
parent62c4d3a1335bcc237a290c110b6d95bcc498e18d (diff)
downloadjgit-e319a6f8d4e014214fe5433b1ffc7e5d528f3541.tar.gz
jgit-e319a6f8d4e014214fe5433b1ffc7e5d528f3541.zip
Refactor v2 advertisement into own function
A subsequent patch needs dynamic generation of this advertisement depending on a configuration variable in the underlying repository, so refactor it into a function instead of using a constant list. Change-Id: Ie00584add1fb56c9e88c7b57f75703981ea5bb85 Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java20
1 files changed, 10 insertions, 10 deletions
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 4538ce2ee4..ea6bd3a91e 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java
@@ -119,14 +119,6 @@ import org.eclipse.jgit.util.io.TimeoutOutputStream;
* Implements the server side of a fetch connection, transmitting objects.
*/
public class UploadPack {
- // UploadPack sends these lines as the first response to a client that
- // supports protocol version 2.
- private static final String[] v2CapabilityAdvertisement = {
- "version 2", //$NON-NLS-1$
- COMMAND_LS_REFS,
- COMMAND_FETCH + '=' + OPTION_SHALLOW
- };
-
/** Policy the server uses to validate client requests */
public static enum RequestPolicy {
/** Client may only ask for objects the server advertised a reference for. */
@@ -1117,13 +1109,21 @@ public class UploadPack {
.format(JGitText.get().unknownTransportCommand, command));
}
+ private List<String> getV2CapabilityAdvertisement() {
+ ArrayList<String> caps = new ArrayList<>();
+ caps.add("version 2"); //$NON-NLS-1$
+ caps.add(COMMAND_LS_REFS);
+ caps.add(COMMAND_FETCH + '=' + OPTION_SHALLOW);
+ return caps;
+ }
+
private void serviceV2() throws IOException {
if (biDirectionalPipe) {
// Just like in service(), the capability advertisement
// is sent only if this is a bidirectional pipe. (If
// not, the client is expected to call
// sendAdvertisedRefs() on its own.)
- for (String s : v2CapabilityAdvertisement) {
+ for (String s : getV2CapabilityAdvertisement()) {
pckOut.writeString(s + "\n"); //$NON-NLS-1$
}
pckOut.end();
@@ -1287,7 +1287,7 @@ public class UploadPack {
if (useProtocolV2()) {
// The equivalent in v2 is only the capabilities
// advertisement.
- for (String s : v2CapabilityAdvertisement) {
+ for (String s : getV2CapabilityAdvertisement()) {
adv.writeOne(s);
}
adv.end();