aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit
diff options
context:
space:
mode:
authorIvan Frade <ifrade@google.com>2018-10-15 12:43:29 -0700
committerIvan Frade <ifrade@google.com>2018-10-15 16:27:58 -0700
commit8460ab8e879e4f9fe55f9e3a3c412c7c5369b5f9 (patch)
tree449eeb58e43372b69829251fd1de0b97e63321fc /org.eclipse.jgit
parent7d7b8dec567e0d8506d59761c09a9307d6103f6b (diff)
downloadjgit-8460ab8e879e4f9fe55f9e3a3c412c7c5369b5f9.tar.gz
jgit-8460ab8e879e4f9fe55f9e3a3c412c7c5369b5f9.zip
Rename Fetch V2 request wantsIds and options
In FetchV0Request, the fields "wantsIds" and "options" are called "wantIds" and "clientCapabilities". Those names describe them better. Rename FetchV2Request fields to follow fetch v0. This will make easier to extract a superclass later. Take also the chance to polish the javadoc. Change-Id: Ia17dbbab8084f39cc529fef9ca5c65e189073767 Signed-off-by: Ivan Frade <ifrade@google.com>
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/FetchV2Request.java113
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/ProtocolV2Parser.java16
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java8
3 files changed, 70 insertions, 67 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/FetchV2Request.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/FetchV2Request.java
index 853d96905c..64f7170df5 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/FetchV2Request.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/FetchV2Request.java
@@ -53,7 +53,7 @@ import org.eclipse.jgit.annotations.NonNull;
import org.eclipse.jgit.lib.ObjectId;
/**
- * fetch protocol v2 request.
+ * Fetch request from git protocol v2.
*
* <p>
* This is used as an input to {@link ProtocolV2Hook}.
@@ -65,7 +65,7 @@ public final class FetchV2Request {
private final TreeMap<String, ObjectId> wantedRefs;
- private final Set<ObjectId> wantsIds;
+ private final Set<ObjectId> wantIds;
private final Set<ObjectId> clientShallowCommits;
@@ -77,37 +77,37 @@ public final class FetchV2Request {
private final long filterBlobLimit;
- private final Set<String> options;
+ private final Set<String> clientCapabilities;
private final boolean doneReceived;
private FetchV2Request(List<ObjectId> peerHas,
- TreeMap<String, ObjectId> wantedRefs, Set<ObjectId> wantsIds,
+ TreeMap<String, ObjectId> wantedRefs, Set<ObjectId> wantIds,
Set<ObjectId> clientShallowCommits, int deepenSince,
List<String> deepenNotRefs, int depth, long filterBlobLimit,
- boolean doneReceived, Set<String> options) {
+ boolean doneReceived, Set<String> clientCapabilities) {
this.peerHas = peerHas;
this.wantedRefs = wantedRefs;
- this.wantsIds = wantsIds;
+ this.wantIds = wantIds;
this.clientShallowCommits = clientShallowCommits;
this.deepenSince = deepenSince;
this.deepenNotRefs = deepenNotRefs;
this.depth = depth;
this.filterBlobLimit = filterBlobLimit;
this.doneReceived = doneReceived;
- this.options = options;
+ this.clientCapabilities = clientCapabilities;
}
/**
- * @return object ids in the "have" lines of the request
+ * @return object ids received in the "have" lines
*/
@NonNull
List<ObjectId> getPeerHas() {
- return this.peerHas;
+ return peerHas;
}
/**
- * @return list of references in the "want-ref" lines of the request
+ * @return list of references received in "want-ref" lines
*/
@NonNull
Map<String, ObjectId> getWantedRefs() {
@@ -115,11 +115,11 @@ public final class FetchV2Request {
}
/**
- * @return object ids in the "want" (and "want-ref") lines of the request
+ * @return object ids received in the "want" and "want-ref" lines
*/
@NonNull
- Set<ObjectId> getWantsIds() {
- return wantsIds;
+ Set<ObjectId> getWantIds() {
+ return wantIds;
}
/**
@@ -146,7 +146,7 @@ public final class FetchV2Request {
}
/**
- * @return the refs in "deepen-not" lines in the request.
+ * @return refs received in "deepen-not" lines.
*/
@NonNull
List<String> getDeepenNotRefs() {
@@ -184,8 +184,8 @@ public final class FetchV2Request {
* @return options found in the request lines
*/
@NonNull
- Set<String> getOptions() {
- return options;
+ Set<String> getClientCapabilities() {
+ return clientCapabilities;
}
/** @return A builder of {@link FetchV2Request}. */
@@ -200,13 +200,13 @@ public final class FetchV2Request {
TreeMap<String, ObjectId> wantedRefs = new TreeMap<>();
- Set<ObjectId> wantsIds = new HashSet<>();
+ Set<ObjectId> wantIds = new HashSet<>();
Set<ObjectId> clientShallowCommits = new HashSet<>();
List<String> deepenNotRefs = new ArrayList<>();
- Set<String> options = new HashSet<>();
+ Set<String> clientCapabilities = new HashSet<>();
int depth;
@@ -221,8 +221,8 @@ public final class FetchV2Request {
/**
* @param objectId
- * from a "have" line in a fetch request
- * @return the builder
+ * object id received in a "have" line
+ * @return this builder
*/
Builder addPeerHas(ObjectId objectId) {
peerHas.add(objectId);
@@ -230,13 +230,13 @@ public final class FetchV2Request {
}
/**
- * From a "want-ref" line in a fetch request
+ * Ref received in "want-ref" line and the object-id it refers to
*
* @param refName
* reference name
* @param oid
- * object id
- * @return the builder
+ * object id the reference is pointing at
+ * @return this builder
*/
Builder addWantedRef(String refName, ObjectId oid) {
wantedRefs.put(refName, oid);
@@ -244,42 +244,42 @@ public final class FetchV2Request {
}
/**
- * @param option
- * fetch request lines acting as options
- * @return the builder
+ * @param clientCapability
+ * capability line sent by the client
+ * @return this builder
*/
- Builder addOption(String option) {
- options.add(option);
+ Builder addClientCapability(String clientCapability) {
+ clientCapabilities.add(clientCapability);
return this;
}
/**
- * @param objectId
- * from a "want" line in a fetch request
- * @return the builder
+ * @param wantId
+ * object id received in a "want" line
+ * @return this builder
*/
- Builder addWantsIds(ObjectId objectId) {
- wantsIds.add(objectId);
+ Builder addWantId(ObjectId wantId) {
+ wantIds.add(wantId);
return this;
}
/**
* @param shallowOid
- * from a "shallow" line in the fetch request
- * @return the builder
+ * object id received in a "shallow" line
+ * @return this builder
*/
Builder addClientShallowCommit(ObjectId shallowOid) {
- this.clientShallowCommits.add(shallowOid);
+ clientShallowCommits.add(shallowOid);
return this;
}
/**
* @param d
- * from a "deepen" line in the fetch request
- * @return the builder
+ * Depth received in a "deepen" line
+ * @return this builder
*/
Builder setDepth(int d) {
- this.depth = d;
+ depth = d;
return this;
}
@@ -288,32 +288,34 @@ public final class FetchV2Request {
* 0 if not set.
*/
int getDepth() {
- return this.depth;
+ return depth;
}
/**
- * @return if there has been any "deepen not" line in the request
+ * @return true if there has been at least one "deepen not" line in the
+ * request so far
*/
boolean hasDeepenNotRefs() {
return !deepenNotRefs.isEmpty();
}
/**
- * @param deepenNotRef reference in a "deepen not" line
- * @return the builder
+ * @param deepenNotRef
+ * reference received in a "deepen not" line
+ * @return this builder
*/
Builder addDeepenNotRef(String deepenNotRef) {
- this.deepenNotRefs.add(deepenNotRef);
+ deepenNotRefs.add(deepenNotRef);
return this;
}
/**
* @param value
* Unix timestamp received in a "deepen since" line
- * @return the builder
+ * @return this builder
*/
Builder setDeepenSince(int value) {
- this.deepenSince = value;
+ deepenSince = value;
return this;
}
@@ -322,35 +324,36 @@ public final class FetchV2Request {
* by default.
*/
int getDeepenSince() {
- return this.deepenSince;
+ return deepenSince;
}
/**
- * @param filterBlobLimit
+ * @param filterBlobLim
* set in a "filter" line
- * @return the builder
+ * @return this builder
*/
- Builder setFilterBlobLimit(long filterBlobLimit) {
- this.filterBlobLimit = filterBlobLimit;
+ Builder setFilterBlobLimit(long filterBlobLim) {
+ filterBlobLimit = filterBlobLim;
return this;
}
/**
* Mark that the "done" line has been received.
*
- * @return the builder
+ * @return this builder
*/
Builder setDoneReceived() {
- this.doneReceived = true;
+ doneReceived = true;
return this;
}
+
/**
* @return Initialized fetch request
*/
FetchV2Request build() {
- return new FetchV2Request(peerHas, wantedRefs, wantsIds,
+ return new FetchV2Request(peerHas, wantedRefs, wantIds,
clientShallowCommits, deepenSince, deepenNotRefs,
- depth, filterBlobLimit, doneReceived, options);
+ depth, filterBlobLimit, doneReceived, clientCapabilities);
}
}
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/ProtocolV2Parser.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/ProtocolV2Parser.java
index da0fb9c447..71b5773a42 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/ProtocolV2Parser.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/ProtocolV2Parser.java
@@ -104,7 +104,7 @@ final class ProtocolV2Parser {
// Packs are always sent multiplexed and using full 64K
// lengths.
- reqBuilder.addOption(OPTION_SIDE_BAND_64K);
+ reqBuilder.addClientCapability(OPTION_SIDE_BAND_64K);
String line;
@@ -118,7 +118,7 @@ final class ProtocolV2Parser {
boolean filterReceived = false;
while ((line = pckIn.readString()) != PacketLineIn.END) {
if (line.startsWith("want ")) { //$NON-NLS-1$
- reqBuilder.addWantsIds(ObjectId.fromString(line.substring(5)));
+ reqBuilder.addWantId(ObjectId.fromString(line.substring(5)));
} else if (transferConfig.isAllowRefInWant()
&& line.startsWith(OPTION_WANT_REF + " ")) { //$NON-NLS-1$
String refName = line.substring(OPTION_WANT_REF.length() + 1);
@@ -136,19 +136,19 @@ final class ProtocolV2Parser {
.format(JGitText.get().invalidRefName, refName));
}
reqBuilder.addWantedRef(refName, oid);
- reqBuilder.addWantsIds(oid);
+ reqBuilder.addWantId(oid);
} else if (line.startsWith("have ")) { //$NON-NLS-1$
reqBuilder.addPeerHas(ObjectId.fromString(line.substring(5)));
} else if (line.equals("done")) { //$NON-NLS-1$
reqBuilder.setDoneReceived();
} else if (line.equals(OPTION_THIN_PACK)) {
- reqBuilder.addOption(OPTION_THIN_PACK);
+ reqBuilder.addClientCapability(OPTION_THIN_PACK);
} else if (line.equals(OPTION_NO_PROGRESS)) {
- reqBuilder.addOption(OPTION_NO_PROGRESS);
+ reqBuilder.addClientCapability(OPTION_NO_PROGRESS);
} else if (line.equals(OPTION_INCLUDE_TAG)) {
- reqBuilder.addOption(OPTION_INCLUDE_TAG);
+ reqBuilder.addClientCapability(OPTION_INCLUDE_TAG);
} else if (line.equals(OPTION_OFS_DELTA)) {
- reqBuilder.addOption(OPTION_OFS_DELTA);
+ reqBuilder.addClientCapability(OPTION_OFS_DELTA);
} else if (line.startsWith("shallow ")) { //$NON-NLS-1$
reqBuilder.addClientShallowCommit(
ObjectId.fromString(line.substring(8)));
@@ -175,7 +175,7 @@ final class ProtocolV2Parser {
JGitText.get().deepenNotWithDeepen);
}
} else if (line.equals(OPTION_DEEPEN_RELATIVE)) {
- reqBuilder.addOption(OPTION_DEEPEN_RELATIVE);
+ reqBuilder.addClientCapability(OPTION_DEEPEN_RELATIVE);
} else if (line.startsWith("deepen-since ")) { //$NON-NLS-1$
int ts = Integer.parseInt(line.substring(13));
if (ts <= 0) {
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 5c7bde05f8..a385339336 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java
@@ -964,8 +964,8 @@ public class UploadPack {
// TODO(ifrade): Refactor to pass around the Request object, instead of
// copying data back to class fields
- options = req.getOptions();
- wantIds.addAll(req.getWantsIds());
+ options = req.getClientCapabilities();
+ wantIds = req.getWantIds();
clientShallowCommits = req.getClientShallowCommits();
depth = req.getDepth();
shallowSince = req.getDeepenSince();
@@ -983,7 +983,7 @@ public class UploadPack {
verifyClientShallow(req.getClientShallowCommits());
}
if (mayHaveShallow) {
- computeShallowsAndUnshallows(req.getWantsIds(),
+ computeShallowsAndUnshallows(req.getWantIds(),
shallowCommit -> shallowCommits.add(shallowCommit),
unshallowCommit -> unshallowCommits.add(unshallowCommit));
}
@@ -1041,7 +1041,7 @@ public class UploadPack {
pckOut.writeDelim();
pckOut.writeString("packfile\n"); //$NON-NLS-1$
sendPack(new PackStatistics.Accumulator(),
- req.getOptions().contains(OPTION_INCLUDE_TAG)
+ req.getClientCapabilities().contains(OPTION_INCLUDE_TAG)
? db.getRefDatabase().getRefsByPrefix(R_TAGS)
: null,
unshallowCommits);