aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIvan Frade <ifrade@google.com>2018-10-16 16:37:18 -0700
committerIvan Frade <ifrade@google.com>2018-10-19 11:01:28 -0700
commit0691c4b94b5a605da50144b8daeb497332d75577 (patch)
treef26495bcd7d4aa456e2877a826e85219046d3867
parent95579e6af3b27c66a7a8e7696ba4fcd3e21e183c (diff)
downloadjgit-0691c4b94b5a605da50144b8daeb497332d75577.tar.gz
jgit-0691c4b94b5a605da50144b8daeb497332d75577.zip
UploadPack: Use request instead of field for client capabilities
Change-Id: Idc21e2b3fd145d2a4b15c1cea5ec1956541e3b40 Signed-off-by: Ivan Frade <ifrade@google.com>
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java37
1 files changed, 22 insertions, 15 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 4639cbd44e..58cd564114 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java
@@ -286,8 +286,7 @@ public class UploadPack {
/** Hook for taking post upload actions. */
private PostUploadHook postUploadHook = PostUploadHook.NULL;
- /** Capabilities requested by the client. */
- private Set<String> options;
+ /** Caller user agent */
String userAgent;
/** Raw ObjectIds the client has asked for, before validating them. */
@@ -681,10 +680,12 @@ public class UploadPack {
* read.
*/
public boolean isSideBand() throws RequestNotYetReadException {
- if (options == null)
+ if (currentRequest == null) {
throw new RequestNotYetReadException();
- return (options.contains(OPTION_SIDE_BAND)
- || options.contains(OPTION_SIDE_BAND_64K));
+ }
+ Set<String> caps = currentRequest.getClientCapabilities();
+ return caps.contains(OPTION_SIDE_BAND)
+ || caps.contains(OPTION_SIDE_BAND_64K);
}
/**
@@ -815,7 +816,6 @@ public class UploadPack {
currentRequest = req;
wantIds = req.getWantIds();
- options = req.getClientCapabilities();
if (req.getWantIds().isEmpty()) {
preUploadHook.onBeginNegotiateRound(this, req.getWantIds(), 0);
@@ -956,7 +956,6 @@ public class UploadPack {
// TODO(ifrade): Refactor to pass around the Request object, instead of
// copying data back to class fields
- options = req.getClientCapabilities();
wantIds = req.getWantIds();
boolean sectionSent = false;
@@ -1368,7 +1367,12 @@ public class UploadPack {
* @since 4.0
*/
public String getPeerUserAgent() {
- return UserAgent.getAgent(options, userAgent);
+ if (currentRequest == null) {
+ return userAgent;
+ }
+
+ return UserAgent.getAgent(currentRequest.getClientCapabilities(),
+ userAgent);
}
private boolean negotiate(FetchRequest req,
@@ -1784,8 +1788,9 @@ public class UploadPack {
FetchRequest req,
@Nullable Collection<Ref> allTags,
List<ObjectId> unshallowCommits) throws IOException {
- final boolean sideband = options.contains(OPTION_SIDE_BAND)
- || options.contains(OPTION_SIDE_BAND_64K);
+ Set<String> caps = req.getClientCapabilities();
+ boolean sideband = caps.contains(OPTION_SIDE_BAND)
+ || caps.contains(OPTION_SIDE_BAND_64K);
if (sideband) {
try {
sendPack(true, req, accumulator, allTags, unshallowCommits);
@@ -1857,12 +1862,12 @@ public class UploadPack {
if (sideband) {
int bufsz = SideBandOutputStream.SMALL_BUF;
- if (options.contains(OPTION_SIDE_BAND_64K))
+ if (req.getClientCapabilities().contains(OPTION_SIDE_BAND_64K))
bufsz = SideBandOutputStream.MAX_BUF;
packOut = new SideBandOutputStream(SideBandOutputStream.CH_DATA,
bufsz, rawOut);
- if (!options.contains(OPTION_NO_PROGRESS)) {
+ if (!req.getClientCapabilities().contains(OPTION_NO_PROGRESS)) {
msgOut = new SideBandOutputStream(
SideBandOutputStream.CH_PROGRESS, bufsz, rawOut);
pm = new SideBandProgressMonitor(msgOut);
@@ -1909,8 +1914,9 @@ public class UploadPack {
&& req.getClientShallowCommits().isEmpty());
pw.setClientShallowCommits(req.getClientShallowCommits());
pw.setReuseDeltaCommits(true);
- pw.setDeltaBaseAsOffset(options.contains(OPTION_OFS_DELTA));
- pw.setThin(options.contains(OPTION_THIN_PACK));
+ pw.setDeltaBaseAsOffset(
+ req.getClientCapabilities().contains(OPTION_OFS_DELTA));
+ pw.setThin(req.getClientCapabilities().contains(OPTION_THIN_PACK));
pw.setReuseValidatingObjects(false);
// Objects named directly by references go at the beginning
@@ -1949,7 +1955,8 @@ public class UploadPack {
rw = ow;
}
- if (options.contains(OPTION_INCLUDE_TAG) && allTags != null) {
+ if (req.getClientCapabilities().contains(OPTION_INCLUDE_TAG)
+ && allTags != null) {
for (Ref ref : allTags) {
ObjectId objectId = ref.getObjectId();
if (objectId == null) {