diff options
author | Ivan Frade <ifrade@google.com> | 2018-08-23 15:20:57 -0700 |
---|---|---|
committer | Ivan Frade <ifrade@google.com> | 2018-08-23 15:22:06 -0700 |
commit | 0b84c5b29ea27cb9af47931792c3819d96da9d8d (patch) | |
tree | 4fde3d85421408800f6ab457b0ad506879797389 /org.eclipse.jgit | |
parent | e1b971848ad91e31558c1fe0cb8f241f3ed4e6e5 (diff) | |
download | jgit-0b84c5b29ea27cb9af47931792c3819d96da9d8d.tar.gz jgit-0b84c5b29ea27cb9af47931792c3819d96da9d8d.zip |
UploadPack: shallowExcludeRefs doesn't need to be nullable
Code can check size instead of null, and that makes the initialization
trivial.
Change-Id: Icbe655816429a7a680926b0e871d96f3b2f1f7ba
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/UploadPack.java | 16 |
1 files changed, 6 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 09acfdf581..3b66839545 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java @@ -309,10 +309,10 @@ public class UploadPack { /** * (Possibly short) ref names, ancestors of which the client has asked us - * not to send using --shallow-exclude. Cannot be non-null if depth is + * not to send using --shallow-exclude. Cannot be non-empty if depth is * nonzero. */ - private @Nullable List<String> shallowExcludeRefs; + private List<String> shallowExcludeRefs = new ArrayList<>(); /** Commit time of the oldest common commit, in seconds. */ private int oldestTime; @@ -1023,16 +1023,12 @@ public class UploadPack { throw new PackProtocolException( JGitText.get().deepenSinceWithDeepen); } - if (shallowExcludeRefs != null) { + if (!shallowExcludeRefs.isEmpty()) { throw new PackProtocolException( JGitText.get().deepenNotWithDeepen); } } else if (line.startsWith("deepen-not ")) { //$NON-NLS-1$ - List<String> exclude = shallowExcludeRefs; - if (exclude == null) { - exclude = shallowExcludeRefs = new ArrayList<>(); - } - exclude.add(line.substring(11)); + shallowExcludeRefs.add(line.substring(11)); if (depth != 0) { throw new PackProtocolException( JGitText.get().deepenNotWithDeepen); @@ -1071,7 +1067,7 @@ public class UploadPack { if (!clientShallowCommits.isEmpty()) { verifyClientShallow(); } - if (depth != 0 || shallowSince != 0 || shallowExcludeRefs != null) { + if (depth != 0 || shallowSince != 0 || !shallowExcludeRefs.isEmpty()) { shallowCommits = new ArrayList<>(); processShallow(shallowCommits, unshallowCommits, false); } @@ -1238,7 +1234,7 @@ public class UploadPack { boolean writeToPckOut) throws IOException { if (options.contains(OPTION_DEEPEN_RELATIVE) || shallowSince != 0 || - shallowExcludeRefs != null) { + !shallowExcludeRefs.isEmpty()) { // TODO(jonathantanmy): Implement deepen-relative, deepen-since, // and deepen-not. throw new UnsupportedOperationException(); |