Browse Source

UploadPack.fetchV2: Make shallow commits list non-nullable

shallowCommits variable is nullable only to signal later
if code has gone through the processShallow code.

Use a flag to indicate that condition and make shallowCommits
non-nullable. This makes code clearer and paves the way to untangle
processShallow in a follow-up commit.

Change-Id: I898e6aaf6f860bb6afafbac05653ba116c9b2da6
Signed-off-by: Ivan Frade <ifrade@google.com>
stable-5.2
Ivan Frade 6 years ago
parent
commit
093fa8ef52
  1. 11
      org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java

11
org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java

@ -973,15 +973,16 @@ public class UploadPack {
deepenNotRefs = req.getDeepenNotRefs();
boolean sectionSent = false;
@Nullable List<ObjectId> shallowCommits = null;
boolean mayHaveShallow = req.getDepth() != 0
|| req.getDeepenSince() != 0
|| !req.getDeepenNotRefs().isEmpty();
List<ObjectId> shallowCommits = new ArrayList<>();
List<ObjectId> unshallowCommits = new ArrayList<>();
if (!req.getClientShallowCommits().isEmpty()) {
verifyClientShallow(req.getClientShallowCommits());
}
if (req.getDepth() != 0 || req.getDeepenSince() != 0
|| !req.getDeepenNotRefs().isEmpty()) {
shallowCommits = new ArrayList<>();
if (mayHaveShallow) {
processShallow(shallowCommits, unshallowCommits, false);
}
if (!req.getClientShallowCommits().isEmpty())
@ -1008,7 +1009,7 @@ public class UploadPack {
}
if (req.wasDoneReceived() || okToGiveUp()) {
if (shallowCommits != null) {
if (mayHaveShallow) {
if (sectionSent)
pckOut.writeDelim();
pckOut.writeString("shallow-info\n"); //$NON-NLS-1$

Loading…
Cancel
Save