ConfigBuilder.getDefault());
FetchV2Request request = parser.parseFetchRequest(pckIn,
testRepo.getRepository().getRefDatabase());
- assertTrue(request.getOptions()
+ assertTrue(request.getClientCapabilities()
.contains(GitProtocolConstants.OPTION_THIN_PACK));
- assertTrue(request.getOptions()
+ assertTrue(request.getClientCapabilities()
.contains(GitProtocolConstants.OPTION_NO_PROGRESS));
- assertTrue(request.getOptions()
+ assertTrue(request.getClientCapabilities()
.contains(GitProtocolConstants.OPTION_INCLUDE_TAG));
- assertTrue(request.getOptions()
+ assertTrue(request.getClientCapabilities()
.contains(GitProtocolConstants.CAPABILITY_OFS_DELTA));
- assertThat(objIdsAsStrings(request.getWantsIds()),
+ assertThat(objIdsAsStrings(request.getWantIds()),
hasItems("4624442d68ee402a94364191085b77137618633e",
"f900c8326a43303685c46b279b9f70411bff1a4b"));
assertThat(objIdsAsStrings(request.getPeerHas()),
"145e683b229dcab9d0e2ccb01b386f9ecc17d29d"));
assertTrue(request.getDeepenNotRefs().isEmpty());
assertEquals(15, request.getDepth());
- assertTrue(request.getOptions()
+ assertTrue(request.getClientCapabilities()
.contains(GitProtocolConstants.OPTION_DEEPEN_RELATIVE));
}
assertEquals(1, request.getWantedRefs().size());
assertThat(request.getWantedRefs().keySet(),
hasItems("refs/heads/branchA"));
- assertEquals(2, request.getWantsIds().size());
- assertThat(objIdsAsStrings(request.getWantsIds()),
+ assertEquals(2, request.getWantIds().size());
+ assertThat(objIdsAsStrings(request.getWantIds()),
hasItems("e4980cdc48cfa1301493ca94eb70523f6788b819",
one.getName()));
}
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}.
private final TreeMap<String, ObjectId> wantedRefs;
- private final Set<ObjectId> wantsIds;
+ private final Set<ObjectId> wantIds;
private final Set<ObjectId> clientShallowCommits;
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() {
}
/**
- * @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;
}
/**
}
/**
- * @return the refs in "deepen-not" lines in the request.
+ * @return refs received in "deepen-not" lines.
*/
@NonNull
List<String> getDeepenNotRefs() {
* @return options found in the request lines
*/
@NonNull
- Set<String> getOptions() {
- return options;
+ Set<String> getClientCapabilities() {
+ return clientCapabilities;
}
/** @return A builder of {@link 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;
/**
* @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);
}
/**
- * 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);
}
/**
- * @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;
}
* 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;
}
* 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);
}
}
}
// Packs are always sent multiplexed and using full 64K
// lengths.
- reqBuilder.addOption(OPTION_SIDE_BAND_64K);
+ reqBuilder.addClientCapability(OPTION_SIDE_BAND_64K);
String line;
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);
.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)));
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) {